Wish adding wish not working
This commit is contained in:
parent
36d83b456f
commit
fc88075bfc
3 changed files with 41 additions and 66 deletions
|
@ -400,7 +400,7 @@ $(function () {
|
||||||
method : 'PUT',
|
method : 'PUT',
|
||||||
data : {
|
data : {
|
||||||
'wish_id' : card.attr('data-id'),
|
'wish_id' : card.attr('data-id'),
|
||||||
'wish_status' : wishthis.strings.wish.status.fulfilled,
|
'wish_status' : wishthis.strings.modal.wish.status.fulfilled,
|
||||||
},
|
},
|
||||||
on : 'now',
|
on : 'now',
|
||||||
onSuccess : function(response, element, xhr) {
|
onSuccess : function(response, element, xhr) {
|
||||||
|
@ -505,16 +505,16 @@ $(function () {
|
||||||
|
|
||||||
modalDefault
|
modalDefault
|
||||||
.modal({
|
.modal({
|
||||||
title : wishthis.strings.wish.delete.title,
|
title : wishthis.strings.modal.wish.delete.title,
|
||||||
content : wishthis.strings.wish.delete.content,
|
content : wishthis.strings.modal.wish.delete.content,
|
||||||
class : 'tiny',
|
class : 'tiny',
|
||||||
actions : [
|
actions : [
|
||||||
{
|
{
|
||||||
text : wishthis.strings.wish.delete.approve,
|
text : wishthis.strings.modal.wish.delete.approve,
|
||||||
class: 'approve primary'
|
class: 'approve primary'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: wishthis.strings.wish.delete.deny
|
text: wishthis.strings.modal.wish.delete.deny
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
autoShow : true,
|
autoShow : true,
|
||||||
|
@ -752,46 +752,25 @@ $(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
/** Save form edit fields */
|
insertWish(formAddOrEdit, modalAddOrEdit, buttonAddOrSave);
|
||||||
/** This code block is a duplicate, please refactor */
|
|
||||||
var formData = new URLSearchParams(new FormData(formAddOrEdit[0]));
|
|
||||||
formData.append('wishlist_id', wishthis.$_GET.id);
|
|
||||||
|
|
||||||
fetch('/?page=api&module=wishes', {
|
|
||||||
method : 'POST',
|
|
||||||
body : formData
|
|
||||||
})
|
|
||||||
.then(handleFetchError)
|
|
||||||
.then(handleFetchResponse)
|
|
||||||
.then(function(response) {
|
|
||||||
if (!response.lastInsertId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$('body').toast({ message: wishthis.strings.toast.wish.update });
|
|
||||||
|
|
||||||
$('.ui.dropdown.wishlists').api('query');
|
|
||||||
|
|
||||||
modalAddOrEdit.modal('hide');
|
|
||||||
})
|
|
||||||
.catch(handleFetchCatch)
|
|
||||||
.finally(function() {
|
|
||||||
formAddOrEdit.removeClass('loading');
|
|
||||||
buttonAddOrSave.removeClass('disabled');
|
|
||||||
});
|
|
||||||
/** */
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(handleFetchCatch);
|
.catch(handleFetchCatch);
|
||||||
} else {
|
} else {
|
||||||
/** Save form edit fields */
|
insertWish(formAddOrEdit, modalAddOrEdit, buttonAddOrSave);
|
||||||
/** This code block is a duplicate, please refactor */
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert wish
|
||||||
|
*/
|
||||||
|
function insertWish(formAddOrEdit, modalAddOrEdit, buttonAddOrSave) {
|
||||||
var formData = new URLSearchParams(new FormData(formAddOrEdit[0]));
|
var formData = new URLSearchParams(new FormData(formAddOrEdit[0]));
|
||||||
formData.append('wishlist_id', wishthis.$_GET.id);
|
formData.append('wishlist_id', wishthis.$_GET.id);
|
||||||
|
|
||||||
fetch('/?page=api&module=wishes', {
|
fetch('/api/wishes', {
|
||||||
method : 'POST',
|
'method' : 'POST',
|
||||||
body : formData
|
'body' : formData,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -811,8 +790,6 @@ $(function () {
|
||||||
formAddOrEdit.removeClass('loading');
|
formAddOrEdit.removeClass('loading');
|
||||||
buttonAddOrSave.removeClass('disabled');
|
buttonAddOrSave.removeClass('disabled');
|
||||||
});
|
});
|
||||||
/** */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -139,9 +139,7 @@ class Page
|
||||||
* Install
|
* Install
|
||||||
*/
|
*/
|
||||||
if (!isset($options) || !$options || !$options->getOption('isInstalled')) {
|
if (!isset($options) || !$options || !$options->getOption('isInstalled')) {
|
||||||
global $page;
|
if ('api' !== $this->name) {
|
||||||
|
|
||||||
if ('api' !== $page) {
|
|
||||||
redirect(Page::PAGE_INSTALL);
|
redirect(Page::PAGE_INSTALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +188,7 @@ class Page
|
||||||
/**
|
/**
|
||||||
* Redirect
|
* Redirect
|
||||||
*/
|
*/
|
||||||
if ($options && $options->getOption('isInstalled') && isset($_GET)) {
|
if ($options && $options->getOption('isInstalled') && isset($_GET) && 'api' !== $this->name) {
|
||||||
$url = new URL($_SERVER['REQUEST_URI']);
|
$url = new URL($_SERVER['REQUEST_URI']);
|
||||||
|
|
||||||
if ($url->url && false === $url->isPretty()) {
|
if ($url->url && false === $url->isPretty()) {
|
||||||
|
|
Loading…
Reference in a new issue