// 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:
1 parent
eec8653b30
commit
fb474af7ec
2 files changed
+45
-45
No files matched your search
+6
-5
@@ -121,10 +121,11 @@ if (Tools::isSubmit('ajaxCategoriesPositions'))
|
|||||||
$pos = explode('_', $value);
|
$pos = explode('_', $value);
|
||||||
if ((isset($pos[1]) AND isset($pos[2])) AND ($pos[1] == $id_category_parent AND $pos[2] == $id_category_to_move))
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$category = new Category($id_category_to_move);
|
$category = new Category($id_category_to_move);
|
||||||
if (Validate::isLoadedObject($category))
|
if (Validate::isLoadedObject($category))
|
||||||
{
|
{
|
||||||
@@ -777,7 +778,7 @@ if (Tools::isSubmit('ajaxGroupsAttributesPositions'))
|
|||||||
|
|
||||||
$new_positions = array();
|
$new_positions = array();
|
||||||
foreach($positions as $k => $v)
|
foreach($positions as $k => $v)
|
||||||
if (count(explode('_', $v)) == 3)
|
if (count(explode('_', $v)) == 4)
|
||||||
$new_positions[] = $v;
|
$new_positions[] = $v;
|
||||||
|
|
||||||
foreach ($new_positions as $position => $value)
|
foreach ($new_positions as $position => $value)
|
||||||
@@ -785,11 +786,11 @@ if (Tools::isSubmit('ajaxGroupsAttributesPositions'))
|
|||||||
// pos[1] = id_attribute_group, pos[2] = old position
|
// pos[1] = id_attribute_group, pos[2] = old position
|
||||||
$pos = explode('_', $value);
|
$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))
|
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
|
else
|
||||||
echo '{"hasError" : true, "errors" : "Can not update group attribute '. (int)$id_attribute_group . ' to position '.(int)$position.' "}';
|
echo '{"hasError" : true, "errors" : "Can not update group attribute '. (int)$id_attribute_group . ' to position '.(int)$position.' "}';
|
||||||
else
|
else
|
||||||
|
|||||||
+39
-40
@@ -30,9 +30,8 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
function initTableDnD(table)
|
function initTableDnD(table)
|
||||||
{
|
{
|
||||||
if (typeof(table) == 'undefined') {
|
if (typeof(table) == 'undefined')
|
||||||
table = 'table.tableDnD';
|
table = 'table.tableDnD';
|
||||||
}
|
|
||||||
|
|
||||||
$(table).tableDnD({
|
$(table).tableDnD({
|
||||||
onDragStart: function(table, row) {
|
onDragStart: function(table, row) {
|
||||||
@@ -66,31 +65,31 @@ function initTableDnD(table)
|
|||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token
|
||||||
};
|
};
|
||||||
if (table.id == 'cms')
|
if (table.id == 'cms')
|
||||||
params = {
|
params = {
|
||||||
ajaxCMSPositions: true,
|
ajaxCMSPositions: true,
|
||||||
id_cms_category: ids[1],
|
id_cms_category: ids[1],
|
||||||
id_cms: ids[2],
|
id_cms: ids[2],
|
||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token
|
||||||
};
|
};
|
||||||
if (table.id == 'cms_block_0')
|
if (table.id == 'cms_block_0')
|
||||||
params = {
|
params = {
|
||||||
ajaxCMSBlockPositions: true,
|
ajaxCMSBlockPositions: true,
|
||||||
id_cms_block: ids[1],
|
id_cms_block: ids[1],
|
||||||
position: ids[2],
|
position: ids[2],
|
||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token
|
||||||
};
|
};
|
||||||
if (table.id == 'cms_block_1')
|
if (table.id == 'cms_block_1')
|
||||||
params = {
|
params = {
|
||||||
ajaxCMSBlockPositions: true,
|
ajaxCMSBlockPositions: true,
|
||||||
id_cms_block: ids[1],
|
id_cms_block: ids[1],
|
||||||
position: ids[2],
|
position: ids[2],
|
||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token
|
||||||
};
|
};
|
||||||
if (come_from == 'AdminModulesPositions')
|
if (come_from == 'AdminModulesPositions')
|
||||||
params = {
|
params = {
|
||||||
ajaxModulesPositions: true,
|
ajaxModulesPositions: true,
|
||||||
id_hook: ids[0],
|
id_hook: ids[0],
|
||||||
@@ -118,8 +117,8 @@ function initTableDnD(table)
|
|||||||
if (table.id.indexOf('attribute') != -1 && table.id != 'attribute_group') {
|
if (table.id.indexOf('attribute') != -1 && table.id != 'attribute_group') {
|
||||||
params = {
|
params = {
|
||||||
ajaxAttributesPositions: true,
|
ajaxAttributesPositions: true,
|
||||||
id_attribute_group: ids[1],
|
id_attribute_group: ids[2],
|
||||||
id_attribute: ids[2],
|
id_attribute: ids[3],
|
||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token
|
||||||
};
|
};
|
||||||
@@ -128,7 +127,7 @@ function initTableDnD(table)
|
|||||||
if (table.id == 'attribute_group') {
|
if (table.id == 'attribute_group') {
|
||||||
params = {
|
params = {
|
||||||
ajaxGroupsAttributesPositions: true,
|
ajaxGroupsAttributesPositions: true,
|
||||||
id_attribute_group: ids[1],
|
id_attribute_group: ids[2],
|
||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token
|
||||||
}
|
}
|
||||||
@@ -208,7 +207,7 @@ function initTableDnD(table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
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));
|
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
||||||
// Update link position
|
// Update link position
|
||||||
// Up links
|
// 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) +'&'));
|
$(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').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"):odd').addClass('alt_row');
|
||||||
tableDrag.children('tbody').children('tr:not(".nodrag"):even').addClass('not_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').children('td.dragHandle').children('a:hidden').show();
|
||||||
|
|
||||||
if (alternate) {
|
if (alternate) {
|
||||||
tableDrag.children('tbody').children('tr').children('td.dragHandle:first').children('a:odd').hide();
|
$(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();
|
$(tableDrag).children('tbody').children('tr').children('td.dragHandle:last').children('a:even').hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tableDrag.children('tbody').children('tr').children('td.dragHandle:first').children('a:even').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();
|
$(tableDrag).children('tbody').children('tr').children('td.dragHandle:last').children('a:odd').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user