mirror of
https://github.com/nasa/openmct.git
synced 2024-12-23 15:02:23 +00:00
[API] Use ViewRegistry from dialog adapter
https://github.com/nasa/openmct/pull/1212#pullrequestreview-2458991
This commit is contained in:
parent
580e10b024
commit
00d0b71080
11
src/MCT.js
11
src/MCT.js
@ -120,6 +120,17 @@ define([
|
||||
*/
|
||||
this.inspectors = new ViewRegistry();
|
||||
|
||||
/**
|
||||
* Registry for views which should appear in Edit Properties
|
||||
* dialogs, and similar user interface elements used for
|
||||
* modifying domain objects external to its regular views.
|
||||
*
|
||||
* @type {module:openmct.ViewRegistry}
|
||||
* @memberof module:openmct.MCT#
|
||||
* @name propertyEditors
|
||||
*/
|
||||
this.propertyEditors = new ViewRegistry();
|
||||
|
||||
/**
|
||||
* Registry for views which should appear in the status indicator area.
|
||||
* @type {module:openmct.ViewRegistry}
|
||||
|
@ -23,19 +23,13 @@
|
||||
define([
|
||||
'../../api/objects/object-utils'
|
||||
], function (objectUtils) {
|
||||
function ActionDialogDecorator(mct, newViews, actionService) {
|
||||
this.actionService = actionService;
|
||||
function ActionDialogDecorator(mct, actionService) {
|
||||
this.mct = mct;
|
||||
this.definitions = newViews.filter(function (newView) {
|
||||
return newView.region === mct.regions.properties;
|
||||
}).map(function (newView) {
|
||||
return newView.factory;
|
||||
});
|
||||
this.actionService = actionService;
|
||||
}
|
||||
|
||||
ActionDialogDecorator.prototype.getActions = function (context) {
|
||||
var mct = this.mct;
|
||||
var definitions = this.definitions;
|
||||
|
||||
return this.actionService.getActions(context).map(function (action) {
|
||||
if (action.dialogService) {
|
||||
@ -43,16 +37,13 @@ define([
|
||||
context.domainObject.getModel(),
|
||||
objectUtils.parseKeyString(context.domainObject.getId())
|
||||
);
|
||||
var providers = mct.propertyEditors.get(domainObject);
|
||||
|
||||
definitions = definitions.filter(function (definition) {
|
||||
return definition.canView(domainObject);
|
||||
});
|
||||
|
||||
if (definitions.length > 0) {
|
||||
if (providers.length > 0) {
|
||||
action.dialogService = Object.create(action.dialogService);
|
||||
action.dialogService.getUserInput = function (form, value) {
|
||||
return new mct.Dialog(
|
||||
definitions[0].view(context.domainObject),
|
||||
providers[0].view(context.domainObject),
|
||||
form.title
|
||||
).show();
|
||||
};
|
||||
|
@ -31,6 +31,13 @@ define([], function () {
|
||||
this.providers = [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private for platform-internal use
|
||||
* @param {*} item the object to be viewed
|
||||
* @returns {module:openmct.ViewProvider[]} any providers
|
||||
* which can provide views of this object
|
||||
*/
|
||||
ViewRegistry.prototype.get = function (item) {
|
||||
return this.providers.filter(function (provider) {
|
||||
return provider.canView(item);
|
||||
|
Loading…
Reference in New Issue
Block a user