mirror of
https://github.com/nasa/openmct.git
synced 2025-06-12 04:08:22 +00:00
[Templates] Use templateLinker from MCTContainer
...for compatibility with both template and templateUrl.
This commit is contained in:
@ -319,6 +319,7 @@ define([
|
|||||||
"key": "mctContainer",
|
"key": "mctContainer",
|
||||||
"implementation": MCTContainer,
|
"implementation": MCTContainer,
|
||||||
"depends": [
|
"depends": [
|
||||||
|
"templateLinker",
|
||||||
"containers[]"
|
"containers[]"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -42,18 +42,12 @@ define(
|
|||||||
* @memberof platform/commonUI/general
|
* @memberof platform/commonUI/general
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function MCTContainer(containers) {
|
function MCTContainer(templateLinker, containers) {
|
||||||
var containerMap = {};
|
var containerMap = {};
|
||||||
|
|
||||||
// Initialize container map from extensions
|
// Initialize container map from extensions
|
||||||
containers.forEach(function (container) {
|
containers.forEach(function (container) {
|
||||||
var key = container.key;
|
containerMap[container.key] = container;
|
||||||
containerMap[key] = Object.create(container);
|
|
||||||
containerMap[key].templateUrl = [
|
|
||||||
container.bundle.path,
|
|
||||||
container.bundle.resources,
|
|
||||||
container.templateUrl
|
|
||||||
].join("/");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -73,9 +67,11 @@ define(
|
|||||||
var key = attrs.key,
|
var key = attrs.key,
|
||||||
container = containerMap[key],
|
container = containerMap[key],
|
||||||
alias = "container",
|
alias = "container",
|
||||||
copiedAttributes = {};
|
copiedAttributes = {},
|
||||||
|
changeTemplate = templateLinker.link(scope, element);
|
||||||
|
|
||||||
if (container) {
|
if (container) {
|
||||||
|
changeTemplate(container);
|
||||||
alias = container.alias || alias;
|
alias = container.alias || alias;
|
||||||
(container.attributes || []).forEach(function (attr) {
|
(container.attributes || []).forEach(function (attr) {
|
||||||
copiedAttributes[attr] = attrs[attr];
|
copiedAttributes[attr] = attrs[attr];
|
||||||
@ -83,15 +79,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope[alias] = copiedAttributes;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user