[Code Style] Rename shadowing variables
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -82,7 +82,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
|
||||
@@ -90,11 +90,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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -124,8 +124,8 @@ define(
|
||||
this.persistenceService.createObject;
|
||||
|
||||
// Update persistence timestamp...
|
||||
domainObject.useCapability("mutation", function (model) {
|
||||
model.persisted = modified;
|
||||
domainObject.useCapability("mutation", function (m) {
|
||||
m.persisted = modified;
|
||||
}, modified);
|
||||
|
||||
// ...and persist
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,7 +175,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user