Remove fetch from product add modal
This commit is contained in:
parent
d39ebfc9f0
commit
d85e2ac65d
4 changed files with 20 additions and 105 deletions
|
@ -347,97 +347,6 @@ $(function () {
|
|||
.modal('show');
|
||||
});
|
||||
|
||||
/** Fetch */
|
||||
$(document).on('click', '#wishlist-wish-add-url-validate', function () {
|
||||
var buttonValidate = $(this);
|
||||
var inputWishURL = buttonValidate.prev();
|
||||
|
||||
var elementModalAdd = $('.ui.modal.wishlist-wish-add');
|
||||
var elementButtons = elementModalAdd.find('.actions .button');
|
||||
var elementTitle = elementModalAdd.find('[name="wish_title"]');
|
||||
var elementDescription = elementModalAdd.find('[name="wish_description"]');
|
||||
|
||||
buttonValidate.addClass('disabled loading');
|
||||
elementButtons.addClass('disabled');
|
||||
|
||||
fetch('/src/api/wishes.php?wish_url=' + inputWishURL.val(), {
|
||||
method: 'GET'
|
||||
})
|
||||
.then(handleFetchError)
|
||||
.then(handleFetchResponse)
|
||||
.then(function(response) {
|
||||
var info = response.info;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*/
|
||||
if (info.title && elementTitle.length) {
|
||||
elementTitle.val(info.title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
if (info.description && elementDescription.length) {
|
||||
elementDescription.val(info.description);
|
||||
}
|
||||
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
if (info.url && info.url !== inputWishURL.val()) {
|
||||
var elementModalFetch = $('.ui.modal.wishlist-wish-fetch');
|
||||
|
||||
elementModalFetch.find('input.current').val(inputWishURL.val());
|
||||
elementModalFetch.find('input.proposed').val(info.url);
|
||||
|
||||
elementButtons.addClass('disabled');
|
||||
|
||||
elementModalFetch
|
||||
.modal({
|
||||
allowMultiple: true,
|
||||
closable: false,
|
||||
onApprove: function (buttonFetch) {
|
||||
var formData = new URLSearchParams();
|
||||
formData.append('wish_url_current', inputWishURL.val());
|
||||
formData.append('wish_url_proposed', info.url);
|
||||
|
||||
buttonFetch.addClass('loading');
|
||||
|
||||
fetch('/src/api/wishes.php', {
|
||||
method: 'PUT',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.success) {
|
||||
inputWishURL.val(info.url);
|
||||
|
||||
elementModalFetch.modal('hide');
|
||||
}
|
||||
|
||||
buttonFetch.removeClass('loading');
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
onHide: function() {
|
||||
buttonValidate.removeClass('disabled loading');
|
||||
elementButtons.removeClass('disabled');
|
||||
}
|
||||
})
|
||||
.modal('show');
|
||||
} else {
|
||||
buttonValidate.removeClass('disabled loading');
|
||||
elementButtons.removeClass('disabled');
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Create wishlist
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue