diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-02 10:54:23 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-02 10:54:23 +0200 |
| commit | 4bebfa04cf759d77c511541bdf30747c76a3b2e1 (patch) | |
| tree | 10eb1a2820fbbf3f49fdafb0a7821abc25e306e6 /views | |
| parent | b0fb3d9df06ab9aa77f95b3b60d60f414a9f5ebe (diff) | |
| download | nowayforward_human-4bebfa04cf759d77c511541bdf30747c76a3b2e1.tar nowayforward_human-4bebfa04cf759d77c511541bdf30747c76a3b2e1.tar.gz nowayforward_human-4bebfa04cf759d77c511541bdf30747c76a3b2e1.zip | |
feat(views/list): Fully implement list updating
Diffstat (limited to 'views')
| -rw-r--r-- | views/list/index.php | 17 | ||||
| -rw-r--r-- | views/list/update/index.php | 46 | ||||
| -rw-r--r-- | views/list/update/meta.php | 4 | ||||
| -rw-r--r-- | views/styles.css | 8 |
4 files changed, 75 insertions, 0 deletions
diff --git a/views/list/index.php b/views/list/index.php index 9b49268..4a84f78 100644 --- a/views/list/index.php +++ b/views/list/index.php @@ -18,6 +18,23 @@ <?= $author->Username ?> </p> <p><?= $list->Description ?></p> + + <section id="list-buttons" hidden> + <form action="/list/update" method="GET"> + <input type="hidden" name="lid" value="<?= $list->LID ?>"> + <input type="submit" value="Update"> + </form> + <form action="/list/delete" method="GET"> + <input type="hidden" name="lid" value="<?= $list->LID ?>"> + <input type="submit" value="Delete"> + </form> + </section> + <script type="text/javascript"> + function showListButtons() { + document.getElementById('list-buttons').hidden = false; + } + authenticated(showListButtons); + </script> </section> <section> <?php diff --git a/views/list/update/index.php b/views/list/update/index.php new file mode 100644 index 0000000..9374aef --- /dev/null +++ b/views/list/update/index.php @@ -0,0 +1,46 @@ +<?php + require_login(); + + $list = null; + $author = null; + $user = null; + + try { + $list = Database\ArchiveList::fromDB($_GET['lid'] ?? -1); + $author = Database\User::fromDBuid($list->AuthorUID); + $user = Database\Cookie::fromDB($TOKEN); + } + catch(Exception $e) {} +?> + +<?php if ($list !== null && $user->UID === $author->UID): ?> + +<h1>Update list</h1> + +<form action="#" method="POST" class="font-115 flex-col-centered max-width-20 center-margin"> + <input type="hidden" name="method" value="PUT"> + <?php if (isset($list_status)): ?> + <?php if ($list_status !== ""): ?> + <p class="item error"><span> + <strong>Error:</strong> <?= $list_status ?> + </span></p> + <?php else: ?> + <script type="text/javascript"> + window.location.href = '/list/<?= $_GET["lid"] ?>'; + </script> + <?php endif; ?> + <?php endif; ?> + + <input type="hidden" name="lid" value="<?= $_GET['lid'] ?>"> + <input type="text" name="name" placeholder="List title" minlength="1" value="<?= $list->Name ?>"> + <textarea name="description" placeholder="Description"><?= $list->Description ?></textarea> + <input type="submit" value="Update"> +</form> + +<?php elseif ($list === null): ?> + <h2>No list with identifier <?= $_GET['lid'] ?> exists!</h2> + +<?php else: ?> + <h2>You're not the owner of "<?= $list->Name ?>", you have no permission to edit it!</h2> + +<?php endif; ?> diff --git a/views/list/update/meta.php b/views/list/update/meta.php new file mode 100644 index 0000000..c3a9f3c --- /dev/null +++ b/views/list/update/meta.php @@ -0,0 +1,4 @@ +<?php + +$title = 'Update a list of archives'; +$controller = 'list'; diff --git a/views/styles.css b/views/styles.css index 4d17e51..132d280 100644 --- a/views/styles.css +++ b/views/styles.css @@ -407,6 +407,14 @@ hr.new-section { vertical-align: middle; } +.list-container #list-buttons { + display: flex; + flex-direction: column; + gap: 0.9em; + font-size: 0.8em; + margin-top: 4em; +} + /* User */ .user-icon { height: 7em; |
