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() {
|
||||
|
@ -206,27 +169,9 @@ $(function() {
|
|||
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) {
|
||||
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) {
|
||||
|
@ -88,26 +84,19 @@ $(function() {
|
|||
wishlistID: wishlistValue
|
||||
},
|
||||
on: 'now',
|
||||
onResponse: function(response) {
|
||||
return response;
|
||||
},
|
||||
successTest: function(response) {
|
||||
return response.success || false;
|
||||
},
|
||||
onComplete: function(response, element, xhr) {
|
||||
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,9 +33,31 @@ class EmbedCache
|
|||
* @link https://github.com/oscarotero/Embed
|
||||
*/
|
||||
$embed = new \Embed\Embed();
|
||||
$info = $embed->get($url);
|
||||
|
||||
$info_simplified = new \stdClass();
|
||||
$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;
|
||||
|
@ -55,6 +77,10 @@ class EmbedCache
|
|||
$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;
|
||||
|
||||
|
|
|
@ -190,7 +190,8 @@ class Page
|
|||
<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">
|
||||
|
||||
<div class="eight wide column">
|
||||
<h4 class="ui inverted header">wishthis</h4>
|
||||
|
||||
<div class="ui inverted link list">
|
||||
|
@ -207,6 +208,16 @@ class Page
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
|
Loading…
Reference in a new issue