Merge branch 'master' into persist-on-mutation-825

Conflicts:
	platform/commonUI/edit/src/actions/RemoveAction.js
	platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js
	platform/commonUI/edit/test/actions/RemoveActionSpec.js
	platform/entanglement/src/services/LinkService.js
	platform/features/timeline/src/controllers/drag/TimelineDragHandler.js
	platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js
	platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js
	platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js
This commit is contained in:
Victor Woeltjen
2016-05-20 14:26:39 -07:00
468 changed files with 2151 additions and 1919 deletions

View File

@@ -81,8 +81,8 @@ define(
// additionally fills in the action's getMetadata method
// with the extension definition (if no getMetadata
// method was supplied.)
function instantiateAction(Action, context) {
var action = new Action(context),
function instantiateAction(Action, ctxt) {
var action = new Action(ctxt),
metadata;
// Provide a getMetadata method that echos
@@ -90,7 +90,7 @@ define(
// unless the action has defined its own.
if (!action.getMetadata) {
metadata = Object.create(Action.definition || {});
metadata.context = context;
metadata.context = ctxt;
action.getMetadata = function () {
return metadata;
};
@@ -103,14 +103,14 @@ define(
// applicable in a given context, according to the static
// appliesTo method of given actions (if defined), and
// instantiate those applicable actions.
function createIfApplicable(actions, context) {
function createIfApplicable(actions, ctxt) {
function isApplicable(Action) {
return Action.appliesTo ? Action.appliesTo(context) : true;
return Action.appliesTo ? Action.appliesTo(ctxt) : true;
}
function instantiate(Action) {
try {
return instantiateAction(Action, context);
return instantiateAction(Action, ctxt);
} catch (e) {
$log.error([
"Could not instantiate action",

View File

@@ -81,7 +81,7 @@ define(
return mutationResult && self.invoke().then(findObject);
}
function addIdToModel(model) {
function addIdToModel(objModel) {
// Pick a specific index if needed.
index = isNaN(index) ? composition.length : index;
// Also, don't put past the end of the array
@@ -89,11 +89,11 @@ define(
// Remove the existing instance of the id
if (oldIndex !== -1) {
model.composition.splice(oldIndex, 1);
objModel.composition.splice(oldIndex, 1);
}
// ...and add it back at the appropriate index.
model.composition.splice(index, 0, id);
objModel.composition.splice(index, 0, id);
}
// If no index has been specified already and the id is already

View File

@@ -82,7 +82,7 @@ define(
parentContext =
parentObject && parentObject.getCapability('context'),
parentPath = parentContext ?
parentContext.getPath() : [ this.parentObject ];
parentContext.getPath() : [this.parentObject];
return parentPath.concat([this.domainObject]);
};

View File

@@ -62,9 +62,9 @@ define(
}
// Package capabilities as key-value pairs
function packageCapabilities(capabilities) {
function packageCapabilities(caps) {
var result = {};
capabilities.forEach(function (capability) {
caps.forEach(function (capability) {
if (capability.key) {
result[capability.key] =
result[capability.key] || capability;

View File

@@ -124,9 +124,9 @@ define(
clone = JSON.parse(JSON.stringify(model)),
useTimestamp = arguments.length > 1;
function notifyListeners(model) {
function notifyListeners(newModel) {
generalTopic.notify(domainObject);
specificTopic.notify(model);
specificTopic.notify(newModel);
}
// Function to handle copying values to the actual

View File

@@ -69,18 +69,18 @@ define(
* Checks if the value returned is falsey, and if so returns a
* rejected promise
*/
function rejectIfFalsey(value, $q){
if (!value){
function rejectIfFalsey(value, $q) {
if (!value) {
return $q.reject("Error persisting object");
} else {
return value;
}
}
function formatError(error){
function formatError(error) {
if (error && error.message) {
return error.message;
} else if (error && typeof error === "string"){
} else if (error && typeof error === "string") {
return error;
} else {
return "unknown error";
@@ -91,7 +91,7 @@ define(
* Display a notification message if an error has occurred during
* persistence.
*/
function notifyOnError(error, domainObject, notificationService, $q){
function notifyOnError(error, domainObject, notificationService, $q) {
var errorMessage = "Unable to persist " + domainObject.getModel().name;
if (error) {
errorMessage += ": " + formatError(error);
@@ -129,8 +129,8 @@ define(
}
// Update persistence timestamp...
domainObject.useCapability("mutation", function (model) {
model.persisted = modified;
domainObject.useCapability("mutation", function (m) {
m.persisted = modified;
}, modified);
// ...and persist
@@ -138,9 +138,9 @@ define(
this.getSpace(),
getKey(domainObject.getId()),
domainObject.getModel()
]).then(function(result){
]).then(function (result) {
return rejectIfFalsey(result, self.$q);
}).catch(function(error){
}).catch(function (error) {
return notifyOnError(error, domainObject, self.notificationService, self.$q);
});
};

View File

@@ -82,9 +82,9 @@ define(
}
// Package the result as id->model
function packageResult(parsedIds, models) {
function packageResult(parsedIdsToPackage, models) {
var result = {};
parsedIds.forEach(function (parsedId, index) {
parsedIdsToPackage.forEach(function (parsedId, index) {
var id = parsedId.id;
if (models[index]) {
result[id] = models[index];
@@ -93,11 +93,11 @@ define(
return result;
}
function loadModels(parsedIds) {
return $q.all(parsedIds.map(loadModel))
function loadModels(parsedIdsToLoad) {
return $q.all(parsedIdsToLoad.map(loadModel))
.then(function (models) {
return packageResult(
parsedIds,
parsedIdsToLoad,
models.map(addPersistedTimestamp)
);
});

View File

@@ -46,7 +46,9 @@ define(
*/
function RootModelProvider(roots, $q, $log) {
// Pull out identifiers to used as ROOT's
var ids = roots.map(function (root) { return root.id; });
var ids = roots.map(function (root) {
return root.id;
});
// Assign an initial location to root models
roots.forEach(function (root) {

View File

@@ -58,14 +58,14 @@ define(
* corresponding keys in the recursive step.
*
*
* @param a the first object to be merged
* @param b the second object to be merged
* @param modelA the first object to be merged
* @param modelB the second object to be merged
* @param merger the merger, as described above
* @returns {*} the result of merging `a` and `b`
* @returns {*} the result of merging `modelA` and `modelB`
* @constructor
* @memberof platform/core
*/
function mergeModels(a, b, merger) {
function mergeModels(modelA, modelB, merger) {
var mergeFunction;
function mergeArrays(a, b) {
@@ -93,11 +93,11 @@ define(
}
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
(Array.isArray(a) && Array.isArray(b)) ? mergeArrays :
(a instanceof Object && b instanceof Object) ? mergeObjects :
(Array.isArray(modelA) && Array.isArray(modelB)) ? mergeArrays :
(modelA instanceof Object && modelB instanceof Object) ? mergeObjects :
mergeOther;
return mergeFunction(a, b);
return mergeFunction(modelA, modelB);
}
return mergeModels;

View File

@@ -33,8 +33,12 @@ define(
}
},
identity: {
toModelValue: function (v) { return v; },
toFormValue: function (v) { return v; }
toModelValue: function (v) {
return v;
},
toFormValue: function (v) {
return v;
}
}
},
ARRAY_SUFFIX = '[]';

View File

@@ -159,8 +159,8 @@ define(
}
function lookupTypeDef(typeKey) {
function buildTypeDef(typeKey) {
var typeDefs = typeDefinitions[typeKey] || [],
function buildTypeDef(typeKeyToBuild) {
var typeDefs = typeDefinitions[typeKeyToBuild] || [],
inherits = typeDefs.map(function (typeDef) {
return asArray(typeDef.inherits || []);
}).reduce(function (a, b) {
@@ -175,11 +175,11 @@ define(
// Always provide a default name
def.model = def.model || {};
def.model.name = def.model.name ||
("Unnamed " + (def.name || "Object"));
("Unnamed " + (def.name || "Object"));
return def;
}
return (self.typeMap[typeKey] =
self.typeMap[typeKey] || buildTypeDef(typeKey));
}

View File

@@ -105,15 +105,15 @@ define(
// Check if an object has all capabilities designated as `needs`
// for a view. Exposing a capability via delegation is taken to
// satisfy this filter if `allowDelegation` is true.
function capabilitiesMatch(domainObject, capabilities, allowDelegation) {
var delegation = domainObject.getCapability("delegation");
function capabilitiesMatch(domainObj, capabilities, allowDelegation) {
var delegation = domainObj.getCapability("delegation");
allowDelegation = allowDelegation && (delegation !== undefined);
// Check if an object has (or delegates, if allowed) a
// capability.
function hasCapability(c) {
return domainObject.hasCapability(c) ||
return domainObj.hasCapability(c) ||
(allowDelegation && delegation.doesDelegateCapability(c));
}
@@ -128,13 +128,13 @@ define(
// Check if a view and domain object type can be paired;
// both can restrict the others they accept.
function viewMatchesType(view, type) {
var views = type && (type.getDefinition() || {}).views,
function viewMatchesType(view, objType) {
var views = objType && (objType.getDefinition() || {}).views,
matches = true;
// View is restricted to a certain type
if (view.type) {
matches = matches && type && type.instanceOf(view.type);
matches = matches && objType && objType.instanceOf(view.type);
}
// Type wishes to restrict its specific views