ver. 0.277: ShopProduct factory, Dashboard, Update migration, legacy cleanup, admin\App
- ShopProduct factory: full migration (~40 ProductRepository methods, ~30 controller actions) - Dashboard: Domain+DI migration (DashboardRepository + DashboardController) - Update: Domain+DI migration (UpdateRepository + UpdateController, template rewrite) - Renamed admin\Site to admin\App, removed dead fallback routing - Removed all legacy folders: admin/controls, admin/factory, admin/view - Newsletter: switched from admin\factory\Articles to ArticleRepository - 414 tests, 1335 assertions passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<div class="g-container" data="table:order-details">
|
||||
<div class="panel panel-info panel-border top">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">Kobinacje produktu: <?= $this -> product['languages'][ $this -> default_language ]['name'];?></span>
|
||||
<span class="panel-title">Kombinacje produktu: <?= $this -> product['languages'][ $this -> default_language ]['name'];?></span>
|
||||
</div>
|
||||
<div class="panel-heading p10 pl15" id="g-menu" style="height: auto;">
|
||||
<a class="btn btn btn-dark btn-sm mr5 btn-sm mr5" href="/admin/shop_product/view_list/"><i class="fa fa-reply mr5"></i>Wstecz</a>
|
||||
@@ -13,19 +13,17 @@
|
||||
<table class="table table-hover table-bordered table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Kombinacja</th>
|
||||
<th>SKU</th>
|
||||
<th>Stan magazynowy</th>
|
||||
<th>Cena netto</th>
|
||||
<th>Zam. SM 0</th>
|
||||
<th>Zam. przy braku</th>
|
||||
<th style="width: 100px;">Opcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ( \S::is_array_fix( $this -> product_permutations ) ): foreach ( $this -> product_permutations as $product ):?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<tr data-combination-id="<?= $product['id'];?>">
|
||||
<td>
|
||||
<?
|
||||
$attributes = explode( '|', $product['permutation_hash'] );
|
||||
@@ -38,19 +36,19 @@
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="sku" value="<?= $product['sku'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_sku_save/', data: { product_id: <?= $product['id'];?>, sku: $( this ).val() } } );">
|
||||
<input type="text" value="<?= $product['sku'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="sku">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="quantity" value="<?= $product['quantity'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_quantity_save/', data: { product_id: <?= $product['id'];?>, quantity: $( this ).val() } } );">
|
||||
<input type="text" value="<?= $product['quantity'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="quantity">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="price" value="<?= $product['price_netto'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_price_save/', data: { product_id: <?= $product['id'];?>, price: $( this ).val() } } );">
|
||||
<input type="text" value="<?= $product['price_netto'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="price">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="stock_0_buy" <? if ( $product['stock_0_buy'] ): echo 'checked="checked"'; endif;?> onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_stock_0_buy_save/', data: { product_id: <?= $product['id'];?>, stock_0_buy: $( this ).is( ':checked' ) } } );">
|
||||
<input type="checkbox" class="g-checkbox combination-checkbox" data-product-id="<?= $product['id'];?>" <? if ( $product['stock_0_buy'] ): echo 'checked="checked"'; endif;?>>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="/admin/shop_product/delete_combination/combination_id=<?= $product['id'];?>&product_id=<?= $product['parent_id'];?>" class="btn btn-danger btn-delete-permutation"><i class="fa fa-trash"></i></a>
|
||||
<button type="button" class="btn btn-danger btn-delete-permutation" data-combination-id="<?= $product['id'];?>"><i class="fa fa-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
<? endforeach; endif;?>
|
||||
@@ -65,6 +63,7 @@
|
||||
<div class="combination-attribute">
|
||||
<div class="title">
|
||||
<?= $attribute['languages'][ $this -> default_language ]['name'];?>
|
||||
<label style="float: right; font-weight: normal; font-size: 12px; cursor: pointer;"><input type="checkbox" class="g-checkbox select-all-attr"> wszystkie</label>
|
||||
</div>
|
||||
<ul class="values">
|
||||
<? foreach ( $attribute['values'] as $value ):?>
|
||||
@@ -92,10 +91,90 @@
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
|
||||
// "Zaznacz wszystkie" per atrybut
|
||||
$( '.select-all-attr' ).on( 'ifChanged', function()
|
||||
{
|
||||
var checked = $( this ).is( ':checked' );
|
||||
$( this ).closest( '.combination-attribute' ).find( '.g-checkbox' ).each( function()
|
||||
{
|
||||
$( this ).iCheck( checked ? 'check' : 'uncheck' );
|
||||
});
|
||||
});
|
||||
|
||||
// Inline save — SKU, ilość, cena
|
||||
var fieldUrlMap = {
|
||||
'sku': '/admin/shop_product/product_combination_sku_save/',
|
||||
'quantity': '/admin/shop_product/product_combination_quantity_save/',
|
||||
'price': '/admin/shop_product/product_combination_price_save/'
|
||||
};
|
||||
|
||||
$( 'body' ).on( 'change', '.combination-field', function()
|
||||
{
|
||||
var $input = $( this );
|
||||
var field = $input.data( 'field' );
|
||||
var data = { product_id: $input.data( 'product-id' ) };
|
||||
data[ field ] = $input.val();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: fieldUrlMap[ field ],
|
||||
data: data,
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status === 'ok' ) {
|
||||
$input.css( 'border-color', '#1cbb8c' );
|
||||
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
|
||||
} else {
|
||||
$input.css( 'border-color', '#ff3d60' );
|
||||
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
|
||||
if ( response.msg ) create_error( response.msg );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$( '#overlay' ).hide();
|
||||
$input.css( 'border-color', '#ff3d60' );
|
||||
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Inline save — checkbox stock_0_buy (iCheck event)
|
||||
$( 'body' ).on( 'ifChanged', '.combination-checkbox', function()
|
||||
{
|
||||
var $cb = $( this );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_combination_stock_0_buy_save/',
|
||||
data: { product_id: $cb.data( 'product-id' ), stock_0_buy: $cb.is( ':checked' ) },
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status !== 'ok' && response.msg ) {
|
||||
create_error( response.msg );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$( '#overlay' ).hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Usuwanie kombinacji — AJAX
|
||||
$( 'body' ).on( 'click', '.btn-delete-permutation', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var href = $( this ).attr( 'href' );
|
||||
var combinationId = $( this ).data( 'combination-id' );
|
||||
var $row = $( this ).closest( 'tr' );
|
||||
|
||||
$.alert(
|
||||
{
|
||||
@@ -119,14 +198,33 @@
|
||||
text: 'Tak',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = href;
|
||||
action: function()
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/delete_combination_ajax/',
|
||||
data: { combination_id: combinationId },
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status === 'ok' ) {
|
||||
$row.fadeOut( 300, function() { $( this ).remove(); } );
|
||||
} else {
|
||||
if ( response.msg ) create_error( response.msg );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$( '#overlay' ).hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user