Merge branch 'develop' of https://github.com/grandeljay/wishthis into develop

This commit is contained in:
Jay Trees 2022-04-08 09:08:49 +02:00
commit a1d12caab1
9 changed files with 49 additions and 15 deletions

View file

@ -8,7 +8,7 @@
RewriteRule ^([a-z\-]+)/(\d+)$ /?page=$1&id=$2 [QSA,L] RewriteRule ^([a-z\-]+)/(\d+)$ /?page=$1&id=$2 [QSA,L]
# Wishlists # Wishlists
RewriteRule ^([a-z\-]+)/(\d+)$ /?page=$1&wishlist=$2 [QSA,L] RewriteRule ^([a-z\-]+)/(\d+)$ /?page=$1&id=$2 [QSA,L]
# Wishlist # Wishlist
RewriteRule ^wishlist/([a-z0-9]+)$ /?wishlist=$1 [QSA,L] RewriteRule ^wishlist/([a-z0-9]+)$ /?wishlist=$1 [QSA,L]

View file

@ -6,7 +6,7 @@
* @author Jay Trees <github.jay@grandel.anonaddy.me> * @author Jay Trees <github.jay@grandel.anonaddy.me>
*/ */
define('VERSION', '0.6.0'); define('VERSION', '0.5.0');
define('ROOT', __DIR__); define('ROOT', __DIR__);
define('DEFAULT_LOCALE', 'en_GB'); define('DEFAULT_LOCALE', 'en_GB');

View file

