// PI-116 - attribute default refactoring
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14525 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
-13
@@ -34,17 +34,4 @@
|
|||||||
<li>{l s='A default combination must be designated for each product.'}</li>
|
<li>{l s='A default combination must be designated for each product.'}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var impact = getE('attribute_price_impact');
|
|
||||||
var impact2 = getE('attribute_weight_impact');
|
|
||||||
|
|
||||||
var s_attr_group = $('#span_new_group');
|
|
||||||
var s_attr_name = $('#span_new_attr');
|
|
||||||
var s_impact = $('#span_impact');
|
|
||||||
var s_impact2 = $('#span_weight_impact');
|
|
||||||
|
|
||||||
init_elems();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
|
|||||||
@@ -23,6 +23,6 @@
|
|||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
<a href="{$href}" class="default" title="{$action}">
|
<a href="{$href}" class="default" title="{$action}" {if isset($name)}name="{$name}{/if}">
|
||||||
<img src="../img/admin/asterisk.gif" alt="{$action}" />
|
<img src="../img/admin/asterisk.gif" alt="{$action}" />
|
||||||
</a>
|
</a>
|
||||||
@@ -197,6 +197,7 @@ class HelperListCore extends Helper
|
|||||||
{
|
{
|
||||||
$id = $tr[$this->identifier];
|
$id = $tr[$this->identifier];
|
||||||
$name = isset($tr['name']) ? $tr['name'] : null;
|
$name = isset($tr['name']) ? $tr['name'] : null;
|
||||||
|
|
||||||
if ($this->shopLinkType)
|
if ($this->shopLinkType)
|
||||||
$this->_list[$index]['short_shop_name'] = Tools::strlen($tr['shop_name']) > 15 ? Tools::substr($tr['shop_name'], 0, 15).'...' : $tr['shop_name'];
|
$this->_list[$index]['short_shop_name'] = Tools::strlen($tr['shop_name']) > 15 ? Tools::substr($tr['shop_name'], 0, 15).'...' : $tr['shop_name'];
|
||||||
|
|
||||||
@@ -481,9 +482,10 @@ class HelperListCore extends Helper
|
|||||||
self::$cache_lang['Default'] = $this->l('Default', 'Helper');
|
self::$cache_lang['Default'] = $this->l('Default', 'Helper');
|
||||||
|
|
||||||
$tpl->assign(array_merge($this->tpl_delete_link_vars, array(
|
$tpl->assign(array_merge($this->tpl_delete_link_vars, array(
|
||||||
'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token != null ? $token : $this->token),
|
'href' => Tools::safeOutput($this->currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token != null ? $token : $this->token)),
|
||||||
'action' => self::$cache_lang['Default'],
|
'action' => self::$cache_lang['Default'],
|
||||||
'id' => $id,
|
'name' => Tools::safeOutput($name),
|
||||||
|
'id' => Tools::safeOutput($id),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
return $tpl->fetch();
|
return $tpl->fetch();
|
||||||
|
|||||||
@@ -3439,24 +3439,21 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
foreach ($comb_array as $id_product_attribute => $product_attribute)
|
foreach ($comb_array as $id_product_attribute => $product_attribute)
|
||||||
{
|
{
|
||||||
$list = '';
|
$list = '';
|
||||||
$js_list = '';
|
|
||||||
|
|
||||||
/* In order to keep the same attributes order */
|
/* In order to keep the same attributes order */
|
||||||
asort($product_attribute['attributes']);
|
asort($product_attribute['attributes']);
|
||||||
|
|
||||||
foreach ($product_attribute['attributes'] as $attribute)
|
foreach ($product_attribute['attributes'] as $attribute)
|
||||||
{
|
|
||||||
$list .= htmlspecialchars($attribute[0]).' - '.htmlspecialchars($attribute[1]).', ';
|
$list .= htmlspecialchars($attribute[0]).' - '.htmlspecialchars($attribute[1]).', ';
|
||||||
$js_list .= '\''.htmlspecialchars($attribute[0]).' : '.htmlspecialchars($attribute[1]).'\', \''.$attribute[2].'\', ';
|
|
||||||
}
|
|
||||||
$list = rtrim($list, ', ');
|
$list = rtrim($list, ', ');
|
||||||
$js_list = rtrim($js_list, ', ');
|
|
||||||
$comb_array[$id_product_attribute]['image'] = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false;
|
$comb_array[$id_product_attribute]['image'] = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false;
|
||||||
$comb_array[$id_product_attribute]['available_date'] = $product_attribute['available_date'] != 0 ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00';
|
$comb_array[$id_product_attribute]['available_date'] = $product_attribute['available_date'] != 0 ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00';
|
||||||
$comb_array[$id_product_attribute]['attributes'] = $list;
|
$comb_array[$id_product_attribute]['attributes'] = $list;
|
||||||
|
|
||||||
if ($product_attribute['default_on'])
|
if ($product_attribute['default_on'])
|
||||||
{
|
{
|
||||||
$this->list_skip_actions['default'][] = $product_attribute['id_product_attribute'];
|
$comb_array[$id_product_attribute]['name'] = 'is_default';
|
||||||
$comb_array[$id_product_attribute]['color'] = $color_by_default;
|
$comb_array[$id_product_attribute]['color'] = $color_by_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+79
-79
@@ -55,7 +55,7 @@ product_tabs['Combinations'] = new function(){
|
|||||||
$('#add_new_combination').show();
|
$('#add_new_combination').show();
|
||||||
$('#attribute_quantity').show();
|
$('#attribute_quantity').show();
|
||||||
$('#product_att_list').html('');
|
$('#product_att_list').html('');
|
||||||
removeButtonCombination('update');
|
self.removeButtonCombination('update');
|
||||||
$.scrollTo('#add_new_combination', 1200, { offset: -100 });
|
$.scrollTo('#add_new_combination', 1200, { offset: -100 });
|
||||||
var wholesale_price = Math.abs(data[0]['wholesale_price']);
|
var wholesale_price = Math.abs(data[0]['wholesale_price']);
|
||||||
var price = Math.abs(data[0]['price']);
|
var price = Math.abs(data[0]['price']);
|
||||||
@@ -123,103 +123,103 @@ product_tabs['Combinations'] = new function(){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.defaultProductAttribute = function(url, item){
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
data: {
|
||||||
|
id_product: id_product,
|
||||||
|
action: 'defaultProductAttribute',
|
||||||
|
ajax: true
|
||||||
|
},
|
||||||
|
context: document.body,
|
||||||
|
dataType: 'json',
|
||||||
|
context: this,
|
||||||
|
async: false,
|
||||||
|
success: function(data) {
|
||||||
|
if (data.status == 'ok')
|
||||||
|
{
|
||||||
|
showSuccessMessage(data.message);
|
||||||
|
|
||||||
|
// Reset previous default attribute display
|
||||||
|
var previous = $('a[name=is_default]');
|
||||||
|
previous.closest('tr').attr('style', '');
|
||||||
|
previous.show();
|
||||||
|
previous.attr('name', '');
|
||||||
|
|
||||||
|
// Update new default attribute display
|
||||||
|
$(item).closest('tr').css('background','#BDE5F8');
|
||||||
|
$(item).hide();
|
||||||
|
$(item).attr('name', 'is_default');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
showErrorMessage(data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
this.bindDefault = function(){
|
this.bindDefault = function(){
|
||||||
|
$('a[name=is_default]').hide();
|
||||||
$('table[name=list_table]').delegate('a.default', 'click', function(e){
|
$('table[name=list_table]').delegate('a.default', 'click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
defaultProductAttribute(this.href, $(this).closest('tr'));
|
self.defaultProductAttribute(this.href, this);
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function defaultProductAttribute (url, parent){
|
this.deleteProductAttribute = function(url, parent){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
data: {
|
data: {
|
||||||
id_product: id_product,
|
id_product: id_product,
|
||||||
action: 'defaultProductAttribute',
|
action: 'deleteProductAttribute',
|
||||||
ajax: true
|
ajax: true
|
||||||
},
|
},
|
||||||
context: document.body,
|
context: document.body,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
context: this,
|
context: this,
|
||||||
async: false,
|
async: false,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data.status == 'ok')
|
if (data.status == 'ok')
|
||||||
{
|
{
|
||||||
showSuccessMessage(data.message);
|
showSuccessMessage(data.message);
|
||||||
$('table.table').find('tr').attr('style', function() {
|
parent.remove();
|
||||||
var style = $(this).attr('style');
|
|
||||||
if (style)
|
|
||||||
{
|
|
||||||
$(this).attr('style', '');
|
|
||||||
var ids = $(this).find('a.edit').attr('ids');
|
|
||||||
var token = $(this).find('a.edit').attr('token');
|
|
||||||
$(this).find('a.edit').after("<a title=\"Default\" onclick=\"javascript:defaultProductAttribute('"+ids+"', '"+token+"', $(this).parent('td').parent('tr'));\" class=\"pointer default\"><img alt=\"Default\" src=\"../img/admin/asterisk.gif\"></a>");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
parent.find('a.default').hide();
|
|
||||||
parent.css('background','#BDE5F8');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
showErrorMessage(data.message);
|
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
}
|
showErrorMessage(data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.bindDelete = function() {
|
this.bindDelete = function() {
|
||||||
$('table[name=list_table]').delegate('a.delete', 'click', function(e){
|
$('table[name=list_table]').delegate('a.delete', 'click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
deleteProductAttribute(this.href, $(this).closest('tr'));
|
self.deleteProductAttribute(this.href, $(this).closest('tr'));
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function deleteProductAttribute(url, parent){
|
this.removeButtonCombination = function(item)
|
||||||
$.ajax({
|
{
|
||||||
url: url,
|
$('#add_new_combination').show();
|
||||||
data: {
|
$('.process-icon-newCombination').removeClass('toolbar-new');
|
||||||
id_product: id_product,
|
$('.process-icon-newCombination').addClass('toolbar-cancel');
|
||||||
action: 'deleteProductAttribute',
|
$('#desc-product-newCombination div').html($('#ResetBtn').val());
|
||||||
ajax: true
|
$('id_product_attribute').val(0);
|
||||||
},
|
init_elems();
|
||||||
context: document.body,
|
};
|
||||||
dataType: 'json',
|
|
||||||
context: this,
|
this.addButtonCombination = function(item)
|
||||||
async: false,
|
{
|
||||||
success: function(data) {
|
$('#add_new_combination').hide();
|
||||||
if (data.status == 'ok')
|
$('.process-icon-newCombination').removeClass('toolbar-cancel');
|
||||||
{
|
$('.process-icon-newCombination').addClass('toolbar-new');
|
||||||
showSuccessMessage(data.message);
|
$('#desc-product-newCombination div').html(msg_new_combination);
|
||||||
parent.remove();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
showErrorMessage(data.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.bindToggleAddCombination = function (){
|
this.bindToggleAddCombination = function (){
|
||||||
$('#desc-product-newCombination').click(function() {
|
$('#desc-product-newCombination').click(function() {
|
||||||
if ($('.process-icon-newCombination').hasClass('toolbar-new'))
|
if ($('.process-icon-newCombination').hasClass('toolbar-new'))
|
||||||
removeButtonCombination('add');
|
self.removeButtonCombination('add');
|
||||||
else
|
else
|
||||||
addButtonCombination('add');
|
self.addButtonCombination('add');
|
||||||
|
|
||||||
function removeButtonCombination(item)
|
|
||||||
{
|
|
||||||
$('#add_new_combination').show();
|
|
||||||
$('.process-icon-newCombination').removeClass('toolbar-new');
|
|
||||||
$('.process-icon-newCombination').addClass('toolbar-cancel');
|
|
||||||
$('#desc-product-newCombination div').html($('#ResetBtn').val());
|
|
||||||
$('id_product_attribute').val(0);
|
|
||||||
init_elems();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addButtonCombination(item)
|
|
||||||
{
|
|
||||||
$('#add_new_combination').hide();
|
|
||||||
$('.process-icon-newCombination').removeClass('toolbar-cancel');
|
|
||||||
$('.process-icon-newCombination').addClass('toolbar-new');
|
|
||||||
$('#desc-product-newCombination div').html(msg_new_combination);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,8 @@ function check_unit_impact()
|
|||||||
|
|
||||||
function init_elems()
|
function init_elems()
|
||||||
{
|
{
|
||||||
|
var impact = getE('attribute_price_impact');
|
||||||
|
var impact2 = getE('attribute_weight_impact');
|
||||||
var elem = getE('product_att_list');
|
var elem = getE('product_att_list');
|
||||||
|
|
||||||
if (elem.length)
|
if (elem.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user