Improve modal behaviour

This commit is contained in:
Jay Trees 2022-02-24 13:59:07 +01:00
parent b1581d907c
commit 9a406ff382
2 changed files with 35 additions and 32 deletions

View file

@ -331,10 +331,7 @@ $(function () {
});
return false;
},
onDeny: function (element) {
return false;
},
}
})
.modal('show');
});
@ -377,41 +374,47 @@ $(function () {
elementModalFetch.find('input.current').val(href);
elementModalFetch.find('input.proposed').val(info.url);
elementButtons.addClass('disabled');
elementModalFetch
.modal({
allowMultiple: true,
closable: false,
onApprove: function (button) {
var formData = new URLSearchParams();
formData.append('product_url_current', href);
formData.append('product_url_proposed', info.url);
.modal({
allowMultiple: true,
closable: false,
onApprove: function (buttonFetch) {
var formData = new URLSearchParams();
formData.append('product_url_current', href);
formData.append('product_url_proposed', info.url);
button.addClass('loading');
buttonFetch.addClass('loading');
fetch('/src/api/products.php', {
method: 'PUT',
body: formData
})
.then(response => response.json())
.then(response => {
if (response.success) {
form.find('input[type="url"]').val(info.url);
fetch('/src/api/products.php', {
method: 'PUT',
body: formData
})
.then(response => response.json())
.then(response => {
if (response.success) {
form.find('input[type="url"]').val(info.url);
elementModalFetch.modal('hide');
}
elementModalFetch.modal('hide');
}
button.removeClass('loading');
});
buttonFetch.removeClass('loading');
});
return false;
}
})
.modal('show');
return false;
},
onHide: function() {
form.removeClass('loading');
elementButtons.removeClass('disabled');
}
})
.modal('show');
} else {
form.removeClass('loading');
elementButtons.removeClass('disabled');
}
}
form.removeClass('loading');
elementButtons.removeClass('disabled');
});
});

View file

@ -143,7 +143,7 @@ if (isset($_POST['wishlist_delete_id'])) {
</div>
</div>
<div class="actions">
<div class="ui primary approve button">
<div class="ui primary approve button disabled">
Add
</div>
<div class="ui deny button">