This commit is contained in:
grandeljay 2022-11-20 11:18:29 +01:00
parent 24082c5cff
commit fb38bb7f86
5 changed files with 26 additions and 29 deletions

View file

@ -23,7 +23,11 @@ $(function () {
var dropdown_wishlists = $('.dropdown.wishlists'); var dropdown_wishlists = $('.dropdown.wishlists');
if (dropdown_wishlists.length) { 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') { if (typeof wistlist_cards_data !== 'undefined') {

View file

@ -20,7 +20,7 @@ $(function () {
/** /**
* Get Wishlists * Get Wishlists
*/ */
var wishlists = []; var wishlists = [];
$('.ui.dropdown.wishlists') $('.ui.dropdown.wishlists')
.dropdown() .dropdown()
@ -39,15 +39,17 @@ $(function () {
wishlists = response.results; wishlists = response.results;
dropdown_wishlists.dropdown({ dropdown_wishlists.dropdown({
values : wishlists 'values' : wishlists,
}) })
/** Select current/active wishlist */ /** Select current/active wishlist */
if (wishlist.id) { if (wishlist.id) {
dropdown_wishlists.dropdown('set selected', wishlist.id); dropdown_wishlists.dropdown('set selected', wishlist.id);
} else { } else {
if (wishlists.length >= 1) { if (Object.keys(wishlists).length >= 1) {
dropdown_wishlists.dropdown('set selected', Object.values(wishlists)[0]); var first_wishlist_id = Object.keys(wishlists)[0];
dropdown_wishlists.dropdown('set selected', first_wishlist_id);
} }
} }

View file

@ -6,9 +6,14 @@
namespace wishthis; 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',
);
?> ?>
<script defer src="<?= $scriptPart ?>?m=<?= filemtime(ROOT . $scriptPart) ?>"></script> <?php foreach ($scripts as $script) { ?>
<script defer src="<?= $script ?>?m=<?= filemtime(ROOT . $script) ?>"></script>
<?php } ?>
<div> <div>
<div class="ui stackable grid"> <div class="ui stackable grid">
@ -65,3 +70,9 @@ $scriptPart = '/src/assets/js/parts/wishlist-filter.js';
</div> </div>
</div> </div>
</div> </div>
<?php if (isset($wishlist->id)) { ?>
<div class="wishlist-cards" data-wishlist="<?= $wishlist->id ?>"></div>
<?php } else { ?>
<div class="wishlist-cards"></div>
<?php } ?>

View file

@ -69,25 +69,7 @@ $page->navigation();
<h2 class="ui header"><?= __('Wishes') ?></h2> <h2 class="ui header"><?= __('Wishes') ?></h2>
<?php include 'parts/wishlist-filter.php' ?> <?php include 'parts/wishlist.php' ?>
<div class="wishlist-cards" data-wishlist="<?= $wishlist->id ?>">
<?php
/*
echo $wishlist->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)'
)
);
*/
?>
</div>
<div class="ui basic center aligned segment"> <div class="ui basic center aligned segment">
<button class="ui primary button wishlist-request-wishes" data-locale="<?= $wishlist_user->getLocale() ?>"> <button class="ui primary button wishlist-request-wishes" data-locale="<?= $wishlist_user->getLocale() ?>">

View file

@ -92,9 +92,7 @@ $page->navigation();
</div> </div>
</div> </div>
<?php include 'parts/wishlist-filter.php' ?> <?php include 'parts/wishlist.php' ?>
<div class="wishlist-cards"></div>
</div> </div>
</main> </main>