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

View File

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