Confirm fulfilled wish
This commit is contained in:
parent
3a83e4c958
commit
e6da9e239c
8 changed files with 85 additions and 38 deletions
|
@ -90,9 +90,15 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
/**
|
||||
* Update Wish Status
|
||||
*/
|
||||
$status = $_PUT['wish_status'];
|
||||
|
||||
if (Wish::STATUS_TEMPORARY === $status) {
|
||||
$status = time();
|
||||
}
|
||||
|
||||
$database->query('UPDATE `wishes`
|
||||
SET `status` = "' . $_PUT['wish_status'] . '"
|
||||
WHERE `id` = ' . $_PUT['wish_id'] . '
|
||||
SET `status` = "' . $status . '"
|
||||
WHERE `id` = ' . $_PUT['wish_id'] . '
|
||||
;');
|
||||
|
||||
$response['success'] = true;
|
||||
|
|
|
@ -60,7 +60,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
}
|
||||
|
||||
$options = array(
|
||||
'WHERE' => implode(' AND ', $where),
|
||||
'WHERE' => '(' . implode(') AND (', $where) . ')',
|
||||
);
|
||||
|
||||
$response['results'] = $wishlist->getCards($options);
|
||||
|
|
|
@ -49,26 +49,6 @@ img {
|
|||
.ui.card:hover {
|
||||
z-index: 102;
|
||||
}
|
||||
|
||||
.ui.card .overlay {
|
||||
transition: 0.4s ease opacity;
|
||||
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
|
||||
z-index: 1;
|
||||
opacity: 0;
|
||||
border-radius: 0.33333333rem;
|
||||
|
||||
background-color: rgba(255, 255, 255, 0.6);
|
||||
background-image: linear-gradient(180deg, #fff, transparent 6em);
|
||||
}
|
||||
.ui.card:hover .overlay {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** Image */
|
||||
|
|
|
@ -49,19 +49,25 @@ $(function() {
|
|||
}
|
||||
}
|
||||
$.fn.api.settings.onFailure = function(response, element, xhr) {
|
||||
var content = '';
|
||||
|
||||
if ('string' === typeof response) {
|
||||
response = response.replace('<br />', '');
|
||||
content = response.replace('<br />', '');
|
||||
}
|
||||
|
||||
if ('' === response.warning) {
|
||||
content = text.modal_failure_content;
|
||||
}
|
||||
|
||||
$('body')
|
||||
.modal({
|
||||
title : text.modal_failure_title,
|
||||
content : response,
|
||||
content : content,
|
||||
class : '',
|
||||
actions : [
|
||||
{
|
||||
text : text.modal_failure_approve,
|
||||
class: 'primary'
|
||||
text : text.modal_failure_approve,
|
||||
class : 'primary'
|
||||
}
|
||||
],
|
||||
autoShow: true
|
||||
|
@ -185,6 +191,9 @@ $(function() {
|
|||
weekNo : text.calendar_week_no,
|
||||
};
|
||||
|
||||
/** Dimmer */
|
||||
$.fn.dimmer.settings.closable = false;
|
||||
|
||||
/**
|
||||
* Menu
|
||||
*/
|
||||
|
|
|
@ -65,14 +65,34 @@ $(function() {
|
|||
method : 'PUT',
|
||||
data : {
|
||||
wish_id : card.attr('data-id'),
|
||||
wish_status : 'unavailable'
|
||||
wish_status : wish_status_temporary,
|
||||
},
|
||||
on : 'now',
|
||||
onSuccess : function(response, element, xhr) {
|
||||
column.fadeOut();
|
||||
card.dimmer('show');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/** Confirm */
|
||||
$(document).on('click', '.card .button.confirm', function() {
|
||||
var button = $(this);
|
||||
var card = button.closest('.card');
|
||||
|
||||
button.api({
|
||||
action : 'update wish status',
|
||||
method : 'PUT',
|
||||
data : {
|
||||
wish_id : card.attr('data-id'),
|
||||
wish_status : wish_status_unavailable,
|
||||
},
|
||||
on : 'now',
|
||||
onSuccess : function(response, element, xhr) {
|
||||
card.fadeOut();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace wishthis;
|
||||
|
||||
use wishthis\{User, URL};
|
||||
use wishthis\{User, URL, Wish};
|
||||
|
||||
enum Navigation: int
|
||||
{
|
||||
|
@ -306,13 +306,16 @@ class Page
|
|||
*/
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var locale = '<?= str_replace('_', '-', $this->language) ?>';
|
||||
var $_GET = JSON.parse('<?= isset($_SESSION['_GET']) ? json_encode($_SESSION['_GET']) : array() ?>');
|
||||
var text = {
|
||||
var locale = '<?= str_replace('_', '-', $this->language) ?>';
|
||||
var $_GET = JSON.parse('<?= isset($_SESSION['_GET']) ? json_encode($_SESSION['_GET']) : array() ?>');
|
||||
var wish_status_temporary = '<?= Wish::STATUS_TEMPORARY ?>';
|
||||
var wish_status_unavailable = '<?= Wish::STATUS_UNAVAILABLE ?>';
|
||||
var text = {
|
||||
wishlist_no_selection : '<?= __('No wishlist selected.') ?>',
|
||||
|
||||
modal_error_title : '<?= __('Error') ?>',
|
||||
modal_failure_title : '<?= __('Failure') ?>',
|
||||
modal_failure_content : '<?= __('The server did not confirm that the action was successful.') ?>',
|
||||
modal_failure_approve : '<?= __('Thanks for nothing') ?>',
|
||||
modal_warning_approve : '<?= __('Understood') ?>',
|
||||
modal_success_title : '<?= __('Success') ?>',
|
||||
|
|
|
@ -13,6 +13,10 @@ class Wish
|
|||
/**
|
||||
* Static
|
||||
*/
|
||||
public const STATUS_TEMPORARY = 'temporary';
|
||||
public const STATUS_TEMPORARY_MINUTES = 30;
|
||||
public const STATUS_UNAVAILABLE = 'unavailable';
|
||||
|
||||
public static array $priorities;
|
||||
|
||||
public static function initialize()
|
||||
|
@ -111,7 +115,29 @@ class Wish
|
|||
}
|
||||
?>
|
||||
|
||||
<div class="ui fluid card stretch" data-id="<?= $this->id ?>" data-cache="<?= $generateCache ?>">
|
||||
<div class="ui blurring dimmable fluid card stretch"
|
||||
data-id="<?= $this->id ?>"
|
||||
data-cache="<?= $generateCache ?>"
|
||||
>
|
||||
<div class="ui inverted dimmer">
|
||||
<div class="content">
|
||||
<div class="center">
|
||||
<div class="ui icon header">
|
||||
<i class="history icon"></i>
|
||||
<div class="content">
|
||||
<?= __('Wish temporarily fulfilled') ?>
|
||||
<div class="sub header"><?= sprintf(__('If this wish is a product, confirm the order was successful and mark it as fulfilled here. If you do not confirm this wish as fulfilled, it will become available again to others after %d minutes.'), self::STATUS_TEMPORARY_MINUTES) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="ui positive labeled icon button confirm">
|
||||
<i class="check double icon"></i>
|
||||
<?= __('Confirm') ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="image">
|
||||
<?php if ($this->priority && isset(Wish::$priorities[$this->priority])) { ?>
|
||||
<div class="ui small <?= Wish::$priorities[$this->priority]['color'] ?> right ribbon label">
|
||||
|
@ -132,8 +158,6 @@ class Wish
|
|||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="overlay"></div>
|
||||
|
||||
<div class="content">
|
||||
<?php if ($this->title) { ?>
|
||||
<div class="header">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
||||
*/
|
||||
|
||||
use wishthis\{Page, User, Wishlist};
|
||||
use wishthis\{Page, User, Wishlist, Wish};
|
||||
|
||||
$wishlist = new Wishlist($_SESSION['_GET']['wishlist']);
|
||||
$page = new Page(__FILE__, $wishlist->getTitle());
|
||||
|
@ -61,7 +61,12 @@ $page->navigation();
|
|||
<?php
|
||||
echo $wishlist->getCards(
|
||||
array(
|
||||
'WHERE' => '`wishlist` = ' . $wishlist->id . ' AND (`status` != "unavailable" OR `status` IS NULL)',
|
||||
'WHERE' => '`wishlist` = ' . $wishlist->id . '
|
||||
AND (
|
||||
`status` = ""
|
||||
OR `status` IS NULL
|
||||
OR `status` < unix_timestamp(CURRENT_TIMESTAMP - INTERVAL ' . Wish::STATUS_TEMPORARY_MINUTES . ' MINUTE)
|
||||
)'
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue