From fb38bb7f862ed201cd034fab7b4e48c4307803ee Mon Sep 17 00:00:00 2001 From: grandeljay Date: Sun, 20 Nov 2022 11:18:29 +0100 Subject: [PATCH] Refactor --- src/assets/js/parts/wishlist-filter.js | 6 +++++- src/assets/js/{ => parts}/wishlists.js | 10 ++++++---- .../{wishlist-filter.php => wishlist.php} | 15 ++++++++++++-- src/pages/wishlist.php | 20 +------------------ src/pages/wishlists.php | 4 +--- 5 files changed, 26 insertions(+), 29 deletions(-) rename src/assets/js/{ => parts}/wishlists.js (99%) rename src/pages/parts/{wishlist-filter.php => wishlist.php} (84%) diff --git a/src/assets/js/parts/wishlist-filter.js b/src/assets/js/parts/wishlist-filter.js index db8dbe9b..8c815f65 100644 --- a/src/assets/js/parts/wishlist-filter.js +++ b/src/assets/js/parts/wishlist-filter.js @@ -23,7 +23,11 @@ $(function () { var dropdown_wishlists = $('.dropdown.wishlists'); if (dropdown_wishlists.length) { - settings.urlData.wishlistid = $('.dropdown.wishlists').dropdown('get value'); + var dropdown_wishlists_value = dropdown_wishlists.dropdown('get value'); + + if (dropdown_wishlists_value) { + settings.urlData.wishlistid = dropdown_wishlists_value; + } } if (typeof wistlist_cards_data !== 'undefined') { diff --git a/src/assets/js/wishlists.js b/src/assets/js/parts/wishlists.js similarity index 99% rename from src/assets/js/wishlists.js rename to src/assets/js/parts/wishlists.js index 718958fe..f6347639 100644 --- a/src/assets/js/wishlists.js +++ b/src/assets/js/parts/wishlists.js @@ -20,7 +20,7 @@ $(function () { /** * Get Wishlists */ - var wishlists = []; + var wishlists = []; $('.ui.dropdown.wishlists') .dropdown() @@ -39,15 +39,17 @@ $(function () { wishlists = response.results; dropdown_wishlists.dropdown({ - values : wishlists + 'values' : wishlists, }) /** Select current/active wishlist */ if (wishlist.id) { dropdown_wishlists.dropdown('set selected', wishlist.id); } else { - if (wishlists.length >= 1) { - dropdown_wishlists.dropdown('set selected', Object.values(wishlists)[0]); + if (Object.keys(wishlists).length >= 1) { + var first_wishlist_id = Object.keys(wishlists)[0]; + + dropdown_wishlists.dropdown('set selected', first_wishlist_id); } } diff --git a/src/pages/parts/wishlist-filter.php b/src/pages/parts/wishlist.php similarity index 84% rename from src/pages/parts/wishlist-filter.php rename to src/pages/parts/wishlist.php index 51adc5b2..5f89e936 100644 --- a/src/pages/parts/wishlist-filter.php +++ b/src/pages/parts/wishlist.php @@ -6,9 +6,14 @@ namespace wishthis; -$scriptPart = '/src/assets/js/parts/wishlist-filter.js'; +$scripts = array( + '/src/assets/js/parts/wishlist-filter.js', + '/src/assets/js/parts/wishlists.js', +); ?> - + + +
@@ -65,3 +70,9 @@ $scriptPart = '/src/assets/js/parts/wishlist-filter.js';
+ +id)) { ?> +
+ +
+ diff --git a/src/pages/wishlist.php b/src/pages/wishlist.php index 8ace6eab..4769f8a4 100644 --- a/src/pages/wishlist.php +++ b/src/pages/wishlist.php @@ -69,25 +69,7 @@ $page->navigation();

- - -
- getCards( - array( - 'WHERE' => '`wishlist` = ' . $wishlist->id . ' - AND ( - `status` = "" - OR `status` IS NULL - OR `status` < unix_timestamp(CURRENT_TIMESTAMP - INTERVAL ' . Wish::STATUS_TEMPORARY_MINUTES . ' MINUTE) - ) - AND (`status` != "' . Wish::STATUS_UNAVAILABLE . '" OR `status` IS NULL)' - ) - ); - */ - ?> -
+
- - -
+