From 26b368ecc159886ae4122d2b31e307089077f0d3 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 2 Feb 2025 13:03:31 +0200 Subject: feat(views/list): Move add item patch requests to list/add --- controllers/list.php | 6 +++++- views/list/add/index.php | 11 +++++++++-- views/list/add/meta.php | 1 + 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) {} ?> - +

To which list do you want to add
URL ?>
@@ -19,8 +19,15 @@ Date ?>?

-
+ + + +

+ Error: +

+ +