@ -90,6 +90,8 @@ switch ($_SERVER['REQUEST_METHOD']) {
SET `status` = "' . $_PUT['wish_status'] . '" SET `status` = "' . $_PUT['wish_status'] . '"
WHERE `id` = ' . $_PUT['wish_id'] . ' WHERE `id` = ' . $_PUT['wish_id'] . '
;'); ;');
$response['success'] = true;
} elseif (isset($_PUT['wish_url_current'], $_PUT['wish_url_proposed'])) { } elseif (isset($_PUT['wish_url_current'], $_PUT['wish_url_proposed'])) {
/** /**
* Update Wish URL * Update Wish URL
@ -98,6 +100,8 @@ switch ($_SERVER['REQUEST_METHOD']) {
SET `url` = "' . $_PUT['wish_url_proposed'] . '" SET `url` = "' . $_PUT['wish_url_proposed'] . '"
WHERE `url` = "' . $_PUT['wish_url_current'] . '" WHERE `url` = "' . $_PUT['wish_url_current'] . '"
;'); ;');
$response['success'] = true;
} }
break; break;
@ -109,6 +113,8 @@ switch ($_SERVER['REQUEST_METHOD']) {
WHERE `id` = ' . $_DELETE['wish_id'] . ' WHERE `id` = ' . $_DELETE['wish_id'] . '
;'); ;');
} }
$response['success'] = true;
break; break;
} }

View file

@ -101,6 +101,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
WHERE `id` = ' . $_PUT['wishlist_id'] . ' WHERE `id` = ' . $_PUT['wishlist_id'] . '
;'); ;');
$response['success'] = true;
break; break;
case 'DELETE': case 'DELETE':
@ -110,6 +111,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
WHERE `id` = ' . $_DELETE['wishlistID'] . ' WHERE `id` = ' . $_DELETE['wishlistID'] . '
;'); ;');
$response['success'] = true;
break; break;
} }

View file

@ -40,8 +40,8 @@ $(function() {
placeholder: text.wishlist_no_selection placeholder: text.wishlist_no_selection
}) })
if ($_GET.wishlist) { if ($_GET.id) {
element.dropdown('set selected', $_GET.wishlist); element.dropdown('set selected', $_GET.id);
} else { } else {
if (response.results[0]) { if (response.results[0]) {
element.dropdown('set selected', response.results[0].value); element.dropdown('set selected', response.results[0].value);

View file

@ -25,9 +25,25 @@ $(function() {
} }
}); });
$('.ui.dropdown').dropdown(); $('.ui.dropdown.channel').dropdown();
$('.ui.dropdown.locale').dropdown({ $('.ui.dropdown.locale').dropdown({
sortSelect : 'natural', sortSelect : 'natural',
}); });
$('.ui.progress').progress(); $('.ui.progress').progress();
var isPWA = navigator.standalone || window.matchMedia('(display-mode: standalone)').matches;
if (isPWA) {
$('.ui.dropdown.channel').dropdown('set selected', 'stable');
$('.ui.dropdown.channel').addClass('disabled');
$('.ui.dropdown.channel').find('select').removeAttr('name');
if ('undefined' !== typeof CHANNELS) {
CHANNELS.forEach(channel => {
if (channel.host === location.host) {
$('.ui.dropdown.channel').dropdown('set selected', channel.branch);
}
});
}
}
}); });

View file

@ -17,8 +17,8 @@ $(function () {
placeholder : text.wishlist_no_selection placeholder : text.wishlist_no_selection
}) })
if ($_GET.wishlist) { if ($_GET.id) {
element.dropdown('set selected', $_GET.wishlist); element.dropdown('set selected', $_GET.id);
} else { } else {
if (wishlists[0]) { if (wishlists[0]) {
element.dropdown('set selected', wishlists[0].value); element.dropdown('set selected', wishlists[0].value);
@ -43,7 +43,7 @@ $(function () {
progress.addClass('indeterminate'); progress.addClass('indeterminate');
if (wishlistValue) { if (wishlistValue) {
$_GET.wishlist = wishlistValue; $_GET.id = wishlistValue;
$('.wishlist-share').attr('href', '/?wishlist=' + wishlists[wishlistIndex].hash); $('.wishlist-share').attr('href', '/?wishlist=' + wishlists[wishlistIndex].hash);
@ -53,9 +53,11 @@ $(function () {
$('.wishlist-delete').removeClass('disabled'); $('.wishlist-delete').removeClass('disabled');
/** Update URL */ /** Update URL */
urlParams.set('wishlist', wishlistValue); urlParams.set('id', wishlistValue);
fetch('/src/api/url.php?url=' + btoa(urlParams.toString()), { console.log(wishlistValue);
fetch('/src/api/url.php?url=' + window.btoa(urlParams.toString()), {
method: 'GET' method: 'GET'
}) })
.then(handleFetchError) .then(handleFetchError)
@ -272,7 +274,7 @@ $(function () {
wishlists.dropdown('clear'); wishlists.dropdown('clear');
urlParams.delete('wishlist'); urlParams.delete('id');
$('body').toast({ message:text.toast_wishlist_delete }); $('body').toast({ message:text.toast_wishlist_delete });
@ -424,7 +426,7 @@ $(function () {
.then(function(response) { .then(function(response) {
modalWishlistCreate.modal('hide'); modalWishlistCreate.modal('hide');
urlParams.set('wishlist', response.data.lastInsertId); urlParams.set('id', response.data.lastInsertId);
$('body').toast({ message: text.toast_wish_create }); $('body').toast({ message: text.toast_wish_create });

View file

@ -260,10 +260,14 @@ $page->navigation();
</div> </div>
<?php if (defined('CHANNELS') && is_array(CHANNELS)) { ?> <?php if (defined('CHANNELS') && is_array(CHANNELS)) { ?>
<script type="text/javascript">
var CHANNELS = <?= json_encode(CHANNELS) ?>;
</script>
<div class="field"> <div class="field">
<label><?= __('Channel') ?></label> <label><?= __('Channel') ?></label>
<select class="ui search clearable dropdown" name="user-channel"> <select class="ui search clearable dropdown channel" name="user-channel">
<option value=""><?= __('Select channel') ?></option> <option value=""><?= __('Select channel') ?></option>
<?php foreach (CHANNELS as $channel) { ?> <?php foreach (CHANNELS as $channel) { ?>

View file

@ -35,7 +35,7 @@ if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) {
$page->messages[] = Page::success(__('Wish successfully updated.'), __('Success')); $page->messages[] = Page::success(__('Wish successfully updated.'), __('Success'));
} }
if (!$userIsAuthenticated || !$wish->exists) { if (!$wish->exists) {
$page->errorDocument(404, $wish); $page->errorDocument(404, $wish);
} }
@ -48,11 +48,15 @@ foreach ($wishlists as $wishlist) {
} }
} }
if (!$userIsAuthenticated) {
$page->errorDocument(404, $wish);
}
$page->header(); $page->header();
$page->bodyStart(); $page->bodyStart();
$page->navigation(); $page->navigation();
$referer = '/?page=wishlists&wishlist=' . $wish->wishlist; $referer = '/?page=wishlists&id=' . $wish->wishlist;
?> ?>
<main> <main>