From 62ec209a5f8a1ed3a6de89d460555bd2fb3b3738 Mon Sep 17 00:00:00 2001 From: Jay Trees Date: Tue, 19 Apr 2022 08:57:27 +0200 Subject: [PATCH] Allow marking wishes as fulfilled --- CHANGELOG.md | 5 +++-- src/assets/js/wishlists.js | 21 +++++++++++++++++++++ src/classes/page.php | 1 + src/classes/wish.php | 6 ++++++ src/pages/wishlist.php | 3 ++- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 454afe7b..5b83206f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - This changelog - Wish properties +- Button to mark wish as fulfilled -### Changed -- Improved card design +### Improved +- Card design ### Fixed - Various small bugs diff --git a/src/assets/js/wishlists.js b/src/assets/js/wishlists.js index 035c391a..f9cc6f22 100644 --- a/src/assets/js/wishlists.js +++ b/src/assets/js/wishlists.js @@ -296,6 +296,27 @@ $(function () { } }); + /** + * Mark as Fulfilled + */ + $(document).on('click', '.wish-fulfilled', function() { + var button = $(this); + var card = button.closest('.card'); + + button.api({ + action : 'update wish status', + method : 'PUT', + data : { + wish_id : card.attr('data-id'), + wish_status : wish_status_fulfilled, + }, + on : 'now', + onSuccess : function(response, element, xhr) { + card.closest('.column').fadeOut(); + }, + }); + }); + /** * Delete Wish */ diff --git a/src/classes/page.php b/src/classes/page.php index 58c08c83..2b635cc4 100644 --- a/src/classes/page.php +++ b/src/classes/page.php @@ -310,6 +310,7 @@ class Page var $_GET = JSON.parse(''); var wish_status_temporary = ''; var wish_status_unavailable = ''; + var wish_status_fulfilled = ''; var text = { wishlist_no_selection : '', diff --git a/src/classes/wish.php b/src/classes/wish.php index 1c1cd5d3..40a3bd57 100644 --- a/src/classes/wish.php +++ b/src/classes/wish.php @@ -16,6 +16,7 @@ class Wish public const STATUS_TEMPORARY = 'temporary'; public const STATUS_TEMPORARY_MINUTES = 30; public const STATUS_UNAVAILABLE = 'unavailable'; + public const STATUS_FULFILLED = 'fulfilled'; public static array $priorities; @@ -205,6 +206,11 @@ class Wish