Skip to content

Commit 92a9e9d

Browse files
luigifabfballiano
authored andcommitted
Adminhhtml: A parent category is not required in order to add a sub category (#2716)
1 parent fafbc1b commit 92a9e9d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

app/design/adminhtml/default/default/template/catalog/category/tree.phtml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,20 +381,27 @@ Ext.onReady(function()
381381
reRenderTree();
382382
});
383383

384-
function addNew(url, isRoot)
384+
function addNew(url, isRoot, node)
385385
{
386386
if (isRoot) {
387+
if (tree.currentNodeId && (node = tree.getNodeById(tree.currentNodeId))) {
388+
node.unselect();
389+
}
387390
tree.currentNodeId = tree.root.id;
388391
}
392+
else if (!tree.currentNodeId || (tree.currentNodeId == tree.root.id)) {
393+
alert("<?php echo Mage::helper('core')->jsQuoteEscape($this->__('Please select a parent category before adding a new one.')) ?>");
394+
return;
395+
}
389396

390397
if (/store\/\d+/.test(url)) {
391398
url = url.replace(/store\/\d+/, "store/" + tree.storeId);
392399
}
393-
else {
394-
url+= "store/" + tree.storeId + "/";
400+
else {
401+
url += "store/" + tree.storeId + "/";
395402
}
396403

397-
url+= 'parent/'+tree.currentNodeId;
404+
url += 'parent/' + tree.currentNodeId + '/';
398405
updateContent(url);
399406
}
400407

app/locale/en_US/Mage_Adminhtml.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@
734734
"Phone:","Phone:"
735735
"Please Select","Please Select"
736736
"Please confirm site switching. All data that hasn't been saved will be lost.","Please confirm site switching. All data that hasn't been saved will be lost."
737+
"Please select a parent category before adding a new one.","Please select a parent category before adding a new one."
737738
"Please enter 6 or more characters.","Please enter 6 or more characters."
738739
"Please enter a number greater than 0 in this field.","Please enter a number greater than 0 in this field."
739740
"Please enter a valid $ amount. For example $100.00.","Please enter a valid $ amount. For example $100.00."

0 commit comments

Comments
 (0)