Fix wish not deleting

This commit is contained in:
grandeljay 2022-11-28 12:13:36 +01:00
parent e3a02ca289
commit 9bcf34685b
4 changed files with 21 additions and 17 deletions

View file

@ -294,15 +294,16 @@ switch ($_SERVER['REQUEST_METHOD']) {
break; break;
case 'DELETE': case 'DELETE':
parse_str(file_get_contents('php://input'), $_DELETE); $_DELETE = $this->input;
if (isset($_DELETE['wish_id'])) { if (isset($_DELETE['wish_id'])) {
$database->query( $database->query(
'DELETE FROM `wishes` 'DELETE FROM `wishes`
WHERE `id` = ' . Sanitiser::getNumber($_DELETE['wish_id']) . ';' WHERE `id` = ' . Sanitiser::getNumber($_DELETE['wish_id']) . ';'
); );
}
$response['success'] = true; $response['success'] = true;
}
break; break;
} }

View file

@ -162,7 +162,7 @@ global $options;
'get wishlists by priority' => '/?page=api&module=wishlists&style={style}&wishlist_id={wishlistid}&priority={priority}', 'get wishlists by priority' => '/?page=api&module=wishlists&style={style}&wishlist_id={wishlistid}&priority={priority}',
'delete wishlist' => '/?page=api&module=wishlists', 'delete wishlist' => '/?page=api&module=wishlists',
'update wish status' => '/?page=api&module=wishes', 'update wish status' => '/?page=api&module=wishes',
'delete wish' => '/?page=api&module=wishes', 'delete wish' => '/?page=api&module=wishes&wish_id={wishid}',
); );
?> ?>

View file

@ -527,13 +527,19 @@ $(function () {
* Delete wish * Delete wish
*/ */
buttonDelete.api({ buttonDelete.api({
action : 'delete wish', 'action' : 'delete wish',
method : 'DELETE', 'method' : 'DELETE',
data : { 'beforeSend' : function (settings) {
'wish_id' : card.attr('data-id'), var wish_id = card.attr('data-id');
settings.urlData.wishid = wish_id;
console.log(wish_id);
return settings;
}, },
on : 'now', 'on' : 'now',
onSuccess : function () { 'onSuccess' : function () {
column.fadeOut(800); column.fadeOut(800);
$('body').toast({ message: wishthis.strings.toast.wish.delete }); $('body').toast({ message: wishthis.strings.toast.wish.delete });
@ -541,17 +547,11 @@ $(function () {
modalDefault.modal('hide'); modalDefault.modal('hide');
setTimeout(() => { setTimeout(() => {
$('.ui.dropdown.wishlists').api('query'); $('.ui.dropdown.filter.priority').api('query');
}, 800); }, 800);
}, },
}); });
/**
* Return false is currently not working.
*
* @version 2.8.8
* @see https://github.com/fomantic/Fomantic-UI/issues/2105
*/
return false; return false;
} }
}); });

View file

@ -138,7 +138,10 @@ class Wish
switch ($this->style) { switch ($this->style) {
case 'list': case 'list':
?> ?>
<div class="ui horizontal card"> <div class="ui horizontal card"
data-id="<?= $this->id ?>"
data-cache="<?= $generateCache ?>"
>
<?= $this->getCardImage() ?> <?= $this->getCardImage() ?>
<div class="content"> <div class="content">