Compare commits

...

3 Commits

Author SHA1 Message Date
daf41f1114 [Representation] Fix unchanged check
Fix logic in unchanged check; compare booleans to detect if
they have changed, instead of just anding them. Partially
addresses #732
2016-03-10 13:48:53 -08:00
a0232ae6d9 Also report how many actual representations occur 2016-03-10 12:42:06 -08:00
ca12129427 Add metrics to title from mct-rep 2016-03-10 12:28:44 -08:00

View File

@ -94,8 +94,23 @@ define(
couldEdit = false,
lastIdPath = [],
lastKey,
metrics = {
linked: (new Date()).toString(),
checked: 0,
refreshed: 0,
represented: 0
},
changeTemplate = templateLinker.link($scope, element);
function updateTitle() {
element.attr("title", [
"Linked: " + metrics.linked,
"Checked: " + metrics.checked,
"Refreshed: " + metrics.refreshed,
"Represented: " + metrics.represented
].join("\n"));
}
// Populate scope with any capabilities indicated by the
// representation's extension definition
function refreshCapabilities() {
@ -140,15 +155,13 @@ define(
}
function unchanged(canRepresent, canEdit, idPath, key) {
return canRepresent &&
couldRepresent &&
key === lastKey &&
idPath.length === lastIdPath.length &&
return (canRepresent === couldRepresent) &&
(key === lastKey) &&
(idPath.length === lastIdPath.length) &&
idPath.every(function (id, i) {
return id === lastIdPath[i];
}) &&
canEdit &&
couldEdit;
(canEdit === couldEdit);
}
function getIdPath(domainObject) {
@ -176,10 +189,15 @@ define(
idPath = getIdPath(domainObject),
key = $scope.key;
metrics.checked += 1;
if (unchanged(canRepresent, canEdit, idPath, key)) {
updateTitle();
return;
}
metrics.refreshed += 1;
// Create an empty object named "representation", for this
// representation to store local variables into.
$scope.representation = {};
@ -211,6 +229,7 @@ define(
// Populate scope with fields associated with the current
// domain object (if one has been passed in)
if (canRepresent) {
metrics.represented += 1;
// Track how many representations we've made in this scope,
// to ensure that the correct representations are matched to
// the correct object/key pairs.
@ -234,6 +253,8 @@ define(
// next change object/key pair changes
toClear = uses.concat(['model']);
}
updateTitle();
}
// Update the representation when the key changes (e.g. if a