Fix message for empty wishlist

This commit is contained in:
Jay Trees 2022-02-22 14:20:27 +01:00
parent 909859ad01
commit 777b7fe188
4 changed files with 78 additions and 100 deletions

View file

@ -40,9 +40,7 @@ $(function() {
console.log(element);
console.log(xhr);
if (response.startsWith('<br />')) {
response = response.replace('<br />', '');
}
$('body')
.modal({
@ -87,11 +85,6 @@ $(function() {
filterRemoteData: true
});
/**
* Refresh Wishlist
*/
// wishlistRefresh();
/**
* Commit to Product
*/
@ -178,14 +171,3 @@ $(function() {
.modal('show');
});
});
function wishlistRefresh() {
/**
* URL Parameter
*/
$('.ui.dropdown.wishlists').api({
action: 'get wishlists',
method: 'GET',
on: 'now'
});
}

View file

@ -10,6 +10,76 @@ use wishthis\User;
class Page
{
/**
* Static
*
* @return string
*/
public static function message(string $content = '', string $header = '', string $type = ''): string
{
ob_start();
$containerClasses = array('ui', 'message');
$iconClasses = array('ui', 'icon');
switch ($type) {
case 'error':
$containerClasses[] = 'error icon';
$iconClasses[] = 'exclamation triangle';
break;
case 'warning':
$containerClasses[] = 'warning icon';
$iconClasses[] = 'exclamation circle';
break;
case 'info':
$containerClasses[] = 'info icon';
$iconClasses[] = 'info circle';
break;
}
$containerClass = implode(' ', $containerClasses);
$iconClass = implode(' ', $iconClasses);
?>
<div class="<?= $containerClass ?>">
<?php if ($type) { ?>
<i class="<?= $iconClass ?>"></i>
<?php } ?>
<div class="content">
<?php if ($header) { ?>
<div class="header"><?= $header ?></div>
<?php } ?>
<?php if ($content) { ?>
<p><?= $content ?></p>
<?php } ?>
</div>
</div>
<?php
return ob_get_clean();
}
public static function error(string $content, string $header = ''): string
{
return self::message($content, $header, 'error');
}
public static function warning(string $content, string $header = ''): string
{
return self::message($content, $header, 'warning');
}
public static function info(string $content, string $header = ''): string
{
return self::message($content, $header, 'info');
}
/**
* Non-Static
*/
public string $language = 'en';
/**
@ -191,7 +261,7 @@ class Page
<div class="ui container">
<div class="ui stackable inverted divided equal height stackable grid">
<div class="eight wide column">
<div class="sixteen wide column">
<h4 class="ui inverted header">wishthis</h4>
<div class="ui inverted link list">
@ -209,15 +279,6 @@ class Page
</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>
@ -226,62 +287,4 @@ class Page
</html>
<?php
}
public function message(string $content = '', string $header = '', string $type = ''): void
{
$containerClasses = array('ui', 'message');
$iconClasses = array('ui', 'icon');
switch ($type) {
case 'error':
$containerClasses[] = 'error icon';
$iconClasses[] = 'exclamation triangle';
break;
case 'warning':
$containerClasses[] = 'warning';
$iconClasses[] = 'exclamation circle';
break;
case 'info':
$containerClasses[] = 'info';
$iconClasses[] = 'info circle';
break;
}
$containerClass = implode(' ', $containerClasses);
$iconClass = implode(' ', $iconClasses);
?>
<div class="<?= $containerClass ?>">
<?php if ($type) { ?>
<i class="<?= $iconClass ?>"></i>
<?php } ?>
<div class="content">
<?php if ($header) { ?>
<div class="header"><?= $header ?></div>
<?php } ?>
<?php if ($content) { ?>
<p><?= $content ?></p>
<?php } ?>
</div>
</div>
<?php
}
public function error(string $content, string $header = ''): void
{
$this->message($content, $header, 'error');
}
public function warning(string $content, string $header = ''): void
{
$this->message($content, $header, 'warning');
}
public function info(string $content, string $header = ''): void
{
$this->message($content, $header, 'info');
}
}

View file

@ -143,17 +143,10 @@ class Wishlist
</div>
<?php } ?>
<?php } else { ?>
<?php if (isset($_GET['wishlist'])) { ?>
<div class="ui icon message">
<i class="info circle icon"></i>
<div class="content">
<div class="header">
Empty
<div class="sixteen wide column">
<?= Page::info('This wishlist seems to be empty.', 'Empty'); ?>
</div>
<p>This wishlist seems to be empty.</p>
</div>
</div><?php
}
<?php
}
return ob_get_clean();

View file

@ -8,7 +8,7 @@
use wishthis\Page;
$page = new page(__FILE__, 'Login');
$page = new Page(__FILE__, 'Login');
if (isset($_POST['email'], $_POST['password'])) {
$email = $_POST['email'];
@ -46,7 +46,7 @@ $page->navigation();
<?php
if (isset($success) && !$success) {
$page->error('Invalid credentials!', 'Error');
echo Page::error('Invalid credentials!', 'Error');
}
?>