From 6c797000c5ff63d9b4d563639a94e831cf0ebcd8 Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Wed, 22 Aug 2018 10:19:03 -0700 Subject: [PATCH 1/9] Adding MenuItem import and export and extracting GridFieldConfig --- code/MenuAdminSquared.php | 57 ++++++++++++++++++++++--- code/MenuItemSquared.php | 53 ++++++++++++++++------- code/MenuItemSquaredGridFieldConfig.php | 24 +++++++++++ code/MenuItem_Separator.php | 8 ++-- code/MenuSetSquared.php | 24 +++++------ composer.json | 5 +-- 6 files changed, 132 insertions(+), 39 deletions(-) create mode 100644 code/MenuItemSquaredGridFieldConfig.php diff --git a/code/MenuAdminSquared.php b/code/MenuAdminSquared.php index c905862..a11cb47 100644 --- a/code/MenuAdminSquared.php +++ b/code/MenuAdminSquared.php @@ -1,17 +1,64 @@ 'CsvBulkLoader', + ]; + private static $managed_models = [ + 'MenuItem', + ]; + + /** + * @param CMSForm $form + */ public function updateEditForm(CMSForm $form) { $fields = $form->Fields(); - $MenuSet = $fields->dataFieldByName('MenuSet'); + $menuSet = $fields->dataFieldByName('MenuSet'); + + if ($menuSet instanceof GridField) { + $menuSet->setTitle('Menus'); + $config = $menuSet->getConfig(); + + $config->removeComponentsByType('GridFieldExportButton'); + $config->removeComponentsByType('GridFieldPrintButton'); - if ($MenuSet instanceof GridField) { - $MenuSetConfig = $MenuSet->getConfig(); - $MenuSetConfig->removeComponentsByType('GridFieldAddNewButton'); + // Only remove add button if set by config. + if (!empty(MenuSet::config()->get('default_sets'))) { + $config->removeComponentsByType('GridFieldAddNewButton'); + } } - } + $menuItems = $fields->dataFieldByName('MenuItem'); + if ($menuItems instanceof GridField) { + $menuItems->setTitle('Items'); + $config = new MenuItemSquaredGridFieldConfig(); + $menuItems->setConfig($config); + + $config->removeComponentsByType('GridFieldAddNewMultiClass'); + + $export = new GridFieldExportButton('buttons-before-left'); + $config->addComponent($export); + + $export->setExportColumns([ + 'ID' => 'ID', + 'ClassName' => 'ClassName', + 'MenuTitle' => 'MenuTitle', + 'Link' => 'Link', + 'Sort' => 'Sort', + 'IsNewWindow' => 'IsNewWindow', + 'Name' => 'Name', + 'PageID' => 'PageID', + 'ImageID' => 'ImageID', + 'ParentItemID' => 'ParentItemID', + ]); + } + } } diff --git a/code/MenuItemSquared.php b/code/MenuItemSquared.php index 71d35da..468ccbf 100644 --- a/code/MenuItemSquared.php +++ b/code/MenuItemSquared.php @@ -1,8 +1,12 @@ 'Varchar(255)', ]; @@ -16,6 +20,16 @@ class MenuItemSquared extends DataExtension 'ChildItems' => 'MenuItem', ]; + private static $summary_fields = [ + 'MenuTitle' => 'Title', + 'Page.Title' => 'Page Title', + 'Link' => 'Link', + 'IsNewWindow' => 'Open in New Window', + ]; + + /** + * @param FieldList $fields + */ public function updateCMSFields(FieldList $fields) { if (!$this->owner->config()->disable_image) { @@ -25,16 +39,17 @@ public function updateCMSFields(FieldList $fields) if (!$this->owner->config()->disable_hierarchy) { if ($this->owner->ID != null) { $AllParentItems = $this->owner->getAllParentItems(); - $TopMenuSet = $this->owner->TopMenuSet(); + $topMenuSet = $this->owner->TopMenuSet(); + $topMenuName = $topMenuSet->Name; + + $config = MenuSet::config(); $depth = 1; + if (is_array($config->$topMenuName) && isset($config->{$topMenuName}['depth'])) { + $depth = $config->{$topMenuName}['depth']; + } - if ( - is_array(MenuSet::config()->{$TopMenuSet->Name}) && - isset(MenuSet::config()->{$TopMenuSet->Name}['depth']) && - is_numeric(MenuSet::config()->{$TopMenuSet->Name}['depth']) && - MenuSet::config()->{$TopMenuSet->Name}['depth'] >= 0 - ) { - $depth = MenuSet::config()->{$TopMenuSet->Name}['depth']; + if (!is_numeric($depth) || $depth < 0) { + $depth = 1; } if (!empty($AllParentItems) && count($AllParentItems) >= $depth) { @@ -45,15 +60,9 @@ public function updateCMSFields(FieldList $fields) 'MenuItems', 'Sub Menu Items', $this->owner->ChildItems(), - $config = GridFieldConfig_RecordEditor::create() + new MenuItemSquaredGridFieldConfig() ) ); - $config->addComponent(new GridFieldOrderableRows('Sort')); - $config->removeComponentsByType('GridFieldAddNewButton'); - $multiClass = new GridFieldAddNewMultiClass(); - $classes = ClassInfo::subclassesFor('MenuItem'); - $multiClass->setClasses($classes); - $config->addComponent($multiClass); } } else { $fields->push(new LabelField('MenuItems', 'Save This Menu Item Before Adding Sub Menu Items')); @@ -61,15 +70,22 @@ public function updateCMSFields(FieldList $fields) } } + /** + * @return mixed + */ public function TopMenuSet() { $AllParentItems = $this->owner->getAllParentItems(); if (!empty($AllParentItems)) { return end($AllParentItems)->MenuSet(); } + return $this->owner->MenuSet(); } + /** + * @return array + */ public function getAllParentItems() { $WorkingItem = $this->owner; @@ -79,6 +95,7 @@ public function getAllParentItems() $ParentItems[$WorkingItem->ID] = $WorkingItem->ParentItem(); $WorkingItem = $ParentItems[$WorkingItem->ID]; } + return $ParentItems; } @@ -101,9 +118,13 @@ public function onBeforeDelete() parent::onBeforeDelete(); } + /** + * @return string + */ public static function get_user_friendly_name() { $title = Config::inst()->get(get_called_class(), 'user_friendly_title'); + return $title ?: FormField::name_to_label(get_called_class()); } } diff --git a/code/MenuItemSquaredGridFieldConfig.php b/code/MenuItemSquaredGridFieldConfig.php new file mode 100644 index 0000000..b5f1ea7 --- /dev/null +++ b/code/MenuItemSquaredGridFieldConfig.php @@ -0,0 +1,24 @@ +removeComponentsByType('GridFieldAddNewButton'); + + $this->addComponent(new GridFieldOrderableRows('Sort')); + $multiClass = new GridFieldAddNewMultiClass(); + $classes = ClassInfo::subclassesFor('MenuItem'); + $multiClass->setClasses($classes); + + $this->addComponent($multiClass); + } +} diff --git a/code/MenuItem_Separator.php b/code/MenuItem_Separator.php index bcf31b4..3353f3e 100644 --- a/code/MenuItem_Separator.php +++ b/code/MenuItem_Separator.php @@ -1,12 +1,13 @@ Link = ''; $this->IsNewWindow = 0; - $this->PageID = 0; + $this->PageID = 0; $this->ImageID = 0; } - } diff --git a/code/MenuSetSquared.php b/code/MenuSetSquared.php index b018eda..e09a674 100644 --- a/code/MenuSetSquared.php +++ b/code/MenuSetSquared.php @@ -1,25 +1,25 @@ dataFieldByName('MenuItems'); if ($menuItem instanceof GridField) { - $menuItemConfig = $menuItem->getConfig(); - $menuItemConfig->removeComponentsByType('GridFieldAddNewButton'); - - $multiClass = new GridFieldAddNewMultiClass(); - $classes = ClassInfo::subclassesFor('MenuItem'); - - $multiClass->setClasses($classes); - $menuItemConfig->addComponent($multiClass); - - $menuItemConfig->removeComponentsByType('GridFieldDeleteAction'); - $menuItemConfig->addComponent(new GridFieldDeleteAction()); + $menuItem->setConfig(new MenuItemSquaredGridFieldConfig()); } } - } diff --git a/composer.json b/composer.json index cd52c8a..4086334 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "marketo/silverstripe-menumanager-squared", "description": "SilverStripe MenuManager Squared", "type": "silverstripe-module", - "keywords": ["silverstripe", "members", "default"], + "keywords": ["silverstripe", "menu", "manager"], "require": { "silverstripe/framework": "3.*", "composer/installers": "*", @@ -21,6 +21,5 @@ "name": "Brandon J. Marshall", "email": "bmarshall@marketo.com" } - ], - "minimum-stability": "dev" + ] } From 0245ce71e89d0388b7445ed35d1b2c728012b5e5 Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Thu, 23 Aug 2018 13:13:18 -0700 Subject: [PATCH 2/9] Fixing missing MenuSetID on export --- code/MenuAdminSquared.php | 1 + 1 file changed, 1 insertion(+) diff --git a/code/MenuAdminSquared.php b/code/MenuAdminSquared.php index a11cb47..a7f566e 100644 --- a/code/MenuAdminSquared.php +++ b/code/MenuAdminSquared.php @@ -56,6 +56,7 @@ public function updateEditForm(CMSForm $form) 'IsNewWindow' => 'IsNewWindow', 'Name' => 'Name', 'PageID' => 'PageID', + 'MenuSetID' => 'MenuSetID', 'ImageID' => 'ImageID', 'ParentItemID' => 'ParentItemID', ]); From d87369bc0ba2bee4e2f5b0e7005470c2f4b817b1 Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Wed, 29 Aug 2018 09:52:00 -0700 Subject: [PATCH 3/9] Keeping gridfield to manage items beyond max depth --- code/MenuItemSquared.php | 69 +++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/code/MenuItemSquared.php b/code/MenuItemSquared.php index 468ccbf..50eb207 100644 --- a/code/MenuItemSquared.php +++ b/code/MenuItemSquared.php @@ -3,6 +3,8 @@ /** * Class MenuItemSquared * + * @method HasManyList ChildItems + * @method MenuItem ParentItem * @see MenuItem */ class MenuItemSquared extends DataExtension @@ -32,38 +34,40 @@ class MenuItemSquared extends DataExtension */ public function updateCMSFields(FieldList $fields) { - if (!$this->owner->config()->disable_image) { + /** @var MenuItem|MenuItemSquared $owner */ + $owner = $this->owner; + if (!$owner->config()->disable_image) { $fields->push(new UploadField('Image', 'Image')); } - if (!$this->owner->config()->disable_hierarchy) { - if ($this->owner->ID != null) { - $AllParentItems = $this->owner->getAllParentItems(); - $topMenuSet = $this->owner->TopMenuSet(); + if (!$owner->config()->disable_hierarchy) { + if ($owner->ID != null) { + $ascendants = $owner->getAllParentItems(); + $topMenuSet = $owner->TopMenuSet(); $topMenuName = $topMenuSet->Name; $config = MenuSet::config(); - $depth = 1; + $maxDepth = 1; if (is_array($config->$topMenuName) && isset($config->{$topMenuName}['depth'])) { - $depth = $config->{$topMenuName}['depth']; + $maxDepth = $config->{$topMenuName}['depth']; } - if (!is_numeric($depth) || $depth < 0) { - $depth = 1; + if (!is_numeric($maxDepth) || $maxDepth < 0) { + $maxDepth = 1; } - if (!empty($AllParentItems) && count($AllParentItems) >= $depth) { - $fields->push(new LabelField('MenuItems', 'Max Sub Menu Depth Limit')); - } else { - $fields->push( - new GridField( - 'MenuItems', - 'Sub Menu Items', - $this->owner->ChildItems(), - new MenuItemSquaredGridFieldConfig() - ) - ); + $gridFieldConfig = new MenuItemSquaredGridFieldConfig(); + if (count($ascendants) >= $maxDepth) { + $fields->push(new LabelField('MenuItems', 'Max Depth Limit Reached, Update Config to Add Sub Menu Items')); + $gridFieldConfig->removeComponentsByType(GridFieldAddNewMultiClass::class); } + // Keep GridField in case of import or max depth changed. + $fields->push(new GridField( + 'MenuItems', + 'Sub Menu Items', + $owner->ChildItems(), + $gridFieldConfig + )); } else { $fields->push(new LabelField('MenuItems', 'Save This Menu Item Before Adding Sub Menu Items')); } @@ -71,32 +75,36 @@ public function updateCMSFields(FieldList $fields) } /** - * @return mixed + * @return MenuSet */ public function TopMenuSet() { - $AllParentItems = $this->owner->getAllParentItems(); - if (!empty($AllParentItems)) { - return end($AllParentItems)->MenuSet(); + $ascendants = $this->owner->getAllParentItems(); + if (!empty($ascendants)) { + return end($ascendants)->MenuSet(); } return $this->owner->MenuSet(); } /** + * Create a key value pair of ChildID => Parent relationships. + * Starts with itself, stops at circular relationships. + * * @return array */ public function getAllParentItems() { - $WorkingItem = $this->owner; - $ParentItems = []; + /** @var MenuItem|MenuItemSquared $current */ + $current = $this->owner; + $parents = []; - while ($WorkingItem->ParentItemID && $WorkingItem->ParentItem() && $WorkingItem->ParentItem()->ID && !isset($ParentItems[$WorkingItem->ParentItem()->ID])) { - $ParentItems[$WorkingItem->ID] = $WorkingItem->ParentItem(); - $WorkingItem = $ParentItems[$WorkingItem->ID]; + while ($current->ParentItemID && $current->ParentItem() && $current->ParentItem()->ID && !isset($parents[$current->ParentItem()->ID])) { + $parents[$current->ID] = $current->ParentItem(); + $current = $parents[$current->ID]; } - return $ParentItems; + return $parents; } public function onBeforeWrite() @@ -112,6 +120,7 @@ public function onBeforeWrite() public function onBeforeDelete() { + /** @var MenuItem $childItem */ foreach ($this->owner->ChildItems() as $childItem) { $childItem->delete(); } From 3827c82a410b6591a40f2af7815018b785399a2f Mon Sep 17 00:00:00 2001 From: Mark Anthony Adriano Date: Fri, 20 Mar 2020 12:44:26 +1300 Subject: [PATCH 4/9] Upgrade to work on SS4 --- code/MenuAdminSquared.php | 11 +++- code/MenuItemSquared.php | 23 ++++++-- code/MenuItemSquaredGridFieldConfig.php | 7 +++ code/MenuItem_Separator.php | 73 +++++++------------------ code/MenuSetSquared.php | 7 +++ composer.json | 26 +++++++-- 6 files changed, 84 insertions(+), 63 deletions(-) diff --git a/code/MenuAdminSquared.php b/code/MenuAdminSquared.php index a7f566e..b47ed47 100644 --- a/code/MenuAdminSquared.php +++ b/code/MenuAdminSquared.php @@ -1,4 +1,13 @@ Fields(); $menuSet = $fields->dataFieldByName('MenuSet'); diff --git a/code/MenuItemSquared.php b/code/MenuItemSquared.php index 50eb207..64ddfa2 100644 --- a/code/MenuItemSquared.php +++ b/code/MenuItemSquared.php @@ -1,5 +1,20 @@ 'Image', - 'ParentItem' => 'MenuItem', + 'Image' => Image::class, + 'ParentItem' => MenuItem::class, ]; private static $has_many = [ - 'ChildItems' => 'MenuItem', + 'ChildItems' => MenuItem::class, ]; private static $summary_fields = [ @@ -65,7 +80,7 @@ public function updateCMSFields(FieldList $fields) $fields->push(new GridField( 'MenuItems', 'Sub Menu Items', - $owner->ChildItems(), + $this->owner->ChildItems(), $gridFieldConfig )); } else { diff --git a/code/MenuItemSquaredGridFieldConfig.php b/code/MenuItemSquaredGridFieldConfig.php index b5f1ea7..b52d62c 100644 --- a/code/MenuItemSquaredGridFieldConfig.php +++ b/code/MenuItemSquaredGridFieldConfig.php @@ -1,5 +1,12 @@ isInDB() ? 'This separator has already been created.' : 'Press "create" to add a new separator.'; - - $fields->push( - new HeaderField('NothingToDo', $message) - ); - - $this->extend('updateCMSFields', $fields); - - return $fields; - } - - /** - * Checks to see if a page has been chosen and if so sets Link to null - * This means that used in conjunction with the __get method above - * calling $menuItem->Link won't return the Link field of this MenuItem - * but rather call the Link method on the associated Page - */ - public function onBeforeWrite() - { - parent::onBeforeWrite(); - - $this->MenuTitle = '— Separator —'; - $this->Link = ''; - $this->IsNewWindow = 0; + $menuItem = $fields->dataFieldByName('MenuItems'); - $this->PageID = 0; - $this->ImageID = 0; + if ($menuItem instanceof GridField) { + $menuItem->setConfig(new MenuItemSquaredGridFieldConfig()); + } } } diff --git a/code/MenuSetSquared.php b/code/MenuSetSquared.php index e09a674..88893e9 100644 --- a/code/MenuSetSquared.php +++ b/code/MenuSetSquared.php @@ -1,5 +1,12 @@ Date: Fri, 20 Mar 2020 20:08:05 +1300 Subject: [PATCH 5/9] remove composer/installers --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index f7dd77b..01d784a 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,6 @@ "manager" ], "require": { - "composer/installers": "*", "silverstripe/framework": "^4.5", "heyday/silverstripe-menumanager": "^3.0" }, From 33fd5dfa2ff714b21580eb663cf403094448db3c Mon Sep 17 00:00:00 2001 From: Mark Anthony Adriano Date: Fri, 20 Mar 2020 20:31:31 +1300 Subject: [PATCH 6/9] update namespace --- code/MenuAdminSquared.php | 70 +++++------------------ code/MenuItemSeparator.php | 74 +++++++++++++++++++++++++ code/MenuItemSquared.php | 4 +- code/MenuItemSquaredGridFieldConfig.php | 2 +- code/MenuItem_Separator.php | 32 ----------- code/MenuSetSquared.php | 4 +- composer.json | 12 ++-- 7 files changed, 101 insertions(+), 97 deletions(-) create mode 100644 code/MenuItemSeparator.php delete mode 100644 code/MenuItem_Separator.php diff --git a/code/MenuAdminSquared.php b/code/MenuAdminSquared.php index b47ed47..6f44896 100644 --- a/code/MenuAdminSquared.php +++ b/code/MenuAdminSquared.php @@ -1,74 +1,32 @@ 'CsvBulkLoader', - ]; + private static $singular_name = 'Menu'; - private static $managed_models = [ - 'MenuItem', - ]; + private static $plural_name = 'Menus'; /** - * @param CMSForm $form + * @param FieldList $fields */ - public function updateEditForm(Form $form) + public function updateCMSFields(FieldList $fields) { - $fields = $form->Fields(); - $menuSet = $fields->dataFieldByName('MenuSet'); - - if ($menuSet instanceof GridField) { - $menuSet->setTitle('Menus'); - $config = $menuSet->getConfig(); - - $config->removeComponentsByType('GridFieldExportButton'); - $config->removeComponentsByType('GridFieldPrintButton'); - - // Only remove add button if set by config. - if (!empty(MenuSet::config()->get('default_sets'))) { - $config->removeComponentsByType('GridFieldAddNewButton'); - } - } - - $menuItems = $fields->dataFieldByName('MenuItem'); - if ($menuItems instanceof GridField) { - $menuItems->setTitle('Items'); - $config = new MenuItemSquaredGridFieldConfig(); - $menuItems->setConfig($config); - - $config->removeComponentsByType('GridFieldAddNewMultiClass'); - - $export = new GridFieldExportButton('buttons-before-left'); - $config->addComponent($export); + $menuItem = $fields->dataFieldByName('MenuItems'); - $export->setExportColumns([ - 'ID' => 'ID', - 'ClassName' => 'ClassName', - 'MenuTitle' => 'MenuTitle', - 'Link' => 'Link', - 'Sort' => 'Sort', - 'IsNewWindow' => 'IsNewWindow', - 'Name' => 'Name', - 'PageID' => 'PageID', - 'MenuSetID' => 'MenuSetID', - 'ImageID' => 'ImageID', - 'ParentItemID' => 'ParentItemID', - ]); + if ($menuItem instanceof GridField) { + $menuItem->setConfig(new MenuItemSquaredGridFieldConfig()); } } } diff --git a/code/MenuItemSeparator.php b/code/MenuItemSeparator.php new file mode 100644 index 0000000..0155d8c --- /dev/null +++ b/code/MenuItemSeparator.php @@ -0,0 +1,74 @@ +isInDB() ? 'This separator has already been created.' : 'Press "create" to add a new separator.'; + + $fields->push( + new HeaderField('NothingToDo', $message) + ); + + $this->extend('updateCMSFields', $fields); + + return $fields; + } + + /** + * Checks to see if a page has been chosen and if so sets Link to null + * This means that used in conjunction with the __get method above + * calling $menuItem->Link won't return the Link field of this MenuItem + * but rather call the Link method on the associated Page + */ + public function onBeforeWrite() + { + parent::onBeforeWrite(); + + $this->MenuTitle = '— Separator —'; + $this->Link = ''; + $this->IsNewWindow = 0; + + $this->PageID = 0; + $this->ImageID = 0; + } +} diff --git a/code/MenuItemSquared.php b/code/MenuItemSquared.php index 64ddfa2..b53883e 100644 --- a/code/MenuItemSquared.php +++ b/code/MenuItemSquared.php @@ -1,6 +1,6 @@ dataFieldByName('MenuItems'); - - if ($menuItem instanceof GridField) { - $menuItem->setConfig(new MenuItemSquaredGridFieldConfig()); - } - } -} diff --git a/code/MenuSetSquared.php b/code/MenuSetSquared.php index 88893e9..6f44896 100644 --- a/code/MenuSetSquared.php +++ b/code/MenuSetSquared.php @@ -1,11 +1,11 @@ Date: Fri, 20 Mar 2020 20:39:10 +1300 Subject: [PATCH 7/9] Revert code (weird) --- code/MenuAdminSquared.php | 64 ++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/code/MenuAdminSquared.php b/code/MenuAdminSquared.php index 6f44896..67692bd 100644 --- a/code/MenuAdminSquared.php +++ b/code/MenuAdminSquared.php @@ -2,31 +2,73 @@ namespace Marketo\Heyday; -use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\Form; +use Heyday\MenuManager\MenuSet; use SilverStripe\ORM\DataExtension; use SilverStripe\Forms\GridField\GridField; use Marketo\Heyday\MenuItemSquaredGridFieldConfig; +use SilverStripe\Forms\GridField\GridFieldExportButton; /** - * Class MenuSetSquared + * Class MenuAdminSquared * - * @see MenuSet + * @see MenuAdmin */ -class MenuSetSquared extends DataExtension +class MenuAdminSquared extends DataExtension { - private static $singular_name = 'Menu'; + private static $model_importers = [ + 'MenuItem' => 'CsvBulkLoader', + ]; - private static $plural_name = 'Menus'; + private static $managed_models = [ + 'MenuItem', + ]; /** - * @param FieldList $fields + * @param CMSForm $form */ - public function updateCMSFields(FieldList $fields) + public function updateEditForm(Form $form) { - $menuItem = $fields->dataFieldByName('MenuItems'); + $fields = $form->Fields(); + $menuSet = $fields->dataFieldByName('MenuSet'); - if ($menuItem instanceof GridField) { - $menuItem->setConfig(new MenuItemSquaredGridFieldConfig()); + if ($menuSet instanceof GridField) { + $menuSet->setTitle('Menus'); + $config = $menuSet->getConfig(); + + $config->removeComponentsByType('GridFieldExportButton'); + $config->removeComponentsByType('GridFieldPrintButton'); + + // Only remove add button if set by config. + if (!empty(MenuSet::config()->get('default_sets'))) { + $config->removeComponentsByType('GridFieldAddNewButton'); + } + } + + $menuItems = $fields->dataFieldByName('MenuItem'); + if ($menuItems instanceof GridField) { + $menuItems->setTitle('Items'); + $config = new MenuItemSquaredGridFieldConfig(); + $menuItems->setConfig($config); + + $config->removeComponentsByType('GridFieldAddNewMultiClass'); + + $export = new GridFieldExportButton('buttons-before-left'); + $config->addComponent($export); + + $export->setExportColumns([ + 'ID' => 'ID', + 'ClassName' => 'ClassName', + 'MenuTitle' => 'MenuTitle', + 'Link' => 'Link', + 'Sort' => 'Sort', + 'IsNewWindow' => 'IsNewWindow', + 'Name' => 'Name', + 'PageID' => 'PageID', + 'MenuSetID' => 'MenuSetID', + 'ImageID' => 'ImageID', + 'ParentItemID' => 'ParentItemID', + ]); } } } From 4778185cbc955cdadfea64b429596b827cd58bb1 Mon Sep 17 00:00:00 2001 From: Mark Anthony Adriano Date: Fri, 20 Mar 2020 21:24:36 +1300 Subject: [PATCH 8/9] update yml with namespace --- _config/project.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_config/project.yml b/_config/project.yml index b4bfd6f..63a35ef 100644 --- a/_config/project.yml +++ b/_config/project.yml @@ -1,11 +1,11 @@ -MenuItem: +Heyday\MenuManager\MenuItem: extensions: - - MenuItemSquared + - Marketo\Heyday\MenuItemSquared -MenuAdmin: +Heyday\MenuManager\MenuAdmin: extensions: - - MenuAdminSquared + - Marketo\Heyday\MenuSetSquared -MenuSet: +Heyday\MenuManager\MenuSet: extensions: - - MenuSetSquared \ No newline at end of file + - Marketo\Heyday\MenuSetSquared From e988928e89c068fbdedc08877f7e96e435d9cdda Mon Sep 17 00:00:00 2001 From: Mark Anthony Adriano Date: Fri, 20 Mar 2020 22:34:42 +1300 Subject: [PATCH 9/9] Fix 2 column isNewWindow --- code/MenuItemSquared.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/MenuItemSquared.php b/code/MenuItemSquared.php index b53883e..7da6352 100644 --- a/code/MenuItemSquared.php +++ b/code/MenuItemSquared.php @@ -41,9 +41,14 @@ class MenuItemSquared extends DataExtension 'MenuTitle' => 'Title', 'Page.Title' => 'Page Title', 'Link' => 'Link', - 'IsNewWindow' => 'Open in New Window', + 'IsNewWindowNice' => 'Opens in New Window', ]; + public function IsNewWindowNice() + { + return $this->IsNewWindow ? 'Yes' : 'No'; + } + /** * @param FieldList $fields */