diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-02 13:03:31 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-02 13:03:31 +0200 |
| commit | 26b368ecc159886ae4122d2b31e307089077f0d3 (patch) | |
| tree | 3ce356dd2f784772d88e3fd5a67e65b52d193020 | |
| parent | e409c1c7123dce3838d6dd1a72b4b0c2f00fba10 (diff) | |
| download | nowayforward_human-26b368ecc159886ae4122d2b31e307089077f0d3.tar nowayforward_human-26b368ecc159886ae4122d2b31e307089077f0d3.tar.gz nowayforward_human-26b368ecc159886ae4122d2b31e307089077f0d3.zip | |
feat(views/list): Move add item patch requests to list/add
| -rw-r--r-- | controllers/list.php | 6 | ||||
| -rw-r--r-- | views/list/add/index.php | 11 | ||||
| -rw-r--r-- | views/list/add/meta.php | 1 | ||||
| -rw-r--r-- | views/list/meta.php | 1 |
4 files changed, 15 insertions, 4 deletions
diff --git a/controllers/list.php b/controllers/list.php index c2e72a0..e608136 100644 --- a/controllers/list.php +++ b/controllers/list.php @@ -22,11 +22,14 @@ function on_post() { function on_patch() { global $TOKEN; global $METHOD; + global $list_status; + $list_status = ""; try { $user = Database\Cookie::fromDB($TOKEN); } catch(Exception $e) { + $list_status = "Couldn't retrieve user!"; return; } @@ -35,13 +38,14 @@ function on_patch() { $list = Database\ArchiveList::fromDB($METHOD['lid']); } catch(Exception $e) { + $list_status = "Couldn't retrieve list!"; return; } switch ($METHOD['type']) { case 'add': $list->addItem($METHOD['wid']); break; - default: throw new Exception('Unknown type ' . $METHOD['type']); + default: $list_status = 'Unknown action ' . $METHOD['type']; return; } header('Location: /list/' . $list->LID); diff --git a/views/list/add/index.php b/views/list/add/index.php index 5366110..98c768d 100644 --- a/views/list/add/index.php +++ b/views/list/add/index.php @@ -11,7 +11,7 @@ catch (Exception $e) {} ?> -<?php if ($webpage !== null && $list !== null): ?> +<?php if ($webpage !== null && $list !== null && $list): ?> <h2> To which list do you want to add</br> <?= $webpage->URL ?></br> @@ -19,8 +19,15 @@ <?= $webpage->Date ?>? </h2> - <form action="/list" method="GET" class="font-125 flex-row width-100 center-margin"> + <form action="#" method="POST" class="font-125 flex-row width-100 center-margin"> <input type="hidden" name="method" value="PATCH"> + <?php if (isset($list_status)): ?> + <?php if ($list_status !== ""): ?> + <p class="item error"><span> + <strong>Error:</strong> <?= $list_status ?> + </span></p> + <?php endif; ?> + <?php endif; ?> <select name="lid" class="flex-expand"> <?php foreach ($list as $list): ?> <option value="<?= $list->LID ?>"><?= $list->Name ?></option> diff --git a/views/list/add/meta.php b/views/list/add/meta.php index 96fd169..5465475 100644 --- a/views/list/add/meta.php +++ b/views/list/add/meta.php @@ -1,3 +1,4 @@ <?php $title = 'Add to list'; +$controller = 'list'; diff --git a/views/list/meta.php b/views/list/meta.php index 5e5e52e..137794e 100644 --- a/views/list/meta.php +++ b/views/list/meta.php @@ -2,4 +2,3 @@ $lid = explode('/', $uri, 4)[2]; $title = 'List'; -$controller = 'list'; |
