Merge remote-tracking branch 'github/master' into open245b
...in preparation to complete merge nasa/openmctweb#257 Conflicts: platform/entanglement/src/actions/CopyAction.js platform/entanglement/src/actions/LinkAction.js platform/entanglement/src/actions/MoveAction.js
This commit is contained in:
@@ -39,9 +39,11 @@ define(
|
||||
* @imeplements {ActionService}
|
||||
* @constructor
|
||||
*/
|
||||
function ActionProvider(actions) {
|
||||
function ActionProvider(actions, $log) {
|
||||
var self = this;
|
||||
|
||||
this.$log = $log;
|
||||
|
||||
// Build up look-up tables
|
||||
this.actions = actions;
|
||||
this.actionsByKey = {};
|
||||
@@ -74,6 +76,7 @@ define(
|
||||
var context = (actionContext || {}),
|
||||
category = context.category,
|
||||
key = context.key,
|
||||
$log = this.$log,
|
||||
candidates;
|
||||
|
||||
// Instantiate an action; invokes the constructor and
|
||||
@@ -103,12 +106,31 @@ define(
|
||||
// appliesTo method of given actions (if defined), and
|
||||
// instantiate those applicable actions.
|
||||
function createIfApplicable(actions, context) {
|
||||
return (actions || []).filter(function (Action) {
|
||||
return Action.appliesTo ?
|
||||
Action.appliesTo(context) : true;
|
||||
}).map(function (Action) {
|
||||
return instantiateAction(Action, context);
|
||||
});
|
||||
function isApplicable(Action) {
|
||||
return Action.appliesTo ? Action.appliesTo(context) : true;
|
||||
}
|
||||
|
||||
function instantiate(Action) {
|
||||
try {
|
||||
return instantiateAction(Action, context);
|
||||
} catch (e) {
|
||||
$log.error([
|
||||
"Could not instantiate action",
|
||||
Action.key,
|
||||
"due to:",
|
||||
e.message
|
||||
].join(" "));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function isDefined(action) {
|
||||
return action !== undefined;
|
||||
}
|
||||
|
||||
return (actions || []).filter(isApplicable)
|
||||
.map(instantiate)
|
||||
.filter(isDefined);
|
||||
}
|
||||
|
||||
// Match actions to the provided context by comparing "key"
|
||||
|
||||
@@ -26,6 +26,8 @@ define(
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
var ERROR_PREFIX = "Error when notifying listener: ";
|
||||
|
||||
/**
|
||||
* The `topic` service provides a way to create both named,
|
||||
* shared listeners and anonymous, private listeners.
|
||||
@@ -46,7 +48,7 @@ define(
|
||||
* @returns {Function}
|
||||
* @memberof platform/core
|
||||
*/
|
||||
function Topic() {
|
||||
function Topic($log) {
|
||||
var topics = {};
|
||||
|
||||
function createTopic() {
|
||||
@@ -63,7 +65,11 @@ define(
|
||||
},
|
||||
notify: function (message) {
|
||||
listeners.forEach(function (listener) {
|
||||
listener(message);
|
||||
try {
|
||||
listener(message);
|
||||
} catch (e) {
|
||||
$log.error(ERROR_PREFIX + e.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -156,8 +156,15 @@ define(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the default model for an object of this type. Note that
|
||||
* this method returns a clone of the original model, so if using this
|
||||
* method heavily, consider caching the result to optimize performance.
|
||||
*
|
||||
* @return {object} The default model for an object of this type.
|
||||
*/
|
||||
TypeImpl.prototype.getInitialModel = function () {
|
||||
return this.typeDef.model || {};
|
||||
return JSON.parse(JSON.stringify(this.typeDef.model || {}));
|
||||
};
|
||||
|
||||
TypeImpl.prototype.getDefinition = function () {
|
||||
|
||||
Reference in New Issue
Block a user