Fix delete not working
This commit is contained in:
parent
aa551dfe12
commit
909859ad01
4 changed files with 96 additions and 127 deletions
|
@ -1,3 +1,5 @@
|
|||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
$(function() {
|
||||
/**
|
||||
* Fomantic UI
|
||||
|
@ -25,8 +27,6 @@ $(function() {
|
|||
placeholder: 'No wishlist selected.'
|
||||
})
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
if (urlParams.has('wishlist')) {
|
||||
element.dropdown('set selected', urlParams.get('wishlist'));
|
||||
} else {
|
||||
|
@ -81,25 +81,7 @@ $(function() {
|
|||
})
|
||||
.modal('show');
|
||||
}
|
||||
$.fn.api.settings.onAbort = function(response, element, xhr) {
|
||||
console.log(response);
|
||||
console.log(element);
|
||||
console.log(xhr);
|
||||
|
||||
$('body')
|
||||
.modal({
|
||||
title: 'Interrupted',
|
||||
content: 'The process was interrupted.',
|
||||
class: '',
|
||||
actions: [
|
||||
{
|
||||
text: 'Thanks for nothing',
|
||||
class: 'primary'
|
||||
}
|
||||
]
|
||||
})
|
||||
.modal('show');
|
||||
}
|
||||
/** */
|
||||
|
||||
$('.ui.dropdown.wishlists').dropdown({
|
||||
filterRemoteData: true
|
||||
|
@ -113,7 +95,7 @@ $(function() {
|
|||
/**
|
||||
* Commit to Product
|
||||
*/
|
||||
$('.ui.button.commit').on('click', function() {
|
||||
$(document).on('click', '.ui.button.commit', function() {
|
||||
var button = $(this);
|
||||
var card = button.closest('.ui.card');
|
||||
var column = card.closest('.column');
|
||||
|
@ -145,27 +127,9 @@ $(function() {
|
|||
productStatus: 'unavailable'
|
||||
},
|
||||
on: 'now',
|
||||
onResponse: function(response) {
|
||||
return response;
|
||||
},
|
||||
successTest: function(response) {
|
||||
return response.success || false;
|
||||
},
|
||||
onComplete: function(response, element, xhr) {
|
||||
|
||||
},
|
||||
onSuccess: function(response, element, xhr) {
|
||||
column.fadeOut();
|
||||
},
|
||||
onFailure: function(response, element, xhr) {
|
||||
|
||||
},
|
||||
onError: function(errorMessage, element, xhr) {
|
||||
|
||||
},
|
||||
onAbort: function(errorMessage, element, xhr) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -175,7 +139,7 @@ $(function() {
|
|||
/**
|
||||
* Delete Product
|
||||
*/
|
||||
$('.ui.button.delete').on('click', function() {
|
||||
$(document).on('click', '.ui.button.delete', function() {
|
||||
var button = $(this);
|
||||
var card = button.closest('.ui.card');
|
||||
var column = card.closest('.column');
|
||||
|
@ -191,8 +155,7 @@ $(function() {
|
|||
class: 'approve primary'
|
||||
},
|
||||
{
|
||||
text: 'Cancel',
|
||||
class: ''
|
||||
text: 'Cancel'
|
||||
}
|
||||
],
|
||||
onApprove: function() {
|
||||
|
@ -200,33 +163,15 @@ $(function() {
|
|||
* Delete product
|
||||
*/
|
||||
button.api({
|
||||
action: 'delete product',
|
||||
method: 'DELETE',
|
||||
data: {
|
||||
action: 'delete product',
|
||||
method: 'DELETE',
|
||||
data: {
|
||||
productID: card.data('id'),
|
||||
},
|
||||
on: 'now',
|
||||
onResponse: function(response) {
|
||||
return response;
|
||||
},
|
||||
successTest: function(response) {
|
||||
return response.success || false;
|
||||
},
|
||||
onComplete: function(response, element, xhr) {
|
||||
|
||||
},
|
||||
onSuccess: function(response, element, xhr) {
|
||||
on: 'now',
|
||||
onSuccess: function() {
|
||||
column.fadeOut();
|
||||
},
|
||||
onFailure: function(response, element, xhr) {
|
||||
|
||||
},
|
||||
onError: function(errorMessage, element, xhr) {
|
||||
|
||||
},
|
||||
onAbort: function(errorMessage, element, xhr) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -238,8 +183,6 @@ function wishlistRefresh() {
|
|||
/**
|
||||
* URL Parameter
|
||||
*/
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
$('.ui.dropdown.wishlists').api({
|
||||
action: 'get wishlists',
|
||||
method: 'GET',
|
||||
|
|
|
@ -10,15 +10,12 @@ $(function() {
|
|||
on: 'now',
|
||||
onSuccess: function(response, element, xhr) {
|
||||
wishlists = response.results;
|
||||
console.log(wishlists);
|
||||
|
||||
element.dropdown({
|
||||
values: wishlists,
|
||||
placeholder: 'No wishlist selected.'
|
||||
})
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
if (urlParams.has('wishlist')) {
|
||||
element.dropdown('set selected', urlParams.get('wishlist'));
|
||||
} else {
|
||||
|
@ -32,14 +29,13 @@ $(function() {
|
|||
/**
|
||||
* Selection
|
||||
*/
|
||||
$('.ui.dropdown.wishlists').on('change', function() {
|
||||
$(document).on('change', '.ui.dropdown.wishlists', function() {
|
||||
var wishlistValue = $('.ui.dropdown.wishlists').dropdown('get value');
|
||||
var wishlistIndex = $('.ui.dropdown.wishlists select').prop('selectedIndex') - 1;
|
||||
|
||||
$('[name="wishlist_delete_id"]').val(wishlistValue);
|
||||
|
||||
if (wishlistValue) {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
urlParams.set('wishlist', wishlistValue);
|
||||
window.history.pushState({}, '', '/?' + urlParams.toString());
|
||||
|
||||
|
@ -61,7 +57,7 @@ $(function() {
|
|||
/**
|
||||
* Delete Wishlist
|
||||
*/
|
||||
$('.wishlist-delete').on('submit', function(event) {
|
||||
$(document).on('submit', '.wishlist-delete', function(event) {
|
||||
var wishlistValue = $('.ui.dropdown.wishlists').dropdown('get value');
|
||||
|
||||
if (wishlistValue) {
|
||||
|
@ -84,30 +80,23 @@ $(function() {
|
|||
$('.ui.dropdown.wishlists').api({
|
||||
action: 'delete wishlist',
|
||||
method: 'DELETE',
|
||||
data: {
|
||||
data: {
|
||||
wishlistID: wishlistValue
|
||||
},
|
||||
on: 'now',
|
||||
onResponse: function(response) {
|
||||
return response;
|
||||
},
|
||||
successTest: function(response) {
|
||||
return response.success || false;
|
||||
},
|
||||
onComplete: function(response, element, xhr) {
|
||||
on: 'now',
|
||||
onSuccess: function(response, wishlists) {
|
||||
$('.wishlist-cards .column').fadeOut();
|
||||
|
||||
},
|
||||
onSuccess: function(response, element, xhr) {
|
||||
wishlistRefresh();
|
||||
},
|
||||
onFailure: function(response, element, xhr) {
|
||||
wishlists.dropdown('clear');
|
||||
|
||||
},
|
||||
onError: function(errorMessage, element, xhr) {
|
||||
|
||||
},
|
||||
onAbort: function(errorMessage, element, xhr) {
|
||||
urlParams.delete('wishlist');
|
||||
window.history.pushState({}, '', '/?' + urlParams.toString());
|
||||
|
||||
$('.ui.dropdown.wishlists').api({
|
||||
action: 'get wishlists',
|
||||
method: 'GET',
|
||||
on: 'now'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ class EmbedCache
|
|||
$info = null;
|
||||
$identifier = md5($url);
|
||||
$filepath = $this->directory . '/' . $identifier;
|
||||
$age = time() - filemtime($filepath);
|
||||
$maxAge = 2592000; // 30 days
|
||||
$age = file_exists($filepath) ? time() - filemtime($filepath) : $maxAge;
|
||||
|
||||
if (file_exists($filepath) && $age <= $maxAge) {
|
||||
$info = json_decode(file_get_contents($filepath));
|
||||
|
@ -33,28 +33,54 @@ class EmbedCache
|
|||
* @link https://github.com/oscarotero/Embed
|
||||
*/
|
||||
$embed = new \Embed\Embed();
|
||||
$info = $embed->get($url);
|
||||
|
||||
$info_simplified = new \stdClass();
|
||||
$info_simplified->authorName = (string) $info->authorName;
|
||||
$info_simplified->authorUrl = (string) $info->authorUrl;
|
||||
$info_simplified->cms = (string) $info->cms;
|
||||
$info_simplified->code = (string) $info->code;
|
||||
$info_simplified->description = (string) $info->description;
|
||||
$info_simplified->favicon = (string) $info->favicon;
|
||||
$info_simplified->feeds = (array) $info->feeds;
|
||||
$info_simplified->icon = (string) $info->icon;
|
||||
$info_simplified->image = (string) $info->image;
|
||||
$info_simplified->keywords = (array) $info->keywords;
|
||||
$info_simplified->language = (string) $info->language;
|
||||
$info_simplified->languages = (array) $info->languages;
|
||||
$info_simplified->license = (string) $info->license;
|
||||
$info_simplified->providerName = (string) $info->providerName;
|
||||
$info_simplified->providerUrl = (string) $info->providerUrl;
|
||||
$info_simplified->publishedTime = $info->publishedTime ? $info->publishedTime->format('d.m.Y') : '';
|
||||
$info_simplified->redirect = (string) $info->redirect;
|
||||
$info_simplified->title = (string) $info->title;
|
||||
$info_simplified->url = (string) $info->url;
|
||||
$info_simplified->authorName = '';
|
||||
$info_simplified->authorUrl = '';
|
||||
$info_simplified->cms = '';
|
||||
$info_simplified->code = '';
|
||||
$info_simplified->description = '';
|
||||
$info_simplified->favicon = '';
|
||||
$info_simplified->feeds = array();
|
||||
$info_simplified->icon = '';
|
||||
$info_simplified->image = '';
|
||||
$info_simplified->keywords = array();
|
||||
$info_simplified->language = '';
|
||||
$info_simplified->languages = array();
|
||||
$info_simplified->license = '';
|
||||
$info_simplified->providerName = '';
|
||||
$info_simplified->providerUrl = '';
|
||||
$info_simplified->publishedTime = '';
|
||||
$info_simplified->redirect = '';
|
||||
$info_simplified->title = '';
|
||||
$info_simplified->url = '';
|
||||
|
||||
try {
|
||||
$info = $embed->get($url);
|
||||
|
||||
$info_simplified->authorName = (string) $info->authorName;
|
||||
$info_simplified->authorUrl = (string) $info->authorUrl;
|
||||
$info_simplified->cms = (string) $info->cms;
|
||||
$info_simplified->code = (string) $info->code;
|
||||
$info_simplified->description = (string) $info->description;
|
||||
$info_simplified->favicon = (string) $info->favicon;
|
||||
$info_simplified->feeds = (array) $info->feeds;
|
||||
$info_simplified->icon = (string) $info->icon;
|
||||
$info_simplified->image = (string) $info->image;
|
||||
$info_simplified->keywords = (array) $info->keywords;
|
||||
$info_simplified->language = (string) $info->language;
|
||||
$info_simplified->languages = (array) $info->languages;
|
||||
$info_simplified->license = (string) $info->license;
|
||||
$info_simplified->providerName = (string) $info->providerName;
|
||||
$info_simplified->providerUrl = (string) $info->providerUrl;
|
||||
$info_simplified->publishedTime = $info->publishedTime ? $info->publishedTime->format('d.m.Y') : '';
|
||||
$info_simplified->redirect = (string) $info->redirect;
|
||||
$info_simplified->title = (string) $info->title;
|
||||
$info_simplified->url = (string) $info->url;
|
||||
} catch (\Throwable $ex) {
|
||||
$info_simplified->title = (string) $ex->getMessage();
|
||||
$info_simplified->url = (string) $url;
|
||||
}
|
||||
|
||||
$info = $info_simplified;
|
||||
|
||||
|
|
|
@ -189,26 +189,37 @@ class Page
|
|||
<div class="ui hidden divider"></div>
|
||||
<div class="ui inverted vertical footer segment">
|
||||
<div class="ui container">
|
||||
<div class="ui stackable inverted divided equal height stackable grid">
|
||||
<div class="sixteen wide column">
|
||||
<h4 class="ui inverted header">wishthis</h4>
|
||||
<div class="ui stackable inverted divided equal height stackable grid">
|
||||
|
||||
<div class="ui inverted link list">
|
||||
<?php
|
||||
global $options;
|
||||
<div class="eight wide column">
|
||||
<h4 class="ui inverted header">wishthis</h4>
|
||||
|
||||
echo 'v' . $options->version;
|
||||
?>
|
||||
<div class="ui inverted link list">
|
||||
<?php
|
||||
global $options;
|
||||
|
||||
echo 'v' . $options->version;
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="ui inverted link list">
|
||||
<a class="item" href="https://github.com/grandeljay/wishthis" target="_blank">
|
||||
<i class="big github icon"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui inverted link list">
|
||||
<a class="item" href="https://github.com/grandeljay/wishthis" target="_blank">
|
||||
<i class="big github icon"></i>
|
||||
</a>
|
||||
<div class="eight wide column">
|
||||
<h4 class="ui inverted header">Preferences</h4>
|
||||
|
||||
<div class="ui inverted link list">
|
||||
<div class="dnt">Do Not Track</div>
|
||||
<div class="prefers-color-scheme">Prefers color scheme</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue