mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
[Framework] Allow controller registration
Add tweaks in framework which fix errors which were preventing controller registration. This includes maintaining the type of controllers as functions, even after decorating with information from the extension. WTD-518.
This commit is contained in:
parent
b383be0711
commit
0e6f419678
@ -38,7 +38,7 @@ define(
|
||||
|
||||
// Utility function for resolving paths in this bundle
|
||||
function resolvePath(elements) {
|
||||
return path.concat(elements || []).join(Constants.SEPARATOR);
|
||||
return [path].concat(elements || []).join(Constants.SEPARATOR);
|
||||
}
|
||||
|
||||
// Override defaults with specifics from bundle definition
|
||||
|
@ -20,13 +20,14 @@ define(
|
||||
var key = extension.key,
|
||||
dependencies = extension.depends || [];
|
||||
|
||||
|
||||
if (!key) {
|
||||
$log.warn([
|
||||
"Cannot register ",
|
||||
angularFunction,
|
||||
", ",
|
||||
" ",
|
||||
index,
|
||||
"no key specified. ",
|
||||
", no key specified. ",
|
||||
JSON.stringify(extension)
|
||||
].join(""));
|
||||
} else {
|
||||
@ -35,7 +36,7 @@ define(
|
||||
angularFunction,
|
||||
": ",
|
||||
key
|
||||
]);
|
||||
].join(""));
|
||||
app[angularFunction](
|
||||
key,
|
||||
dependencies.concat([extension])
|
||||
|
@ -3,6 +3,8 @@
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* An extension's plain JSON definition.
|
||||
*
|
||||
@ -32,7 +34,7 @@ define(
|
||||
*/
|
||||
function Extension(bundle, category, definition) {
|
||||
var logName = category,
|
||||
extensionDefinition = Object.create(definition);
|
||||
extensionDefinition = {};
|
||||
|
||||
// Build up the log-friendly name for this bundle
|
||||
if (definition.key || definition.name) {
|
||||
@ -40,9 +42,16 @@ define(
|
||||
logName += definition.key || "";
|
||||
logName += (definition.key && definition.name) ? " " : "";
|
||||
logName += definition.name || "";
|
||||
logName += ")";
|
||||
}
|
||||
logName += " from " + bundle.getLogName();
|
||||
|
||||
// Copy over definition. This allows us to attach the bundle
|
||||
// definition without modifying the original definition object.
|
||||
Object.keys(definition).forEach(function (k) {
|
||||
extensionDefinition[k] = definition[k];
|
||||
});
|
||||
|
||||
// Attach bundle metadata
|
||||
extensionDefinition.bundle = bundle.getDefinition();
|
||||
|
||||
|
@ -36,7 +36,7 @@ define(
|
||||
// Utility function; create the second argument for Angular's
|
||||
// .service service registration method (an array containing
|
||||
// both dependencies and a factory method for the service.)
|
||||
function makeServiceArgument(extension) {
|
||||
function makeServiceArgument(category, extension) {
|
||||
var dependencies = extension.depends || [],
|
||||
factory = (typeof extension === 'function') ?
|
||||
new PartialConstructor(extension) :
|
||||
@ -59,7 +59,10 @@ define(
|
||||
// Track individual extension names as-registered
|
||||
names.push(name);
|
||||
|
||||
app.factory(name, makeServiceArgument(extension));
|
||||
app.factory(
|
||||
name,
|
||||
makeServiceArgument(category, extension)
|
||||
);
|
||||
}
|
||||
|
||||
if (registeredCategories[category]) {
|
||||
|
@ -25,7 +25,11 @@ define(
|
||||
// Attach values from the object definition to the
|
||||
// loaded implementation.
|
||||
function attachDefinition(impl) {
|
||||
var result = Object.create(impl);
|
||||
var result = (typeof impl === 'function') ?
|
||||
function () {
|
||||
return impl.apply({}, arguments);
|
||||
} :
|
||||
Object.create(impl);
|
||||
|
||||
Object.keys(definition).forEach(function (k) {
|
||||
result[k] = definition[k];
|
||||
|
@ -19,7 +19,7 @@ define(
|
||||
function ImplementationLoader(require) {
|
||||
function loadModule(path) {
|
||||
return new Promise(function (fulfill, reject) {
|
||||
require(path, fulfill, reject);
|
||||
require([path], fulfill, reject);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user