From bd81ebf4461fc9e74706d8ab4f183f40339ed729 Mon Sep 17 00:00:00 2001 From: Fabrice Creuzot Date: Wed, 16 Nov 2022 21:51:25 +0100 Subject: [PATCH 1/3] Require a parent category to add a new sub category Unselect current category when adding a new root category --- .../default/template/catalog/category/tree.phtml | 15 +++++++++++---- app/locale/en_US/Mage_Adminhtml.csv | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/design/adminhtml/default/default/template/catalog/category/tree.phtml b/app/design/adminhtml/default/default/template/catalog/category/tree.phtml index 3ce8376b9b6..79c30e13671 100644 --- a/app/design/adminhtml/default/default/template/catalog/category/tree.phtml +++ b/app/design/adminhtml/default/default/template/catalog/category/tree.phtml @@ -381,20 +381,27 @@ Ext.onReady(function() reRenderTree(); }); -function addNew(url, isRoot) +function addNew(url, isRoot, node) { if (isRoot) { + if (tree.currentNodeId && (node = tree.getNodeById(tree.currentNodeId))) { + node.unselect(); + } tree.currentNodeId = tree.root.id; } + else if (!tree.currentNodeId || (tree.currentNodeId == tree.root.id)) { + alert("jsQuoteEscape($this->__('Please select a parent category before add new one.')) ?>"); + return; + } if (/store\/\d+/.test(url)) { url = url.replace(/store\/\d+/, "store/" + tree.storeId); } - else { - url+= "store/" + tree.storeId + "/"; + else { + url += "store/" + tree.storeId + "/"; } - url+= 'parent/'+tree.currentNodeId; + url += 'parent/' + tree.currentNodeId + '/'; updateContent(url); } diff --git a/app/locale/en_US/Mage_Adminhtml.csv b/app/locale/en_US/Mage_Adminhtml.csv index e90770090c7..c5b541bac33 100644 --- a/app/locale/en_US/Mage_Adminhtml.csv +++ b/app/locale/en_US/Mage_Adminhtml.csv @@ -735,6 +735,7 @@ "Phone:","Phone:" "Please Select","Please Select" "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." +"Please select a parent category before add new one.","Please select a parent category before add new one." "Please enter 6 or more characters.","Please enter 6 or more characters." "Please enter a number greater than 0 in this field.","Please enter a number greater than 0 in this field." "Please enter a valid $ amount. For example $100.00.","Please enter a valid $ amount. For example $100.00." From 701a9754ee52554ac8e9f58a9a193c1f26da62f4 Mon Sep 17 00:00:00 2001 From: luigifab <31816829+luigifab@users.noreply.github.com> Date: Thu, 1 Dec 2022 19:31:50 +0100 Subject: [PATCH 2/3] Text update Co-authored-by: Fabrizio Balliano --- .../default/default/template/catalog/category/tree.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/design/adminhtml/default/default/template/catalog/category/tree.phtml b/app/design/adminhtml/default/default/template/catalog/category/tree.phtml index 79c30e13671..f31fbb71319 100644 --- a/app/design/adminhtml/default/default/template/catalog/category/tree.phtml +++ b/app/design/adminhtml/default/default/template/catalog/category/tree.phtml @@ -390,7 +390,7 @@ function addNew(url, isRoot, node) tree.currentNodeId = tree.root.id; } else if (!tree.currentNodeId || (tree.currentNodeId == tree.root.id)) { - alert("jsQuoteEscape($this->__('Please select a parent category before add new one.')) ?>"); + alert("jsQuoteEscape($this->__('Please select a parent category before adding a new one.')) ?>"); return; } From 8b08a5f715ea5a10e6e29b52b02581109b8abaa9 Mon Sep 17 00:00:00 2001 From: luigifab <31816829+luigifab@users.noreply.github.com> Date: Thu, 1 Dec 2022 19:31:56 +0100 Subject: [PATCH 3/3] Text update Co-authored-by: Fabrizio Balliano --- app/locale/en_US/Mage_Adminhtml.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/locale/en_US/Mage_Adminhtml.csv b/app/locale/en_US/Mage_Adminhtml.csv index c5b541bac33..64bca63fa05 100644 --- a/app/locale/en_US/Mage_Adminhtml.csv +++ b/app/locale/en_US/Mage_Adminhtml.csv @@ -735,7 +735,7 @@ "Phone:","Phone:" "Please Select","Please Select" "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." -"Please select a parent category before add new one.","Please select a parent category before add new one." +"Please select a parent category before adding a new one.","Please select a parent category before adding a new one." "Please enter 6 or more characters.","Please enter 6 or more characters." "Please enter a number greater than 0 in this field.","Please enter a number greater than 0 in this field." "Please enter a valid $ amount. For example $100.00.","Please enter a valid $ amount. For example $100.00."