diff --git a/src/MCT.js b/src/MCT.js index 193e3fb29a..c1b328b736 100644 --- a/src/MCT.js +++ b/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} diff --git a/src/adapter/actions/ActionDialogDecorator.js b/src/adapter/actions/ActionDialogDecorator.js index 5a5426e081..d80e72741a 100644 --- a/src/adapter/actions/ActionDialogDecorator.js +++ b/src/adapter/actions/ActionDialogDecorator.js @@ -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(); }; diff --git a/src/ui/ViewRegistry.js b/src/ui/ViewRegistry.js index 074a9fbf2e..67bd494f4d 100644 --- a/src/ui/ViewRegistry.js +++ b/src/ui/ViewRegistry.js @@ -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);