diff --git a/src/api/wishes.php b/src/api/wishes.php
index d4b5c4d7..9f529b75 100644
--- a/src/api/wishes.php
+++ b/src/api/wishes.php
@@ -61,11 +61,15 @@ switch ($_SERVER['REQUEST_METHOD']) {
$wish_title = trim($_POST['wish_title']);
$wish_description = trim($_POST['wish_description']);
- $wish_image = 'NULL';
+ $wish_image = trim($_POST['wish_image']);
$wish_url = trim($_POST['wish_url']);
$wish_priority = isset($_POST['wish_priority']) && $_POST['wish_priority'] ? $_POST['wish_priority'] : 'NULL';
$wish_is_purchasable = isset($_POST['wish_is_purchasable']) ? 'true' : 'false';
+ if (Wish::NO_IMAGE === $wish_image) {
+ $wish_image = '';
+ }
+
if (isset($_POST['wish_id'], $_POST['wishlist_id'])) {
/** Update wish */
$wish = new Wish($_POST['wish_id']);
@@ -84,11 +88,13 @@ switch ($_SERVER['REQUEST_METHOD']) {
}
/** Image */
- if (!empty($info->image)) {
- $codeImage = URL::getResponseCode($info->image);
+ if (empty($wish_image) && empty($wish->image)) {
+ if (!empty($info->image)) {
+ $codeImage = URL::getResponseCode($info->image);
- if ($codeImage >= 200 && $codeImage < 400) {
- $wish_image = '"' . $info->image . '"';
+ if ($codeImage >= 200 && $codeImage < 400) {
+ $wish_image = '"' . $info->image . '"';
+ }
}
}
@@ -98,9 +104,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
}
/** Update */
- $wish_title = empty($wish_title) ? 'NULL' : '"' . substr($wish_title, 0, 128) . '"';
- $wish_description = empty($wish_description) ? 'NULL' : '"' . $wish_description . '"';
- $wish_url = empty($wish_url) ? 'NULL' : '"' . $wish_url . '"';
+ $wish_title = empty($wish_title) ? 'NULL' : '"' . substr($wish_title, 0, 128) . '"';
+ $wish_description = empty($wish_description) ? 'NULL' : '"' . $wish_description . '"';
+ $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? 'NULL' : '"' . $wish_image . '"';
+ $wish_url = empty($wish_url) ? 'NULL' : '"' . $wish_url . '"';
$database
->query(
@@ -153,11 +160,13 @@ switch ($_SERVER['REQUEST_METHOD']) {
}
/** Image */
- if (!empty($info->image)) {
- $codeImage = URL::getResponseCode($info->image);
+ if (empty($wish_image) && empty($wish->image)) {
+ if (!empty($info->image)) {
+ $codeImage = URL::getResponseCode($info->image);
- if ($codeImage >= 200 && $codeImage < 400) {
- $wish_image = '"' . $info->image . '"';
+ if ($codeImage >= 200 && $codeImage < 400) {
+ $wish_image = '"' . $info->image . '"';
+ }
}
}
@@ -167,9 +176,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
}
/** Update */
- $wish_title = empty($wish_title) ? 'NULL' : '"' . substr($wish_title, 0, 128) . '"';
- $wish_description = empty($wish_description) ? 'NULL' : '"' . $wish_description . '"';
- $wish_url = empty($wish_url) ? 'NULL' : '"' . $wish_url . '"';
+ $wish_title = empty($wish_title) ? 'NULL' : '"' . substr($wish_title, 0, 128) . '"';
+ $wish_description = empty($wish_description) ? 'NULL' : '"' . $wish_description . '"';
+ $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? 'NULL' : '"' . $wish_image . '"';
+ $wish_url = empty($wish_url) ? 'NULL' : '"' . $wish_url . '"';
$database
->query(
diff --git a/src/assets/css/default.css b/src/assets/css/default.css
index 98e6ab46..23ccda28 100644
--- a/src/assets/css/default.css
+++ b/src/assets/css/default.css
@@ -70,16 +70,13 @@ figure {
}
/** Image */
-svg,
-.wishlist .ui.card > .image > svg {
- color: #f0f0f0;
- background-color: #f4f4f4;
-}
-
.wishlist .ui.card > .image > svg {
width: 100%;
height: var(--wishPreviewHeight);
+ color: #f0f0f0;
+ background-color: #f4f4f4;
+
box-sizing: border-box;
border-radius: inherit;
}
diff --git a/src/assets/js/wishlists.js b/src/assets/js/wishlists.js
index 9a7a0685..3db781ad 100644
--- a/src/assets/js/wishlists.js
+++ b/src/assets/js/wishlists.js
@@ -9,13 +9,11 @@ $(function () {
var wishlists = [];
function wishlistsRefresh() {
- var selectedValue = $('.ui.dropdown.wishlists').dropdown('get value');
-
$('.ui.dropdown.wishlists').api({
- action : 'get wishlists',
- method : 'GET',
- on : 'now',
- onSuccess: function (response, element, xhr) {
+ action : 'get wishlists',
+ method : 'GET',
+ on : 'now',
+ onSuccess : function (response, element, xhr) {
wishlists = response.results;
element.dropdown({
@@ -24,11 +22,7 @@ $(function () {
})
if (wishlist.id) {
- if (wishlist.id === selectedValue) {
- element.dropdown('set selected', wishlist.id, null, true);
- } else {
- element.dropdown('set selected', wishlist.id);
- }
+ element.dropdown('set selected', wishlist.id);
} else {
if (wishlists[0]) {
element.dropdown('set selected', wishlists[0].value);
@@ -396,6 +390,7 @@ $(function () {
$('[name="wish_id"]').val(wish.id);
$('[name="wish_title"]').val(wish.title);
$('[name="wish_description"]').val(wish.description);
+ $('[name="wish_image"]').val(wish.image);
$('[name="wish_url"]').val(wish.url);
$('.ui.selection.dropdown.priority').dropdown('set selected', wish.priority);
@@ -706,11 +701,7 @@ $(function () {
/** */
}
})
- .catch(handleFetchCatch)
- .finally(function() {
- formAddOrEdit.removeClass('loading');
- buttonAddOrSave.removeClass('disabled');
- });
+ .catch(handleFetchCatch);
} else {
/** Save form edit fields */
/** This code block is a duplicate, please refactor */
diff --git a/src/classes/wish.php b/src/classes/wish.php
index e1eec8d5..389d46e5 100644
--- a/src/classes/wish.php
+++ b/src/classes/wish.php
@@ -109,10 +109,6 @@ class Wish
$this->$key = $this->info->$key;
}
}
-
- if (empty($this->image)) {
- $this->image = self::NO_IMAGE;
- }
}
}
@@ -190,6 +186,8 @@ class Wish
+
+ = file_get_contents(ROOT . self::NO_IMAGE) ?>
info->favicon)) { ?>
diff --git a/src/pages/parts/wish-add.php b/src/pages/parts/wish-add.php
index b3a9fc32..b36d24cf 100644
--- a/src/pages/parts/wish-add.php
+++ b/src/pages/parts/wish-add.php
@@ -72,6 +72,17 @@ namespace wishthis;
+