[API] Restrict dialog overrides

...to those domain objects which have some view for the
properties region registered.
This commit is contained in:
Victor Woeltjen
2016-07-28 16:05:02 -07:00
parent 62d90a8114
commit 14f30b2489
2 changed files with 19 additions and 11 deletions

View File

@ -1,22 +1,30 @@
define([], function () { define([], function () {
function ActionDialogDecorator(mct, actionService) { function ActionDialogDecorator(mct, newViews, actionService) {
this.actionService = actionService; this.actionService = actionService;
this.mct = mct; this.mct = mct;
this.propertiesViews = newViews.filter(function (propertiesView) {
return propertiesView.region === mct.regions.properties;
});
} }
ActionDialogDecorator.prototype.getActions = function (context) { ActionDialogDecorator.prototype.getActions = function (context) {
var mct = this.mct; var mct = this.mct;
var definitions = this.propertiesViews;
return this.actionService.getActions(context).map(function (action) { return this.actionService.getActions(context).map(function (action) {
if (action.dialogService) { if (action.dialogService) {
action.dialogService = Object.create(action.dialogService); var domainObject = context.domainObject;
action.dialogService.getUserInput = function (form, value) {
mct.dialog({ definitions = definitions.filter(function (definition) {
show: function (container) { return definition.canView(domainObject);
container.textContent = JSON.stringify(value); });
},
destroy: function () {} if (definitions.length > 0) {
}, form.title); action.dialogService = Object.create(action.dialogService);
return Promise.resolve(value); action.dialogService.getUserInput = function (form, value) {
mct.dialog(definitions[0].view(domainObject), form.title);
return Promise.resolve(value);
};
} }
} }
return action; return action;

View File

@ -48,7 +48,7 @@ define([
type: "decorator", type: "decorator",
provides: "actionService", provides: "actionService",
implementation: ActionDialogDecorator, implementation: ActionDialogDecorator,
depends: [ "mct" ] depends: [ "mct", "newViews[]" ]
} }
] ]
} }