Compare commits

...

11 Commits

Author SHA1 Message Date
Victor Woeltjen
a41c54f711 Merge remote-tracking branch 'origin/master' into subobject-select-1126 2016-12-16 11:22:33 -08:00
Victor Woeltjen
995790d32d [Inspection] Correct variable name 2016-12-08 13:06:32 -08:00
Victor Woeltjen
074548964a [Inspection] Update selection on navigation 2016-11-21 14:19:30 -08:00
Victor Woeltjen
d6deb533dd [Inspection] Change ViewRegistry to accept context
https://github.com/nasa/openmct/issues/1126#issuecomment-248112837
https://github.com/nasa/openmct/issues/1126#issuecomment-248127507
2016-11-21 13:39:37 -08:00
Victor Woeltjen
8834b11b56 [Inspector] Fix/clarify active check 2016-11-21 12:50:20 -08:00
Victor Woeltjen
f2d588be4b [Inspection] Simplify InspectorController
...such that it doees not depend upon navigation state (instead,
expect navigation changes to also update selection when appropriate)
2016-11-21 12:06:31 -08:00
Victor Woeltjen
f88da89b78 [Inspection] Sketch in InspectorView 2016-11-21 12:04:06 -08:00
Victor Woeltjen
f4547d333e [Inspection] Add template 2016-11-18 16:08:49 -08:00
Victor Woeltjen
309ec07bc7 [Inspection] Sketch in InspectorPanelView 2016-11-17 14:45:34 -08:00
Victor Woeltjen
d9226568b7 [Inspection] Update API usage from SelectGesture 2016-11-16 16:07:56 -08:00
Victor Woeltjen
936a668fe3 [Inspection] Sketch in InspectorController
...to mediate between selection/navigation changes and UI updates.
#1126
2016-11-16 15:57:41 -08:00
9 changed files with 220 additions and 10 deletions

View File

@@ -32,6 +32,7 @@ define([
'./policies/AdapterCompositionPolicy',
'./policies/AdaptedViewPolicy',
'./runs/AlternateCompositionInitializer',
'./runs/SelectingNavigationListener',
'text!./templates/adapted-view-template.html'
], function (
legacyRegistry,
@@ -45,6 +46,7 @@ define([
AdapterCompositionPolicy,
AdaptedViewPolicy,
AlternateCompositionInitializer,
SelectingNavigationListener,
adaptedViewTemplate
) {
legacyRegistry.register('src/adapter', {
@@ -121,6 +123,10 @@ define([
{
implementation: AlternateCompositionInitializer,
depends: ["openmct"]
},
{
implementation: SelectingNavigationListener,
depends: ["navigationService", "openmct"]
}
],
views: [

View File

@@ -29,8 +29,9 @@ define([], function () {
}
var domainObject = legacyObject.useCapability('adapter');
var providers = openmct.mainViews.get(domainObject);
$scope.view = providers[0] && providers[0].view(domainObject);
var context = { item: domainObject };
var providers = openmct.mainViews.get(context);
$scope.view = providers[0] && providers[0].view(context);
}
$scope.$watch('domainObject', refresh);

View File

@@ -0,0 +1,34 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2016, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
function SelectingNavigationListener(navigationService, openmct) {
var selection = openmct.selection;
navigationService.addListener(function (legacyObject) {
var domainObject = legacyObject.useCapability('adapter');
selection.clear();
selection.add({ item: domainObject });
});
}
return SelectingNavigationListener;
});

View File

@@ -0,0 +1,53 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2016, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./InspectorView'], function (InspectorView) {
function InspectorController(selection, region, registry) {
this.selection = selection;
this.region = region;
this.registry = registry;
this.active = false;
this.onChange = this.onChange.bind(this);
}
InspectorController.prototype.onChange = function (context) {
var view = new InspectorView(this.registry, context)
this.region.show(view);
};
InspectorController.prototype.activate = function () {
if (!this.active) {
this.selection.on('change', this.onChange);
this.active = true;
}
};
InspectorController.prototype.deactivate = function () {
if (this.active) {
this.selection.off('change', this.onChange);
this.active = false;
}
};
return InspectorController;
});

View File

@@ -0,0 +1,55 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2016, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'text!./inspector-panel.html',
'zepto',
'lodash'
], function (inspectorTemplate, $, _) {
var TEMPLATE = _.template(inspectorTemplate);
function InspectorPanelView(provider, context) {
this.provider = provider;
this.context = context;
}
InspectorPanelView.prototype.show = function (element) {
var html = TEMPLATE(this.provider.metadata(this.context));
var $elements = $(html);
var innerRegion = $elements.find('.inner-region')[0];
$(element).append($elements);
this.destroy();
this.view = this.provider.view(this.context);
this.view.show(innerRegion);
};
InspectorPanelView.prototype.destroy = function () {
if (this.view) {
this.view.destroy();
this.view = undefined;
}
};
return InspectorPanelView;
});

View File

@@ -0,0 +1,55 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2016, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['zepto', './InspectorPanelView'], function ($, InspectorPanelView) {
function InspectorView(registry, context) {
this.registry = registry;
this.context = context;
this.views = [];
}
InspectorView.prototype.show = function (element) {
var providers = this.registry.get(this.context);
var $ul = $('<ul></ul>');
this.destroy();
this.views = providers.map(function (provider) {
return new InspectorPanelView(provider, this.context);
}.bind(this));
$(element).append($ul);
this.views.foreEach(function (view) {
view.show($ul[0]);
});
};
InspectorView.prototype.destroy = function () {
this.views.forEach(function (view) {
view.destroy();
});
this.views = [];
};
return InspectorView;
});

View File

@@ -0,0 +1,4 @@
<li>
<em class="t-inspector-part-header"><%- name %></em>
<div class="inner-region"></div>
</li>

View File

@@ -30,7 +30,7 @@ define(['zepto'], function ($) {
var $element = $(htmlElement);
var contextManager = this.contextManager;
var selection = this.selection;
var path = contextManager.path(item, htmlElement);
var context = contextManager.context(item, htmlElement);
function select() {
selection.add(path);
@@ -40,7 +40,7 @@ define(['zepto'], function ($) {
var selected = selection.primary();
$element.toggleClass(
'selected',
selected && path.matches(selected)
!!selected && (selected.element === htmlElement)
);
}

View File

@@ -34,13 +34,14 @@ define([], function () {
/**
* @private for platform-internal use
* @param {*} item the object to be viewed
* @param {module:openmct.Context} context the view's context,
* which includes the item being viewed
* @returns {module:openmct.ViewProvider[]} any providers
* which can provide views of this object
*/
ViewRegistry.prototype.get = function (item) {
ViewRegistry.prototype.get = function (context) {
return this.providers.filter(function (provider) {
return provider.canView(item);
return provider.canView(context);
});
};
@@ -105,8 +106,8 @@ define([], function () {
*
* @method canView
* @memberof module:openmct.ViewProvider#
* @param {module:openmct.DomainObject} domainObject the domain object
* to be viewed
* @param {module:openmct.Context} context the view's context,
* which includes the item being viewed
* @returns {boolean} true if this domain object can be viewed using
* this provider
*/
@@ -122,7 +123,8 @@ define([], function () {
*
* @method view
* @memberof module:openmct.ViewProvider#
* @param {*} object the object to be viewed
* @param {module:openmct.Context} context the view's context,
* which includes the item being viewed
* @returns {module:openmct.View} a view of this domain object
*/