diff --git a/code/GridFieldPageSectionsExtension.php b/code/GridFieldPageSectionsExtension.php index e149043..c4d0649 100644 --- a/code/GridFieldPageSectionsExtension.php +++ b/code/GridFieldPageSectionsExtension.php @@ -51,6 +51,7 @@ public function getHTMLFragments($field) { $moduleDir = self::getModuleDir(); Requirements::css($moduleDir . "/css/GridFieldPageSectionsExtension.css"); Requirements::javascript($moduleDir . "/javascript/GridFieldPageSectionsExtension.js"); + Requirements::add_i18n_javascript($moduleDir . '/javascript/lang', false, true); $id = rand(1000000, 9999999); $field->addExtraClass("ss-gridfield-pagesections"); @@ -87,8 +88,7 @@ public function augmentColumns($gridField, &$columns) { $newList = $gridField->getManipulatedList(); while (count($list) < count($newList)) { foreach ($newList as $item) { - //var_dump($item->Children());die; - if ($item->isOpenByDefault() && $item->Children()->Count) { + if ($item->isOpenByDefault() && $item->Children()->Count()) { $this->openElement($state, $item); } } @@ -185,6 +185,10 @@ public function getColumnContent($gridField, $record, $columnName) { array("element" => $record) ); $field->addExtraClass("level".$level . ($open ? " is-open" : " is-closed")); + if (!$record->Children()->Count()) { + $field->addExtraClass(" is-end"); + $field->setDisabled(true); + } $field->setButtonContent($icon); $field->setForm($gridField->getForm()); diff --git a/css/GridFieldPageSectionsExtension.css b/css/GridFieldPageSectionsExtension.css index 23cec77..6bfb42f 100644 --- a/css/GridFieldPageSectionsExtension.css +++ b/css/GridFieldPageSectionsExtension.css @@ -70,6 +70,20 @@ position: relative; } +.cms table.ss-gridfield-table tbody td.col-treenav button.ui-state-disabled { + opacity: 1; + filter: Alpha(Opacity=100); + background-image: none; + background: none; + box-shadow: none; +} + +.cms table.ss-gridfield-table tbody td.col-treenav button.ui-state-disabled:active { + border: none; + background: none; + box-shadow: none; +} + .cms table.ss-gridfield-table tbody td.col-treenav button svg { position: absolute; left: 50%; diff --git a/javascript/GridFieldPageSectionsExtension.js b/javascript/GridFieldPageSectionsExtension.js index a01ca2e..d1b2a61 100644 --- a/javascript/GridFieldPageSectionsExtension.js +++ b/javascript/GridFieldPageSectionsExtension.js @@ -69,7 +69,7 @@ } if ($parent != null) { parentId = $parent.data("id"); - parentName = $parent.find(".col-treenav > span").html(); + parentName = $parent.find(".col-treenav .col-treenav__title").html(); } } @@ -86,7 +86,7 @@ rowId: rowId, parentId: parentId, }); - $menu.append("