// drag and drop fixes
// admin category translations git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13941 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+6
-5
@@ -121,10 +121,11 @@ if (Tools::isSubmit('ajaxCategoriesPositions'))
|
||||
$pos = explode('_', $value);
|
||||
if ((isset($pos[1]) AND isset($pos[2])) AND ($pos[1] == $id_category_parent AND $pos[2] == $id_category_to_move))
|
||||
{
|
||||
$position = $key;
|
||||
$position = $key + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$category = new Category($id_category_to_move);
|
||||
if (Validate::isLoadedObject($category))
|
||||
{
|
||||
@@ -777,7 +778,7 @@ if (Tools::isSubmit('ajaxGroupsAttributesPositions'))
|
||||
|
||||
$new_positions = array();
|
||||
foreach($positions as $k => $v)
|
||||
if (count(explode('_', $v)) == 3)
|
||||
if (count(explode('_', $v)) == 4)
|
||||
$new_positions[] = $v;
|
||||
|
||||
foreach ($new_positions as $position => $value)
|
||||
@@ -785,11 +786,11 @@ if (Tools::isSubmit('ajaxGroupsAttributesPositions'))
|
||||
// pos[1] = id_attribute_group, pos[2] = old position
|
||||
$pos = explode('_', $value);
|
||||
|
||||
if (isset($pos[1]) && (int)$pos[1] === $id_attribute_group)
|
||||
if (isset($pos[2]) && (int)$pos[2] === $id_attribute_group)
|
||||
{
|
||||
if ($group_attribute = new AttributeGroup((int)$pos[1]))
|
||||
if ($group_attribute = new AttributeGroup((int)$pos[2]))
|
||||
if (isset($position) && $group_attribute->updatePosition($way, $position))
|
||||
echo "ok position ".(int)$position." for group attribute ".(int)$pos[1]."\r\n";
|
||||
echo "ok position ".(int)$position." for group attribute ".(int)$pos[2]."\r\n";
|
||||
else
|
||||
echo '{"hasError" : true, "errors" : "Can not update group attribute '. (int)$id_attribute_group . ' to position '.(int)$position.' "}';
|
||||
else
|
||||
|
||||
+39
-40
@@ -30,9 +30,8 @@ $(document).ready(function() {
|
||||
|
||||
function initTableDnD(table)
|
||||
{
|
||||
if (typeof(table) == 'undefined') {
|
||||
if (typeof(table) == 'undefined')
|
||||
table = 'table.tableDnD';
|
||||
}
|
||||
|
||||
$(table).tableDnD({
|
||||
onDragStart: function(table, row) {
|
||||
@@ -66,31 +65,31 @@ function initTableDnD(table)
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
if (table.id == 'cms')
|
||||
params = {
|
||||
ajaxCMSPositions: true,
|
||||
id_cms_category: ids[1],
|
||||
id_cms: ids[2],
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
if (table.id == 'cms_block_0')
|
||||
params = {
|
||||
ajaxCMSBlockPositions: true,
|
||||
id_cms_block: ids[1],
|
||||
position: ids[2],
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
if (table.id == 'cms_block_1')
|
||||
params = {
|
||||
ajaxCMSBlockPositions: true,
|
||||
id_cms_block: ids[1],
|
||||
position: ids[2],
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
if (come_from == 'AdminModulesPositions')
|
||||
if (table.id == 'cms')
|
||||
params = {
|
||||
ajaxCMSPositions: true,
|
||||
id_cms_category: ids[1],
|
||||
id_cms: ids[2],
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
if (table.id == 'cms_block_0')
|
||||
params = {
|
||||
ajaxCMSBlockPositions: true,
|
||||
id_cms_block: ids[1],
|
||||
position: ids[2],
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
if (table.id == 'cms_block_1')
|
||||
params = {
|
||||
ajaxCMSBlockPositions: true,
|
||||
id_cms_block: ids[1],
|
||||
position: ids[2],
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
if (come_from == 'AdminModulesPositions')
|
||||
params = {
|
||||
ajaxModulesPositions: true,
|
||||
id_hook: ids[0],
|
||||
@@ -118,8 +117,8 @@ function initTableDnD(table)
|
||||
if (table.id.indexOf('attribute') != -1 && table.id != 'attribute_group') {
|
||||
params = {
|
||||
ajaxAttributesPositions: true,
|
||||
id_attribute_group: ids[1],
|
||||
id_attribute: ids[2],
|
||||
id_attribute_group: ids[2],
|
||||
id_attribute: ids[3],
|
||||
way: way,
|
||||
token: token
|
||||
};
|
||||
@@ -128,7 +127,7 @@ function initTableDnD(table)
|
||||
if (table.id == 'attribute_group') {
|
||||
params = {
|
||||
ajaxGroupsAttributesPositions: true,
|
||||
id_attribute_group: ids[1],
|
||||
id_attribute_group: ids[2],
|
||||
way: way,
|
||||
token: token
|
||||
}
|
||||
@@ -208,7 +207,7 @@ function initTableDnD(table)
|
||||
}
|
||||
|
||||
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
||||
tableDrag.children('tbody').children('tr').each(function(i) {
|
||||
$(tableDrag).children('tbody').children('tr').each(function(i) {
|
||||
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
||||
// Update link position
|
||||
// Up links
|
||||
@@ -218,18 +217,18 @@ function initTableDnD(table)
|
||||
$(this).children('td.dragHandle a:even').attr('href', $(this).children('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&'));
|
||||
|
||||
});
|
||||
tableDrag.children('tbody').children('tr').not('.nodrag').removeClass('alt_row').removeClass('not_alt_row');
|
||||
tableDrag.children('tbody').children('tr:not(".nodrag"):odd').addClass('alt_row');
|
||||
tableDrag.children('tbody').children('tr:not(".nodrag"):even').addClass('not_alt_row');
|
||||
tableDrag.children('tbody').children('tr').children('td.dragHandle').children('a:hidden').show();
|
||||
$(tableDrag).children('tbody').children('tr').not('.nodrag').removeClass('alt_row').removeClass('not_alt_row');
|
||||
$(tableDrag).children('tbody').children('tr:not(".nodrag"):odd').addClass('alt_row');
|
||||
$(tableDrag).children('tbody').children('tr:not(".nodrag"):even').addClass('not_alt_row');
|
||||
$(tableDrag).children('tbody').children('tr').children('td.dragHandle').children('a:hidden').show();
|
||||
|
||||
if (alternate) {
|
||||
tableDrag.children('tbody').children('tr').children('td.dragHandle:first').children('a:odd').hide();
|
||||
tableDrag.children('tbody').children('tr').children('td.dragHandle:last').children('a:even').hide();
|
||||
if (alternate) {
|
||||
$(tableDrag).children('tbody').children('tr').children('td.dragHandle:first').children('a:odd').hide();
|
||||
$(tableDrag).children('tbody').children('tr').children('td.dragHandle:last').children('a:even').hide();
|
||||
}
|
||||
else {
|
||||
tableDrag.children('tbody').children('tr').children('td.dragHandle:first').children('a:even').hide();
|
||||
tableDrag.children('tbody').children('tr').children('td.dragHandle:last').children('a:odd').hide();
|
||||
$(tableDrag).children('tbody').children('tr').children('td.dragHandle:first').children('a:even').hide();
|
||||
$(tableDrag).children('tbody').children('tr').children('td.dragHandle:last').children('a:odd').hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user