mirror of
https://github.com/nasa/openmct.git
synced 2025-05-29 21:54:20 +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
|
// Utility function for resolving paths in this bundle
|
||||||
function resolvePath(elements) {
|
function resolvePath(elements) {
|
||||||
return path.concat(elements || []).join(Constants.SEPARATOR);
|
return [path].concat(elements || []).join(Constants.SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override defaults with specifics from bundle definition
|
// Override defaults with specifics from bundle definition
|
||||||
|
@ -20,13 +20,14 @@ define(
|
|||||||
var key = extension.key,
|
var key = extension.key,
|
||||||
dependencies = extension.depends || [];
|
dependencies = extension.depends || [];
|
||||||
|
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
$log.warn([
|
$log.warn([
|
||||||
"Cannot register ",
|
"Cannot register ",
|
||||||
angularFunction,
|
angularFunction,
|
||||||
", ",
|
" ",
|
||||||
index,
|
index,
|
||||||
"no key specified. ",
|
", no key specified. ",
|
||||||
JSON.stringify(extension)
|
JSON.stringify(extension)
|
||||||
].join(""));
|
].join(""));
|
||||||
} else {
|
} else {
|
||||||
@ -35,7 +36,7 @@ define(
|
|||||||
angularFunction,
|
angularFunction,
|
||||||
": ",
|
": ",
|
||||||
key
|
key
|
||||||
]);
|
].join(""));
|
||||||
app[angularFunction](
|
app[angularFunction](
|
||||||
key,
|
key,
|
||||||
dependencies.concat([extension])
|
dependencies.concat([extension])
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
define(
|
define(
|
||||||
[],
|
[],
|
||||||
function () {
|
function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extension's plain JSON definition.
|
* An extension's plain JSON definition.
|
||||||
*
|
*
|
||||||
@ -32,7 +34,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
function Extension(bundle, category, definition) {
|
function Extension(bundle, category, definition) {
|
||||||
var logName = category,
|
var logName = category,
|
||||||
extensionDefinition = Object.create(definition);
|
extensionDefinition = {};
|
||||||
|
|
||||||
// Build up the log-friendly name for this bundle
|
// Build up the log-friendly name for this bundle
|
||||||
if (definition.key || definition.name) {
|
if (definition.key || definition.name) {
|
||||||
@ -40,9 +42,16 @@ define(
|
|||||||
logName += definition.key || "";
|
logName += definition.key || "";
|
||||||
logName += (definition.key && definition.name) ? " " : "";
|
logName += (definition.key && definition.name) ? " " : "";
|
||||||
logName += definition.name || "";
|
logName += definition.name || "";
|
||||||
|
logName += ")";
|
||||||
}
|
}
|
||||||
logName += " from " + bundle.getLogName();
|
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
|
// Attach bundle metadata
|
||||||
extensionDefinition.bundle = bundle.getDefinition();
|
extensionDefinition.bundle = bundle.getDefinition();
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ define(
|
|||||||
// Utility function; create the second argument for Angular's
|
// Utility function; create the second argument for Angular's
|
||||||
// .service service registration method (an array containing
|
// .service service registration method (an array containing
|
||||||
// both dependencies and a factory method for the service.)
|
// both dependencies and a factory method for the service.)
|
||||||
function makeServiceArgument(extension) {
|
function makeServiceArgument(category, extension) {
|
||||||
var dependencies = extension.depends || [],
|
var dependencies = extension.depends || [],
|
||||||
factory = (typeof extension === 'function') ?
|
factory = (typeof extension === 'function') ?
|
||||||
new PartialConstructor(extension) :
|
new PartialConstructor(extension) :
|
||||||
@ -59,7 +59,10 @@ define(
|
|||||||
// Track individual extension names as-registered
|
// Track individual extension names as-registered
|
||||||
names.push(name);
|
names.push(name);
|
||||||
|
|
||||||
app.factory(name, makeServiceArgument(extension));
|
app.factory(
|
||||||
|
name,
|
||||||
|
makeServiceArgument(category, extension)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (registeredCategories[category]) {
|
if (registeredCategories[category]) {
|
||||||
|
@ -25,7 +25,11 @@ define(
|
|||||||
// Attach values from the object definition to the
|
// Attach values from the object definition to the
|
||||||
// loaded implementation.
|
// loaded implementation.
|
||||||
function attachDefinition(impl) {
|
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) {
|
Object.keys(definition).forEach(function (k) {
|
||||||
result[k] = definition[k];
|
result[k] = definition[k];
|
||||||
|
@ -19,7 +19,7 @@ define(
|
|||||||
function ImplementationLoader(require) {
|
function ImplementationLoader(require) {
|
||||||
function loadModule(path) {
|
function loadModule(path) {
|
||||||
return new Promise(function (fulfill, reject) {
|
return new Promise(function (fulfill, reject) {
|
||||||
require(path, fulfill, reject);
|
require([path], fulfill, reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user