Allow creating new ebook placeholders when creating a new project

This commit is contained in:
Alex Cabal 2024-12-18 22:23:39 -06:00
parent 4596aeb007
commit 98e09f414e
14 changed files with 114 additions and 44 deletions

View file

@ -56,6 +56,9 @@ catch(Exceptions\InvalidPermissionsException){
<form class="create-update-ebook-placeholder" method="<?= Enums\HttpMethod::Post->value ?>" action="<?= $ebook->Url ?>" autocomplete="off">
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Put->value ?>" />
<?= Template::EbookPlaceholderForm(['ebook' => $ebook, 'isEditForm' => true]) ?>
<div class="footer">
<button>Save</button>
</div>
</form>
</section>
</main>

View file

@ -82,6 +82,9 @@ catch(Exceptions\InvalidPermissionsException){
<form class="create-update-ebook-placeholder" method="<?= Enums\HttpMethod::Post->value ?>" action="/ebook-placeholders" autocomplete="off">
<?= Template::EbookPlaceholderForm(['ebook' => $ebook]) ?>
<div class="footer">
<button>Submit</button>
</div>
</form>
</section>
</main>

View file

@ -42,9 +42,9 @@ try{
$_SESSION['is-only-ebook-project-created'] = true;
}
else{
// No `Project`, throw the exception and really fail.
// The existing ebook already has a `Project`, throw the exception and really fail.
$ebook = $existingEbook;
throw $ex;
throw new Exceptions\ProjectExistsException('This ebook already exists, and already has an in-progress project.');
}
}
@ -85,7 +85,7 @@ catch(Exceptions\LoginRequiredException){
catch(Exceptions\InvalidPermissionsException | Exceptions\InvalidHttpMethodException | Exceptions\HttpMethodNotAllowedException){
Template::ExitWithCode(Enums\HttpCode::Forbidden);
}
catch(Exceptions\InvalidEbookException | Exceptions\InvalidProjectException $ex){
catch(Exceptions\InvalidEbookException | Exceptions\ProjectExistsException | Exceptions\InvalidProjectException $ex){
$_SESSION['ebook'] = $ebook;
$_SESSION['exception'] = $ex;