Merge pull request #1537 from silverstripe-terraformers/fix/menuitems-fix

When page is disabled, rename "Edit" label in contextmenu and …
This commit is contained in:
Damian Mooyman 2016-08-02 17:01:07 +12:00 committed by GitHub
commit 48a2aecaab
3 changed files with 41 additions and 35 deletions

View File

@ -41,6 +41,7 @@ if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') {
"Tree.AddSubPage": "Add new page here", "Tree.AddSubPage": "Add new page here",
"Tree.Duplicate": "Duplicate", "Tree.Duplicate": "Duplicate",
"Tree.EditPage": "Edit", "Tree.EditPage": "Edit",
"Tree.ViewPage": "View",
"Tree.ShowAsList": "Show children as list", "Tree.ShowAsList": "Show children as list",
"Tree.ThisPageAndSubpages": "This page and subpages", "Tree.ThisPageAndSubpages": "This page and subpages",
"Tree.ThisPageOnly": "This page only", "Tree.ThisPageOnly": "This page only",
@ -50,4 +51,4 @@ if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') {
"URLSEGMENT.UpdateURL": "Update URL", "URLSEGMENT.UpdateURL": "Update URL",
"WidgetAreaEditor.TOOMANY": "Sorry, you have reached the maximum number of widgets in this area" "WidgetAreaEditor.TOOMANY": "Sorry, you have reached the maximum number of widgets in this area"
}); });
} }

View File

@ -34,6 +34,7 @@
"Tree.AddSubPage": "Add new page here", "Tree.AddSubPage": "Add new page here",
"Tree.Duplicate": "Duplicate", "Tree.Duplicate": "Duplicate",
"Tree.EditPage": "Edit", "Tree.EditPage": "Edit",
"Tree.ViewPage": "View",
"Tree.ShowAsList": "Show children as list", "Tree.ShowAsList": "Show children as list",
"Tree.ThisPageAndSubpages": "This page and subpages", "Tree.ThisPageAndSubpages": "This page and subpages",
"Tree.ThisPageOnly": "This page only", "Tree.ThisPageOnly": "This page only",

View File

@ -40,16 +40,18 @@ $.entwine('ss.tree', function($){
config.contextmenu = { config.contextmenu = {
'items': function(node) { 'items': function(node) {
var menuitems = { var menuitems = {
'edit': { edit: {
'label': i18n._t('Tree.EditPage', 'Edit page', 100, 'Used in the context menu when right-clicking on a page node in the CMS tree'), 'label': (node.hasClass('edit-disabled')) ?
'action': function(obj) { i18n._t('Tree.EditPage', 'Edit page', 100, 'Used in the context menu when right-clicking on a page node in the CMS tree')
$('.cms-container').entwine('.ss').loadPanel(i18n.sprintf( : i18n._t('Tree.ViewPage', 'View page', 100, 'Used in the context menu when right-clicking on a page node in the CMS tree'),
self.data('urlEditpage'), obj.data('id') 'action': function(obj) {
)); $('.cms-container').entwine('.ss').loadPanel(i18n.sprintf(
} self.data('urlEditpage'), obj.data('id')
));
} }
}; }
};
// Add "show as list" // Add "show as list"
if(!node.hasClass('nochildren')) { if(!node.hasClass('nochildren')) {
@ -97,32 +99,34 @@ $.entwine('ss.tree', function($){
}; };
} }
menuitems['duplicate'] = { if (!node.hasClass('edit-disabled')) {
'label': i18n._t('Tree.Duplicate'), menuitems['duplicate'] = {
'submenu': [ 'label': i18n._t('Tree.Duplicate'),
{ 'submenu': [
'label': i18n._t('Tree.ThisPageOnly'), {
'action': function(obj) { 'label': i18n._t('Tree.ThisPageOnly'),
$('.cms-container').entwine('.ss').loadPanel( 'action': function (obj) {
$.path.addSearchParams( $('.cms-container').entwine('.ss').loadPanel(
i18n.sprintf(self.data('urlDuplicate'), obj.data('id')), $.path.addSearchParams(
self.data('extraParams') i18n.sprintf(self.data('urlDuplicate'), obj.data('id')),
) self.data('extraParams')
); )
);
}
}, {
'label': i18n._t('Tree.ThisPageAndSubpages'),
'action': function (obj) {
$('.cms-container').entwine('.ss').loadPanel(
$.path.addSearchParams(
i18n.sprintf(self.data('urlDuplicatewithchildren'), obj.data('id')),
self.data('extraParams')
)
);
}
} }
},{ ]
'label': i18n._t('Tree.ThisPageAndSubpages'), };
'action': function(obj) { }
$('.cms-container').entwine('.ss').loadPanel(
$.path.addSearchParams(
i18n.sprintf(self.data('urlDuplicatewithchildren'), obj.data('id')),
self.data('extraParams')
)
);
}
}
]
};
return menuitems; return menuitems;
} }