Skip to content

Commit

Permalink
Disable menu for non configuration items
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Rossi committed Dec 24, 2015
1 parent 7abfcac commit 6ab558d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/main/webapp/resources/net/apachegui/ConfigurationTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,31 @@ define([
this.menu.bindDomNode(div);

this.menu.addChild(new MenuItem({
id: this.id + '-menu-item-expand-all',
label : "Expand All",
onClick : function() {
that.expandAll();
}
}));

this.menu.addChild(new MenuItem({
id: this.id + '-menu-item-collapse-all',
label : "Collapse All",
onClick : function() {
that.collapseAll();
}
}));

this.menu.addChild(new MenuItem({
id: this.id + '-menu-item-edit',
label : "Edit",
onClick : function() {
that._showEditLineDialog();
}
}));

this.menu.addChild(new MenuItem({
id: this.id + '-menu-item-delete',
label : "Delete",
onClick : function() {
that._deleteLine()
Expand All @@ -148,18 +152,21 @@ define([

var subMenu = new Menu();
subMenu.addChild(new MenuItem({
id: this.id + '-menu-item-add-enclosure',
label : "New Enclosure",
onClick: function() {
that._showAddLineDialog(that.LineTypes.ENCLOSURE);
}
}));
subMenu.addChild(new MenuItem({
id: this.id + '-menu-item-add-directive',
label : "New Directive",
onClick: function() {
that._showAddLineDialog(that.LineTypes.DIRECTIVE);
}
}));
this.menu.addChild(new PopupMenuItem({
id: this.id + '-menu-item-add-submenu',
label : "Add",
popup : subMenu
}));
Expand Down Expand Up @@ -535,6 +542,15 @@ define([
on(this.menu, "focus", function(e) {
var tn = registry.getEnclosingWidget(this.currentTarget);
that.currentTreeItem = tn.item;

var lineType = that._getItemProperty(that.currentTreeItem, 'lineType');
var isConfigurationItem = (lineType == that.LineTypes.ENCLOSURE || lineType == that.LineTypes.DIRECTIVE);

registry.byId(that.id + '-menu-item-edit').set('disabled', !isConfigurationItem);
registry.byId(that.id + '-menu-item-delete').set('disabled', !isConfigurationItem);
registry.byId(that.id + '-menu-item-add-enclosure').set('disabled', !isConfigurationItem);
registry.byId(that.id + '-menu-item-add-directive').set('disabled', !isConfigurationItem);

that.onMenuFocus();
});
},
Expand Down
3 changes: 1 addition & 2 deletions src/main/webapp/resources/net/apachegui/VirtualHosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ define([ "dojo/_base/declare",
"dijit/Tooltip",
"dojo/dom-attr",
"net/apachegui/ConfigurationTree",
"net/apachegui/InputAutoSuggest"
], function(declare, dom, request, registry, on, ItemFileWriteStore, DataGrid, TitlePane, RefreshableTree, Tree, ForestStoreModel, Observable, Menu, MenuItem, PopupMenuItem, Select, scroll, query, array, lang, domConstruct, Tooltip, domAttr, ConfigurationTree, InputAutoSuggest) {
], function(declare, dom, request, registry, on, ItemFileWriteStore, DataGrid, TitlePane, RefreshableTree, Tree, ForestStoreModel, Observable, Menu, MenuItem, PopupMenuItem, Select, scroll, query, array, lang, domConstruct, Tooltip, domAttr, ConfigurationTree) {

declare("net.apachegui.VirtualHosts", null, {

Expand Down

0 comments on commit 6ab558d

Please sign in to comment.