mirror of
https://github.com/nasa/openmct.git
synced 2025-01-11 15:32:56 +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();
|
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.
|
* Registry for views which should appear in the status indicator area.
|
||||||
* @type {module:openmct.ViewRegistry}
|
* @type {module:openmct.ViewRegistry}
|
||||||
|
@ -23,19 +23,13 @@
|
|||||||
define([
|
define([
|
||||||
'../../api/objects/object-utils'
|
'../../api/objects/object-utils'
|
||||||
], function (objectUtils) {
|
], function (objectUtils) {
|
||||||
function ActionDialogDecorator(mct, newViews, actionService) {
|
function ActionDialogDecorator(mct, actionService) {
|
||||||
this.actionService = actionService;
|
|
||||||
this.mct = mct;
|
this.mct = mct;
|
||||||
this.definitions = newViews.filter(function (newView) {
|
this.actionService = actionService;
|
||||||
return newView.region === mct.regions.properties;
|
|
||||||
}).map(function (newView) {
|
|
||||||
return newView.factory;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionDialogDecorator.prototype.getActions = function (context) {
|
ActionDialogDecorator.prototype.getActions = function (context) {
|
||||||
var mct = this.mct;
|
var mct = this.mct;
|
||||||
var definitions = this.definitions;
|
|
||||||
|
|
||||||
return this.actionService.getActions(context).map(function (action) {
|
return this.actionService.getActions(context).map(function (action) {
|
||||||
if (action.dialogService) {
|
if (action.dialogService) {
|
||||||
@ -43,16 +37,13 @@ define([
|
|||||||
context.domainObject.getModel(),
|
context.domainObject.getModel(),
|
||||||
objectUtils.parseKeyString(context.domainObject.getId())
|
objectUtils.parseKeyString(context.domainObject.getId())
|
||||||
);
|
);
|
||||||
|
var providers = mct.propertyEditors.get(domainObject);
|
||||||
|
|
||||||
definitions = definitions.filter(function (definition) {
|
if (providers.length > 0) {
|
||||||
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) {
|
||||||
return new mct.Dialog(
|
return new mct.Dialog(
|
||||||
definitions[0].view(context.domainObject),
|
providers[0].view(context.domainObject),
|
||||||
form.title
|
form.title
|
||||||
).show();
|
).show();
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,13 @@ define([], function () {
|
|||||||
this.providers = [];
|
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) {
|
ViewRegistry.prototype.get = function (item) {
|
||||||
return this.providers.filter(function (provider) {
|
return this.providers.filter(function (provider) {
|
||||||
return provider.canView(item);
|
return provider.canView(item);
|
||||||
|
Loading…
Reference in New Issue
Block a user