mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
[API] Restrict dialog overrides
...to those domain objects which have some view for the properties region registered.
This commit is contained in:
parent
62d90a8114
commit
14f30b2489
@ -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;
|
||||
|
@ -48,7 +48,7 @@ define([
|
||||
type: "decorator",
|
||||
provides: "actionService",
|
||||
implementation: ActionDialogDecorator,
|
||||
depends: [ "mct" ]
|
||||
depends: [ "mct", "newViews[]" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user