Remove fetch from product add modal
This commit is contained in:
parent
d39ebfc9f0
commit
d85e2ac65d
4 changed files with 20 additions and 105 deletions
|
@ -26,6 +26,15 @@ $(function () {
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
var info = response.info;
|
var info = response.info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prodiver name
|
||||||
|
*/
|
||||||
|
if (info.providerName) {
|
||||||
|
modalValidate.find('.providerName').text(info.providerName);
|
||||||
|
} else {
|
||||||
|
modalValidate.find('.provider').remove();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title
|
* Title
|
||||||
*/
|
*/
|
||||||
|
@ -46,9 +55,6 @@ $(function () {
|
||||||
if (info.url && info.url !== inputURL.val()) {
|
if (info.url && info.url !== inputURL.val()) {
|
||||||
var elementModalFetch = $('.modal.validate');
|
var elementModalFetch = $('.modal.validate');
|
||||||
|
|
||||||
modalValidate.find('.primary.button').popup();
|
|
||||||
console.log(modalValidate.find('.primary.button'));
|
|
||||||
|
|
||||||
elementModalFetch.find('input.current').val(inputURL.val());
|
elementModalFetch.find('input.current').val(inputURL.val());
|
||||||
elementModalFetch.find('input.proposed').val(info.url);
|
elementModalFetch.find('input.proposed').val(info.url);
|
||||||
|
|
||||||
|
@ -91,6 +97,13 @@ $(function () {
|
||||||
})
|
})
|
||||||
.modal('show');
|
.modal('show');
|
||||||
} else {
|
} else {
|
||||||
|
$('body').toast({
|
||||||
|
class: 'success',
|
||||||
|
showIcon: 'check',
|
||||||
|
title: 'Success',
|
||||||
|
message: 'Wish information updated.'
|
||||||
|
});
|
||||||
|
|
||||||
formWish.removeClass('loading');
|
formWish.removeClass('loading');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -347,97 +347,6 @@ $(function () {
|
||||||
.modal('show');
|
.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
|
* Create wishlist
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -147,12 +147,12 @@ $referer = '/?page=wishlists&wishlist=' . $wish->wishlist;
|
||||||
<!-- Validate -->
|
<!-- Validate -->
|
||||||
<div class="ui small modal validate">
|
<div class="ui small modal validate">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
Incorrect URL
|
URL mismatch
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<div class="ui header">Wish URLs</div>
|
|
||||||
<p>The URL you have entered does not seem quite right. Would you like to update it with the one I found?</p>
|
<p>The URL you have entered does not seem quite right. Would you like to update it with the one I found?</p>
|
||||||
|
<p class="provider">According to <strong class="providerName">Unknown</strong>, this is the canonical (correct) URL.</p>
|
||||||
|
|
||||||
<div class="ui form urls">
|
<div class="ui form urls">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -168,7 +168,7 @@ $referer = '/?page=wishlists&wishlist=' . $wish->wishlist;
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<div class="ui primary approve button" data-title="Recommended action" data-content="If you don't have a specific reason to not, click this." >
|
<div class="ui primary approve button">
|
||||||
Yes, update
|
Yes, update
|
||||||
</div>
|
</div>
|
||||||
<div class="ui deny button">
|
<div class="ui deny button">
|
||||||
|
|
|
@ -148,15 +148,8 @@ $page->navigation();
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>URL</label>
|
<label>URL</label>
|
||||||
|
|
||||||
<div class="ui action input url">
|
<div class="ui input url">
|
||||||
<input type="url" name="wish_url" maxlength="255" />
|
<input type="url" name="wish_url" maxlength="255" />
|
||||||
|
|
||||||
<button class="ui button"
|
|
||||||
id="wishlist-wish-add-url-validate"
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
Validate
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue