mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
[API] Show a custom view in dialog
This commit is contained in:
parent
14f30b2489
commit
fe2ce91d50
@ -1,19 +1,26 @@
|
||||
define([], function () {
|
||||
define([
|
||||
'../../api/objects/object-utils'
|
||||
], function (objectUtils) {
|
||||
function ActionDialogDecorator(mct, newViews, actionService) {
|
||||
this.actionService = actionService;
|
||||
this.mct = mct;
|
||||
this.propertiesViews = newViews.filter(function (propertiesView) {
|
||||
return propertiesView.region === mct.regions.properties;
|
||||
this.definitions = newViews.filter(function (newView) {
|
||||
return newView.region === mct.regions.properties;
|
||||
}).map(function (newView) {
|
||||
return newView.factory;
|
||||
});
|
||||
}
|
||||
|
||||
ActionDialogDecorator.prototype.getActions = function (context) {
|
||||
var mct = this.mct;
|
||||
var definitions = this.propertiesViews;
|
||||
var definitions = this.definitions;
|
||||
|
||||
return this.actionService.getActions(context).map(function (action) {
|
||||
if (action.dialogService) {
|
||||
var domainObject = context.domainObject;
|
||||
var domainObject = objectUtils.toNewFormat(
|
||||
context.domainObject.getModel(),
|
||||
objectUtils.parseKeyString(context.domainObject.getId())
|
||||
);
|
||||
|
||||
definitions = definitions.filter(function (definition) {
|
||||
return definition.canView(domainObject);
|
||||
@ -22,7 +29,10 @@ define([], function () {
|
||||
if (definitions.length > 0) {
|
||||
action.dialogService = Object.create(action.dialogService);
|
||||
action.dialogService.getUserInput = function (form, value) {
|
||||
mct.dialog(definitions[0].view(domainObject), form.title);
|
||||
mct.dialog(
|
||||
definitions[0].view(context.domainObject),
|
||||
form.title
|
||||
);
|
||||
return Promise.resolve(value);
|
||||
};
|
||||
}
|
||||
|
@ -221,6 +221,13 @@ define([
|
||||
canView: todoType.check.bind(todoType)
|
||||
});
|
||||
|
||||
mct.view(mct.regions.properties, {
|
||||
view: function (domainObject) {
|
||||
return new TodoToolbarView(domainObject);
|
||||
},
|
||||
canView: todoType.check.bind(todoType)
|
||||
});
|
||||
|
||||
return mct;
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user