Add wish type
This commit is contained in:
parent
8e3d06b084
commit
14ee9d09fd
3 changed files with 21 additions and 7 deletions
|
@ -24,9 +24,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
$database->query('INSERT INTO `wishes`
|
$database->query('INSERT INTO `wishes`
|
||||||
(
|
(
|
||||||
`wishlist`,
|
`wishlist`,
|
||||||
|
`type`,
|
||||||
`url`
|
`url`
|
||||||
) VALUES ('
|
) VALUES ('
|
||||||
. $_POST['wishlist_id'] . ',
|
. $_POST['wishlist_id'] . ',
|
||||||
|
"' . $_POST['wish_type'] . '",
|
||||||
"' . $_POST['wish_url'] . '"
|
"' . $_POST['wish_url'] . '"
|
||||||
)
|
)
|
||||||
;');
|
;');
|
||||||
|
|
|
@ -376,6 +376,8 @@ $(function () {
|
||||||
/**
|
/**
|
||||||
* Add wish
|
* Add wish
|
||||||
*/
|
*/
|
||||||
|
$('.ui.dropdown.types').dropdown();
|
||||||
|
|
||||||
$(document).on('click', '.button.wishlist-wish-add', function () {
|
$(document).on('click', '.button.wishlist-wish-add', function () {
|
||||||
var modalWishlistWishAdd = $('.ui.modal.wishlist-wish-add');
|
var modalWishlistWishAdd = $('.ui.modal.wishlist-wish-add');
|
||||||
|
|
||||||
|
@ -388,16 +390,15 @@ $(function () {
|
||||||
button.addClass('loading');
|
button.addClass('loading');
|
||||||
|
|
||||||
var form = $('.ui.form.wishlist-wish-fetch');
|
var form = $('.ui.form.wishlist-wish-fetch');
|
||||||
var formData = new URLSearchParams();
|
var formData = new URLSearchParams(new FormData(form[0]));
|
||||||
formData.append('wishlist_id', form.find('input[name="wishlist_id"]').val());
|
|
||||||
formData.append('wish_url', form.find('input[name="wish_url"]').val());
|
|
||||||
|
|
||||||
fetch('/src/api/wishes.php', {
|
fetch('/src/api/wishes.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(handleFetchError)
|
||||||
.then(response => {
|
.then(handleFetchResponse)
|
||||||
|
.then(function(response) {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
$('body').toast({
|
$('body').toast({
|
||||||
class: 'success',
|
class: 'success',
|
||||||
|
@ -411,6 +412,9 @@ $(function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
button.removeClass('loading');
|
button.removeClass('loading');
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -138,6 +138,14 @@ $page->navigation();
|
||||||
<form class="ui form wishlist-wish-fetch" method="post">
|
<form class="ui form wishlist-wish-fetch" method="post">
|
||||||
<input type="hidden" name="wishlist_id" />
|
<input type="hidden" name="wishlist_id" />
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<label>Type</label>
|
||||||
|
<select class="ui fluid selection dropdown types" name="wish_type">
|
||||||
|
<option value="product">Product</option>
|
||||||
|
<option value="custom" disabled>Custom</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>URL</label>
|
<label>URL</label>
|
||||||
<input type="url" name="wish_url" />
|
<input type="url" name="wish_url" />
|
||||||
|
|
Loading…
Reference in a new issue