mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 14:48:13 +00:00
[API] Restrict dialog overrides
...to those domain objects which have some view for the properties region registered.
This commit is contained in:
@ -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) {
|
||||||
|
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 = Object.create(action.dialogService);
|
||||||
action.dialogService.getUserInput = function (form, value) {
|
action.dialogService.getUserInput = function (form, value) {
|
||||||
mct.dialog({
|
mct.dialog(definitions[0].view(domainObject), form.title);
|
||||||
show: function (container) {
|
|
||||||
container.textContent = JSON.stringify(value);
|
|
||||||
},
|
|
||||||
destroy: function () {}
|
|
||||||
}, form.title);
|
|
||||||
return Promise.resolve(value);
|
return Promise.resolve(value);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
|
@ -48,7 +48,7 @@ define([
|
|||||||
type: "decorator",
|
type: "decorator",
|
||||||
provides: "actionService",
|
provides: "actionService",
|
||||||
implementation: ActionDialogDecorator,
|
implementation: ActionDialogDecorator,
|
||||||
depends: [ "mct" ]
|
depends: [ "mct", "newViews[]" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user