From 1f9cf97a12fe595cad6495dc4c77ad962c23b31e Mon Sep 17 00:00:00 2001 From: Severin Hauser Date: Mon, 27 Mar 2023 17:50:18 +0200 Subject: [PATCH] feat: reorder add menu, move name and version to uses tab --- .gitignore | 3 ++- client/javascript/TreeView.js | 28 ++++++++++++++++------------ src/PageElement.php | 15 ++++++++------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 3698562..e3bb871 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor/ composer.lock -resources/ \ No newline at end of file +resources/ +.vscode \ No newline at end of file diff --git a/client/javascript/TreeView.js b/client/javascript/TreeView.js index a318ef1..c231728 100644 --- a/client/javascript/TreeView.js +++ b/client/javascript/TreeView.js @@ -351,16 +351,16 @@ menu.addLabel( ss.i18n._t('PageSections.TreeView.AddAChild', 'Add a child') ); - menu.addAddExistingButton(ss.i18n._t('PageSection.TreeView.FindExisting', 'Find existing'), function() { - showFindExistingDialog([], null, 1); - menu.remove(); - }); $.each(elems, function(key, value) { menu.addItem(key, value, function() { $treeView.addItem([], null, key, 1); menu.remove(); }); }); + menu.addAddExistingButton(ss.i18n._t('PageSection.TreeView.FindExisting', 'Find existing'), function() { + showFindExistingDialog([], null, 1); + menu.remove(); + }); menu.show(event.pageX, event.pageY); }); @@ -436,16 +436,16 @@ menu.addLabel( ss.i18n._t('PageSections.TreeView.AddAChild', 'Add a child') ); - menu.addAddExistingButton(ss.i18n._t('PageSection.TreeView.FindExisting', 'Find existing'), function() { - showFindExistingDialog(parents, itemId, 1); - menu.remove(); - }); $.each(elems, function(key, value) { menu.addItem(key, value, function() { $treeView.addItem(parents, itemId, key, 1); menu.remove(); }); }); + menu.addAddExistingButton(ss.i18n._t('PageSection.TreeView.FindExisting', 'Find existing'), function() { + showFindExistingDialog(parents, itemId, 1); + menu.remove(); + }); menu.show(event.pageX, event.pageY); }); @@ -467,10 +467,6 @@ 'Add new element' ) ); - menu.addAddExistingButton(ss.i18n._t('PageSection.TreeView.FindExisting', 'Find existing'), function() { - showFindExistingDialog(parents.slice(0, parents.length - 1), parents[parents.length - 1], $item.data('sort') + 1); - menu.remove(); - }); $.each(elems, function(key, value) { menu.addItem(key, value, function() { $treeView.addItem( @@ -482,6 +478,14 @@ menu.remove(); }); }); + menu.addAddExistingButton(ss.i18n._t('PageSection.TreeView.FindExisting', 'Find existing'), function() { + showFindExistingDialog( + parents.slice(0, parents.length - 1), + parents[parents.length - 1], + $item.data('sort') + 1 + ); + menu.remove(); + }); menu.show(event.pageX, event.pageY); }); diff --git a/src/PageElement.php b/src/PageElement.php index 19bb5dd..2b0a4d0 100755 --- a/src/PageElement.php +++ b/src/PageElement.php @@ -8,6 +8,7 @@ use SilverStripe\Forms\GridField\GridFieldConfig_Base; use SilverStripe\Forms\GridField\GridFieldDataColumns; use SilverStripe\Forms\ReadonlyField; +use SilverStripe\Forms\TextField; use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\DataObject; use SilverStripe\Versioned\Versioned; @@ -228,18 +229,18 @@ public function getAllUses() public function getCMSFields() { $fields = parent::getCMSFields(); - $fields->removeByName('Pages'); - $fields->removeByName('Parents'); - $fields->removeByName("PageSections"); - $fields->removeByName('__Counter'); + $fields->removeByName(["Name", "Pages", "Parents", "PageSections", "__Counter"]); $fields->removeByName("Children"); // Add our newest version as a readonly field $fields->addFieldsToTab( - "Root.Main", - ReadonlyField::create("Version", "Version", $this->Version), - "Title" + "Root.Uses", + [ + TextField::create("Name", "Name", $this->Name), + ReadonlyField::create("Version", "Version", $this->Version), + ], + "Uses" ); // Create an array of all places this PageElement is shown