[API] Change approach to applies-to checking (#1072)

* [API] Allow selection

* [API] Keep in sync using model

* [API] Add selection as EventEmitter

* [API] Use selection from ToDo tutorial

* [API] Add appliesTo-style method

* [API] Remove destroy method, simplify show

* [View] Return a no-op

* [API] Use new applies-to checking

* [API] Rename TodoView to TodoRenderer

* [API] Rewire views

* [API] Wire up so that things work

* [API] Begin adding container

...to attempt to give views something to listen to for destroy-like
events

* [API] Begin using regions...

* [API] Begin working through Region stuff

* [API] Revise Region API

...for similarity with Marionette,
https://github.com/nasa/openmct/pull/1072#issuecomment-230902986

* [API] Begin separating View, ViewDefinition

* [API] Finish separating View/ViewDefinition

* [API] Update MCTView

...to reflect updates to Region/View/ViewDefinition APIs

* [API] Simplify View API

...merging closely-related populate/show methods, and restoring
compatibility with todo tutorial

* [API] Wire in from todo tutorial plugin

* [API] Switch back to region constants

* [API] Update method signature, add JSDoc

* [API] Update variable name

* [API] Remove unnecessary separate regions file

* [API] Relocate Region; not external api

* [API] Revert changes to api.js

...as these ended up becoming entirely superficial
This commit is contained in:
Victor Woeltjen
2016-07-20 13:46:03 -07:00
committed by Pete Richards
parent 1879c122c7
commit 18843cee48
6 changed files with 125 additions and 28 deletions

View File

@ -37,7 +37,13 @@ define([
this.legacyBundle.extensions[category].push(extension);
};
MCT.prototype.view = function (region, factory) {
/**
* Register a new type of view.
*
* @param region the region identifier (see mct.regions)
* @param {ViewDefinition} definition the definition for this view
*/
MCT.prototype.view = function (region, definition) {
var viewKey = region + uuid();
var adaptedViewKey = "adapted-view-" + region;
@ -61,9 +67,9 @@ define([
this.legacyExtension('policies', {
category: "view",
implementation: function Policy() {
this.allow = function (view, domainObject) {
if (view.key === adaptedViewKey) {
return !!factory(domainObject);
this.allow = function (v, domainObject) {
if (v.key === adaptedViewKey) {
return definition.canView(domainObject);
}
return true;
};
@ -71,7 +77,7 @@ define([
});
this.legacyExtension('newViews', {
factory: factory,
factory: definition,
region: region,
key: viewKey
});