Allow editing of projects

This commit is contained in:
Alex Cabal 2024-12-18 14:20:28 -06:00
parent e21f411191
commit b2191d1219
16 changed files with 191 additions and 75 deletions

View file

@ -2,6 +2,8 @@
/**
* @var Ebook $ebook
*/
$showPlaceholderMetadata = $showPlaceholderMetadata ?? false;
?>
<section id="metadata">
<h2>Metadata</h2>
@ -11,7 +13,16 @@
<td>Ebook ID:</td>
<td><?= $ebook->EbookId ?></td>
</tr>
<? if($ebook->IsPlaceholder() && $ebook->EbookPlaceholder !== null){ ?>
</tbody>
</table>
</section>
<? if($showPlaceholderMetadata && $ebook->IsPlaceholder() && $ebook->EbookPlaceholder !== null){ ?>
<section id="placeholder-metadata">
<h2>Placeholder metadata</h2>
<p><a href="<?= $ebook->EditUrl ?>">Edit placeholder</a></p>
<table class="admin-table">
<tbody>
<tr>
<td>Is wanted:</td>
<td><? if($ebook->EbookPlaceholder->IsWanted){ ?>☑<? }else{ ?>☐<? } ?></td>
@ -26,7 +37,8 @@
<td>Difficulty:</td>
<td><?= ucfirst($ebook->EbookPlaceholder->Difficulty->value ?? '') ?></td>
</tr>
<? } ?>
</tbody>
</table>
</section>
</tbody>
</table>
</section>
<? } ?>

View file

@ -1,5 +1,6 @@
<?
$ebook = $ebook ?? new Ebook();
$isEditForm = $isEditForm ?? false;
?>
<fieldset>
<legend>Contributors</legend>
@ -189,21 +190,23 @@ $ebook = $ebook ?? new Ebook();
</label>
</fieldset>
</details>
<fieldset>
<legend>Project</legend>
<label class="controls-following-fieldset">
<span>In progress?</span>
<input type="hidden" name="ebook-placeholder-is-in-progress" value="false" />
<input
type="checkbox"
name="ebook-placeholder-is-in-progress"
<? if($ebook->EbookPlaceholder?->IsInProgress){ ?>checked="checked"<? } ?>
/>
</label>
<fieldset class="project-form">
<?= Template::ProjectForm(['project' => $ebook->ProjectInProgress, 'areFieldsRequired' => false]) ?>
<? if(!$isEditForm){ ?>
<fieldset>
<legend>Project</legend>
<label class="controls-following-fieldset">
<span>In progress?</span>
<input type="hidden" name="ebook-placeholder-is-in-progress" value="false" />
<input
type="checkbox"
name="ebook-placeholder-is-in-progress"
<? if($ebook->EbookPlaceholder?->IsInProgress){ ?>checked="checked"<? } ?>
/>
</label>
<fieldset class="project-form">
<?= Template::ProjectForm(['project' => $ebook->ProjectInProgress, 'areFieldsRequired' => false]) ?>
</fieldset>
</fieldset>
</fieldset>
<? } ?>
<fieldset>
<legend>Wanted list</legend>
<label class="controls-following-fieldset">

View file

@ -4,13 +4,16 @@
*/
$showAddButton = $showAddButton ?? false;
$showEditButton = $showEditButton ?? false;
?>
<section id="projects">
<h2>Projects</h2>
<? if($showAddButton){ ?>
<a href="<?= $ebook->Url ?>/projects/new">New project</a>
<p>
<a href="<?= $ebook->Url ?>/projects/new">New project</a>
</p>
<? } ?>
<? if(sizeof($ebook->Projects) > 0){ ?>
<?= Template::ProjectsTable(['projects' => $ebook->Projects, 'includeTitle' => false]) ?>
<?= Template::ProjectsTable(['projects' => $ebook->Projects, 'includeTitle' => false, 'showEditButton' => $showEditButton]) ?>
<? } ?>
</section>

View file

@ -3,8 +3,11 @@ $project = $project ?? new Project();
$managers = User::GetAllByCanManageProjects();
$reviewers = User::GetAllByCanReviewProjects();
$areFieldsRequired = $areFieldsRequired ?? true;
$isEditForm = $isEditForm ?? false;
?>
<input type="hidden" name="project-ebook-id" value="<?= $project->EbookId ?? '' ?>" />
<? if(!$isEditForm){ ?>
<input type="hidden" name="project-ebook-id" value="<?= $project->EbookId ?? '' ?>" />
<? } ?>
<label class="icon user">
<span>Producer name</span>

View file

@ -5,6 +5,7 @@
$includeTitle = $includeTitle ?? true;
$includeStatus = $includeStatus ?? true;
$showEditButton = $showEditButton ?? false;
?>
<table class="data-table">
<caption aria-hidden="true">Scroll right </caption>
@ -22,6 +23,9 @@ $includeStatus = $includeStatus ?? true;
<? } ?>
<th></th>
<th></th>
<? if($showEditButton){ ?>
<th></th>
<? } ?>
</tr>
</thead>
<tbody>
@ -65,6 +69,11 @@ $includeStatus = $includeStatus ?? true;
<a href="<?= Formatter::EscapeHtml($project->DiscussionUrl) ?>">Discussion</a>
<? } ?>
</td>
<? if($showEditButton){ ?>
<td>
<a href="<?= $project->EditUrl ?>">Edit</a>
</td>
<? } ?>
</tr>
<? } ?>
</tbody>