Skip to content

Commit

Permalink
feat: reorder add menu, move name and version to uses tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Severin Hauser committed Mar 27, 2023
1 parent 57dc2c3 commit 1f9cf97
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
composer.lock
resources/
resources/
.vscode
28 changes: 16 additions & 12 deletions client/javascript/TreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand All @@ -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(
Expand All @@ -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);
});

Expand Down
15 changes: 8 additions & 7 deletions src/PageElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f9cf97

Please sign in to comment.