[API] Override dialogService in actions

An ugly hack to allow dialogs to be shown for Save As
and Edit Properties, without requiring form generation.
This will permit views to be shown instead in certain
cases, https://github.com/nasa/openmct/pull/999#issuecomment-236045158
This commit is contained in:
Victor Woeltjen 2016-07-28 15:48:28 -07:00
parent bfdbc71e40
commit 1d31fe8d02
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,20 @@
define([], function () {
function ActionDialogDecorator(actionService) {
this.actionService = actionService;
}
ActionDialogDecorator.prototype.getActions = function (context) {
return this.actionService.getActions(context).map(function (action) {
if (action.dialogService) {
action.dialogService = Object.create(action.dialogService);
action.dialogService.getUserInput = function (form, value) {
window.alert("Get user input!");
return Promise.resolve(value);
}
}
return action;
});
};
return ActionDialogDecorator;
});

View File

@ -1,10 +1,12 @@
define([
'legacyRegistry',
'./actions/ActionDialogDecorator',
'./directives/MCTView',
'./services/Instantiate',
'./capabilities/APICapabilityDecorator'
], function (
legacyRegistry,
ActionDialogDecorator,
MCTView,
Instantiate,
APICapabilityDecorator
@ -41,6 +43,11 @@ define([
depends: [
"$injector"
]
},
{
type: "decorator",
provides: "actionService",
implementation: ActionDialogDecorator
}
]
}