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("
  • Add a child
  • "); + $menu.append("
  • " + ss.i18n._t('PageSections.GridField.AddAChild','Add a child') + "
  • "); $.each(elems, function(key, value) { $menu.append("
  • " + value + "
  • "); }); diff --git a/javascript/lang/de.js b/javascript/lang/de.js new file mode 100644 index 0000000..e4908cf --- /dev/null +++ b/javascript/lang/de.js @@ -0,0 +1,9 @@ +if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') { + if (typeof(console) !== 'undefined') { // eslint-disable-line no-console + console.error('Class ss.i18n not defined'); // eslint-disable-line no-console + } +} else { + ss.i18n.addDictionary('en', { + "GridField.AddAChild": "Unterelement hinzufügen", +}); +} diff --git a/javascript/lang/en.js b/javascript/lang/en.js new file mode 100644 index 0000000..fa6f20c --- /dev/null +++ b/javascript/lang/en.js @@ -0,0 +1,9 @@ +if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') { + if (typeof(console) !== 'undefined') { // eslint-disable-line no-console + console.error('Class ss.i18n not defined'); // eslint-disable-line no-console + } +} else { + ss.i18n.addDictionary('en', { + "PageSections.GridField.AddAChild": "Add a child", +}); +}