ver. 0.276: ShopOrder migration, Integrations cleanup, global admin search
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
Sklep
|
||||
</div>
|
||||
<ul>
|
||||
<li> <a href="/admin/shop_order/view_list/"><img src="/admin/layout/icon/icon-menu/shopping-cart.svg">Zamówienia</a></li>
|
||||
<li> <a href="/admin/shop_order/list/"><img src="/admin/layout/icon/icon-menu/shopping-cart.svg">Zamówienia</a></li>
|
||||
<li> <a href="/admin/shop_clients/list/"><img src="/admin/layout/icon/icon-menu/people-fill.svg">Klienci</a></li>
|
||||
<li><a href="/admin/shop_category/list/"><img src="/admin/layout/icon/icon-menu/bxs-category-alt.svg">Kategorie</a></li>
|
||||
<li><a href="/admin/shop_product/view_list/"><img src="/admin/layout/icon/icon-menu/shopping-basket.svg">Produkty</a></li>
|
||||
@@ -159,7 +159,19 @@
|
||||
<div class="col-12 col-md-3 col-lg-2">
|
||||
<button id="clear-cache-btn" class="btn btn-danger mt-3">Wyczyść cache</button>
|
||||
</div>
|
||||
<div class="col-12 col-md-9 col-lg-10 top-user">
|
||||
<div class="col-12 col-md-6 col-lg-7 mt-3">
|
||||
<div class="admin-global-search" id="admin-global-search-wrap">
|
||||
<input
|
||||
type="text"
|
||||
id="admin-global-search-input"
|
||||
class="form-control"
|
||||
placeholder="Szukaj produktu (EAN, Nazwa, SKU) lub zamówienia (email, imię, nazwisko, telefon, numer)"
|
||||
autocomplete="off"
|
||||
>
|
||||
<div class="admin-global-search-results" id="admin-global-search-results"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 col-lg-3 top-user">
|
||||
<div class="dropdown">
|
||||
<?
|
||||
if ( $user[ 'name' ] or $user[ 'surname' ] )
|
||||
@@ -246,6 +258,101 @@
|
||||
bindClearCacheButton();
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var $input = $('#admin-global-search-input');
|
||||
var $results = $('#admin-global-search-results');
|
||||
var $wrap = $('#admin-global-search-wrap');
|
||||
var timer = null;
|
||||
|
||||
function escapeHtml(value) {
|
||||
return $('<div>').text(value || '').html();
|
||||
}
|
||||
|
||||
function hideResults() {
|
||||
$results.removeClass('open').empty();
|
||||
}
|
||||
|
||||
function renderResults(items) {
|
||||
if (!Array.isArray(items) || items.length === 0) {
|
||||
$results
|
||||
.html('<div class="admin-global-search-empty">Brak wyników</div>')
|
||||
.addClass('open');
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '';
|
||||
items.forEach(function(item) {
|
||||
var title = escapeHtml(item.title || '');
|
||||
var subtitle = escapeHtml(item.subtitle || '');
|
||||
var type = item.type === 'order' ? 'Zamówienie' : 'Produkt';
|
||||
var url = escapeHtml(item.url || '#');
|
||||
|
||||
html += ''
|
||||
+ '<a class="admin-global-search-item" href="' + url + '">'
|
||||
+ ' <div class="admin-global-search-item-title">' + title + '</div>'
|
||||
+ ' <div class="admin-global-search-item-subtitle">' + escapeHtml(type) + (subtitle ? ' | ' + subtitle : '') + '</div>'
|
||||
+ '</a>';
|
||||
});
|
||||
|
||||
$results.html(html).addClass('open');
|
||||
}
|
||||
|
||||
function searchNow() {
|
||||
var phrase = ($input.val() || '').trim();
|
||||
if (phrase.length < 2) {
|
||||
hideResults();
|
||||
return;
|
||||
}
|
||||
|
||||
$results.html('<div class="admin-global-search-empty">Szukam...</div>').addClass('open');
|
||||
|
||||
$.ajax({
|
||||
url: '/admin/settings/globalSearchAjax/',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: { q: phrase },
|
||||
success: function(response) {
|
||||
if (!response || response.status !== 'ok') {
|
||||
$results.html('<div class="admin-global-search-empty">Wystąpił błąd wyszukiwania</div>').addClass('open');
|
||||
return;
|
||||
}
|
||||
|
||||
renderResults(response.items || []);
|
||||
},
|
||||
error: function() {
|
||||
$results.html('<div class="admin-global-search-empty">Błąd połączenia</div>').addClass('open');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document)
|
||||
.off('input.adminGlobalSearch', '#admin-global-search-input')
|
||||
.on('input.adminGlobalSearch', '#admin-global-search-input', function() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(searchNow, 250);
|
||||
});
|
||||
|
||||
$(document)
|
||||
.off('focus.adminGlobalSearch', '#admin-global-search-input')
|
||||
.on('focus.adminGlobalSearch', '#admin-global-search-input', function() {
|
||||
if (($input.val() || '').trim().length >= 2 && $results.children().length > 0) {
|
||||
$results.addClass('open');
|
||||
}
|
||||
});
|
||||
|
||||
$(document)
|
||||
.off('click.adminGlobalSearch')
|
||||
.on('click.adminGlobalSearch', function(e) {
|
||||
if ($wrap.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(e.target).closest('#admin-global-search-wrap').length === 0) {
|
||||
hideResults();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
$(document).ready(function () {
|
||||
var user_agent = navigator.userAgent.toLowerCase();
|
||||
var click_event = user_agent.match(/(iphone|ipod|ipad)/) ? "touchend" : "click";
|
||||
@@ -269,5 +376,62 @@
|
||||
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.admin-global-search {
|
||||
position: relative;
|
||||
max-width: 900px;
|
||||
}
|
||||
|
||||
.admin-global-search-results {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: calc(100% + 4px);
|
||||
z-index: 9999;
|
||||
background: #fff;
|
||||
border: 1px solid #e5e5e5;
|
||||
border-radius: 4px;
|
||||
max-height: 420px;
|
||||
overflow: auto;
|
||||
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.admin-global-search-results.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.admin-global-search-item {
|
||||
display: block;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.admin-global-search-item:hover,
|
||||
.admin-global-search-item:focus {
|
||||
background: #f7f9fc;
|
||||
color: #222;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.admin-global-search-item-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.admin-global-search-item-subtitle {
|
||||
font-size: 12px;
|
||||
color: #6c757d;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.admin-global-search-empty {
|
||||
padding: 10px 12px;
|
||||
color: #6c757d;
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user