Refactor admin lists and migrate legacy archive/filemanager controllers
This commit is contained in:
100
admin/templates/banners/banners-list-custom-script.php
Normal file
100
admin/templates/banners/banners-list-custom-script.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<style type="text/css">
|
||||
.banner-thumb-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.banner-thumb-image {
|
||||
width: 72px;
|
||||
height: 42px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.banner-thumb-popup {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: min(70vw, 760px);
|
||||
max-height: 80vh;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
|
||||
z-index: 3000;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition: opacity .1s ease;
|
||||
}
|
||||
|
||||
.banner-thumb-popup.is-visible {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.banner-thumb-popup img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: calc(80vh - 12px);
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.banner-thumb-popup').remove();
|
||||
var $popup = $('<div class="banner-thumb-popup" aria-hidden="true"><img src="" alt=""></div>');
|
||||
var $popupImage = $popup.find('img');
|
||||
$('body').append($popup);
|
||||
|
||||
function positionPopup(event) {
|
||||
var offset = 18;
|
||||
var viewportWidth = $(window).width();
|
||||
var viewportHeight = $(window).height();
|
||||
var popupWidth = $popup.outerWidth();
|
||||
var popupHeight = $popup.outerHeight();
|
||||
var left = (event.clientX || 0) + offset;
|
||||
var top = (event.clientY || 0) + offset;
|
||||
|
||||
if (left + popupWidth + 12 > viewportWidth) {
|
||||
left = Math.max(12, (event.clientX || 0) - popupWidth - offset);
|
||||
}
|
||||
|
||||
if (top + popupHeight + 12 > viewportHeight) {
|
||||
top = Math.max(12, viewportHeight - popupHeight - 12);
|
||||
}
|
||||
|
||||
$popup.css({ left: left + 'px', top: top + 'px' });
|
||||
}
|
||||
|
||||
$(document).off('.bannerThumbPopup');
|
||||
|
||||
$(document).on('mouseenter.bannerThumbPopup', '.js-banner-thumb-preview', function(event) {
|
||||
var src = $(this).data('previewSrc');
|
||||
if (!src) {
|
||||
return;
|
||||
}
|
||||
|
||||
$popupImage.attr('src', String(src));
|
||||
$popup.addClass('is-visible');
|
||||
positionPopup(event);
|
||||
});
|
||||
|
||||
$(document).on('mousemove.bannerThumbPopup', '.js-banner-thumb-preview', function(event) {
|
||||
if ($popup.hasClass('is-visible')) {
|
||||
positionPopup(event);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('mouseleave.bannerThumbPopup', '.js-banner-thumb-preview', function() {
|
||||
$popup.removeClass('is-visible');
|
||||
$popupImage.attr('src', '');
|
||||
});
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
@@ -1,105 +1,5 @@
|
||||
<?= \Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
<style type="text/css">
|
||||
.banner-thumb-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.banner-thumb-image {
|
||||
width: 72px;
|
||||
height: 42px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.banner-thumb-popup {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: min(70vw, 760px);
|
||||
max-height: 80vh;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
|
||||
z-index: 3000;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition: opacity .1s ease;
|
||||
}
|
||||
|
||||
.banner-thumb-popup.is-visible {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.banner-thumb-popup img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: calc(80vh - 12px);
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $popup = $('<div class="banner-thumb-popup" aria-hidden="true"><img src="" alt=""></div>');
|
||||
var $popupImage = $popup.find('img');
|
||||
$('body').append($popup);
|
||||
|
||||
function positionPopup(event) {
|
||||
var offset = 18;
|
||||
var viewportWidth = $(window).width();
|
||||
var viewportHeight = $(window).height();
|
||||
var popupWidth = $popup.outerWidth();
|
||||
var popupHeight = $popup.outerHeight();
|
||||
var left = (event.clientX || 0) + offset;
|
||||
var top = (event.clientY || 0) + offset;
|
||||
|
||||
if (left + popupWidth + 12 > viewportWidth) {
|
||||
left = Math.max(12, (event.clientX || 0) - popupWidth - offset);
|
||||
}
|
||||
|
||||
if (top + popupHeight + 12 > viewportHeight) {
|
||||
top = Math.max(12, viewportHeight - popupHeight - 12);
|
||||
}
|
||||
|
||||
$popup.css({ left: left + 'px', top: top + 'px' });
|
||||
}
|
||||
|
||||
$(document).off('.bannerThumbPopup');
|
||||
|
||||
$(document).on('mouseenter.bannerThumbPopup', '.js-banner-thumb-preview', function(event) {
|
||||
var src = $(this).data('previewSrc');
|
||||
if (!src) {
|
||||
return;
|
||||
}
|
||||
|
||||
$popupImage.attr('src', String(src));
|
||||
$popup.addClass('is-visible');
|
||||
positionPopup(event);
|
||||
});
|
||||
|
||||
$(document).on('mousemove.bannerThumbPopup', '.js-banner-thumb-preview', function(event) {
|
||||
if ($popup.hasClass('is-visible')) {
|
||||
positionPopup(event);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('mouseleave.bannerThumbPopup', '.js-banner-thumb-preview', function() {
|
||||
$popup.removeClass('is-visible');
|
||||
$popupImage.attr('src', '');
|
||||
});
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Tpl::view($this->viewModel->customScriptView, ['list' => $this->viewModel]); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
<iframe src="/libraries/filemanager-9.14.2/dialog.php?akey=c3cb2537d25c0efc9e573d059d79c3b8" style="border: 0px; width: 100%; height: 800px; background: #FFF; padding: 5px;"></iframe>
|
||||
<?php
|
||||
$filemanagerUrl = trim((string)($this->filemanager_url ?? '/libraries/filemanager-9.14.2/dialog.php'));
|
||||
?>
|
||||
<iframe src="<?= htmlspecialchars($filemanagerUrl, ENT_QUOTES, 'UTF-8'); ?>" style="border: 0px; width: 100%; height: 800px; background: #FFF; padding: 5px;"></iframe>
|
||||
|
||||
100
admin/templates/product-archive/products-list-custom-script.php
Normal file
100
admin/templates/product-archive/products-list-custom-script.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<style type="text/css">
|
||||
.product-archive-thumb-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.product-archive-thumb-image {
|
||||
width: 72px;
|
||||
height: 42px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.product-archive-thumb-popup {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: min(70vw, 760px);
|
||||
max-height: 80vh;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
|
||||
z-index: 3000;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition: opacity .1s ease;
|
||||
}
|
||||
|
||||
.product-archive-thumb-popup.is-visible {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.product-archive-thumb-popup img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: calc(80vh - 12px);
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.product-archive-thumb-popup').remove();
|
||||
var $popup = $('<div class="product-archive-thumb-popup" aria-hidden="true"><img src="" alt=""></div>');
|
||||
var $popupImage = $popup.find('img');
|
||||
$('body').append($popup);
|
||||
|
||||
function positionPopup(event) {
|
||||
var offset = 18;
|
||||
var viewportWidth = $(window).width();
|
||||
var viewportHeight = $(window).height();
|
||||
var popupWidth = $popup.outerWidth();
|
||||
var popupHeight = $popup.outerHeight();
|
||||
var left = (event.clientX || 0) + offset;
|
||||
var top = (event.clientY || 0) + offset;
|
||||
|
||||
if (left + popupWidth + 12 > viewportWidth) {
|
||||
left = Math.max(12, (event.clientX || 0) - popupWidth - offset);
|
||||
}
|
||||
|
||||
if (top + popupHeight + 12 > viewportHeight) {
|
||||
top = Math.max(12, viewportHeight - popupHeight - 12);
|
||||
}
|
||||
|
||||
$popup.css({ left: left + 'px', top: top + 'px' });
|
||||
}
|
||||
|
||||
$(document).off('.productArchiveThumbPopup');
|
||||
|
||||
$(document).on('mouseenter.productArchiveThumbPopup', '.js-product-archive-thumb-preview', function(event) {
|
||||
var src = $(this).data('previewSrc');
|
||||
if (!src) {
|
||||
return;
|
||||
}
|
||||
|
||||
$popupImage.attr('src', String(src));
|
||||
$popup.addClass('is-visible');
|
||||
positionPopup(event);
|
||||
});
|
||||
|
||||
$(document).on('mousemove.productArchiveThumbPopup', '.js-product-archive-thumb-preview', function(event) {
|
||||
if ($popup.hasClass('is-visible')) {
|
||||
positionPopup(event);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('mouseleave.productArchiveThumbPopup', '.js-product-archive-thumb-preview', function() {
|
||||
$popup.removeClass('is-visible');
|
||||
$popupImage.attr('src', '');
|
||||
});
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
5
admin/templates/product-archive/products-list.php
Normal file
5
admin/templates/product-archive/products-list.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?= \Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Tpl::view($this->viewModel->customScriptView, ['list' => $this->viewModel]); ?>
|
||||
<?php endif; ?>
|
||||
@@ -1,41 +0,0 @@
|
||||
<? $i = ( $this -> current_page - 1 ) * 10 + 1;?>
|
||||
<? foreach ( $this -> products as $product ):?>
|
||||
<tr>
|
||||
<td>
|
||||
<?= $i++;?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="product-image">
|
||||
<? if ( $product['images'][0]['src'] ):?>
|
||||
<img src="<?= $product['images'][0]['src'];?>" alt="<?= $product['images'][0]['alt'];?>" class="img-responsive">
|
||||
<? else:?>
|
||||
<img src="/admin/layout/images/no-image.png" alt="Brak zdjęcia" class="img-responsive">
|
||||
<? endif;?>
|
||||
</div>
|
||||
<div class="product-name">
|
||||
<a href="/admin/shop_product/product_edit/id=<?= $product['id'];?>">
|
||||
<?= $product['languages']['pl']['name'];?>
|
||||
</a>
|
||||
</div>
|
||||
<small class="text-muted"><?= \admin\factory\ShopProduct::product_categories( $product['id'] );?></small>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?= $product['price_brutto'];?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?= $product['price_brutto_promo'];?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="text-muted"><?= (int)\admin\factory\shopProduct::get_product_quantity_list( $product['id'] );?></span>
|
||||
</td>
|
||||
<td>
|
||||
<a href='/admin/shop_product/product_combination/product_id=<?= $product['id'];?>'>kombinacje (<?= \admin\factory\shopProduct::count_product_combinations( $product['id'] );?>)</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href='/admin/shop_product/product_edit/id=<?= $product['id'];?>'>edytuj</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href='/admin/product_archive/unarchive/product_id=<?= $product['id'];?>' class="product-unarchive">przywróć</a>
|
||||
</td>
|
||||
</tr>
|
||||
<? endforeach;?>
|
||||
@@ -1,152 +0,0 @@
|
||||
<div class="panel">
|
||||
<div class="panel-body pn">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-striped mbn" id="table-products">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 10px;">#</th>
|
||||
<th>Nazwa</th>
|
||||
<th class="text-center" style="width: 100px;">Cena</th>
|
||||
<th class="text-center" style="width: 100px;">Cena promocyjna</th>
|
||||
<th class="text-center" style="width: 75px;">Stan MG</th>
|
||||
<th class="text-center" style="width: 100px;">Kombinacje</th>
|
||||
<th class="text-center" style="width: 75px;">Edytuj</th>
|
||||
<th class="text-center" style="width: 75px;">Przywróć</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>
|
||||
<input type="text" class="form-control table-search" field_name="name|ean|sku" placeholder="szukaj..." value="<?= htmlspecialchars( $this -> query_array['name'] ?? '', ENT_QUOTES, 'UTF-8');?>">
|
||||
</th>
|
||||
<th colspan="6"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<ul class="pagination" pagination_max="<?= $this -> pagination_max;?>">
|
||||
<li>
|
||||
<a href="#" page="1" title="pierwsza strona">
|
||||
<i class="fa fa-angle-double-left"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="previous" page="<?= ( $this -> current_page - 1 > 1 ) ? ( $this -> current_page - 1 ) : 1;?>" title="poprzednia strona">
|
||||
<i class="fa fa-angle-left" title="poprzednia strona"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
Strona <span id="current-page"><?= $this -> current_page;?></span> z <span id="max_page"><?= $this -> pagination_max;?></span>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="next" page="<?= ( $this -> current_page + 1 < $this -> pagination_max ) ? ( $this -> current_page + 1 ) : $this -> pagination_max;?>" title="następna strona">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="last" page="<?= $this -> pagination_max;?>" title="ostatnia strona">
|
||||
<i class="fa fa-angle-double-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$( function() {
|
||||
ajax_load_products( <?= $this -> current_page;?> );
|
||||
|
||||
$( 'body' ).on( 'change', '.table-search', function() {
|
||||
ajax_load_products( 1 );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.pagination a', function() {
|
||||
var current_page = $( this ).attr( 'page' );
|
||||
ajax_load_products( current_page );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.product-unarchive', function(e) {
|
||||
e.preventDefault();
|
||||
var href = $( this ).attr( 'href' );
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz przywrócić wybrany produkt z archiwum?',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'supervan',
|
||||
icon: 'fa fa-question',
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-success',
|
||||
action: function() {}
|
||||
},
|
||||
confirm: {
|
||||
text: 'Tak',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = href;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function ajax_load_products( current_page ) {
|
||||
var pagination_max = parseInt( $( '.pagination' ).attr( 'pagination_max' ) );
|
||||
|
||||
var query = '';
|
||||
$( '.table-search' ).each(function(){
|
||||
query += $( this ).attr( 'field_name' ) + '=' + $( this ).val() + '&';
|
||||
});
|
||||
|
||||
current_page = parseInt( current_page );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/ajax_load_products_archive/',
|
||||
data: {
|
||||
current_page: current_page,
|
||||
query: query
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( '#table-products tbody' ).html( data.html );
|
||||
$( '.pagination .previous' ).attr( 'page', ( current_page - 1 > 1 ) ? ( current_page - 1 ) : 1 );
|
||||
$( '.pagination .next' ).attr( 'page', ( current_page + 1 < pagination_max ) ? ( current_page + 1 ) : pagination_max );
|
||||
$( '.pagination span' ).html( current_page );
|
||||
if ( data.pagination_max ) {
|
||||
$( '.pagination' ).attr( 'pagination_max', data.pagination_max );
|
||||
$( '.pagination #max_page' ).html( data.pagination_max );
|
||||
$( '.pagination .last' ).attr( 'page', data.pagination_max );
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user