mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 22:50:49 +00:00
[Templates] Use templateLinker from MCTContainer
...for compatibility with both template and templateUrl.
This commit is contained in:
parent
741d4476e6
commit
e61711688e
@ -319,6 +319,7 @@ define([
|
||||
"key": "mctContainer",
|
||||
"implementation": MCTContainer,
|
||||
"depends": [
|
||||
"templateLinker",
|
||||
"containers[]"
|
||||
]
|
||||
},
|
||||
|
@ -42,18 +42,12 @@ define(
|
||||
* @memberof platform/commonUI/general
|
||||
* @constructor
|
||||
*/
|
||||
function MCTContainer(containers) {
|
||||
function MCTContainer(templateLinker, containers) {
|
||||
var containerMap = {};
|
||||
|
||||
// Initialize container map from extensions
|
||||
containers.forEach(function (container) {
|
||||
var key = container.key;
|
||||
containerMap[key] = Object.create(container);
|
||||
containerMap[key].templateUrl = [
|
||||
container.bundle.path,
|
||||
container.bundle.resources,
|
||||
container.templateUrl
|
||||
].join("/");
|
||||
containerMap[container.key] = container;
|
||||
});
|
||||
|
||||
return {
|
||||
@ -73,9 +67,11 @@ define(
|
||||
var key = attrs.key,
|
||||
container = containerMap[key],
|
||||
alias = "container",
|
||||
copiedAttributes = {};
|
||||
copiedAttributes = {},
|
||||
changeTemplate = templateLinker.link(scope, element);
|
||||
|
||||
if (container) {
|
||||
changeTemplate(container);
|
||||
alias = container.alias || alias;
|
||||
(container.attributes || []).forEach(function (attr) {
|
||||
copiedAttributes[attr] = attrs[attr];
|
||||
@ -83,15 +79,7 @@ define(
|
||||
}
|
||||
|
||||
scope[alias] = copiedAttributes;
|
||||
},
|
||||
|
||||
// Get the template URL for this container, based
|
||||
// on its attributes.
|
||||
templateUrl: function (element, attrs) {
|
||||
var key = attrs.key;
|
||||
return containerMap[key].templateUrl;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user