From 4c0a79116a89c6fb75cbb41ad8d3c2da3b36ab8f Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 11 Nov 2015 11:52:30 -0800 Subject: [PATCH] Added refresh check for editability --- platform/representation/src/MCTRepresentation.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js index d1937389d2..5fab004205 100644 --- a/platform/representation/src/MCTRepresentation.js +++ b/platform/representation/src/MCTRepresentation.js @@ -96,6 +96,7 @@ define( toClear = [], // Properties to clear out of scope on change counter = 0, couldRepresent = false, + couldEdit = false, lastId, lastKey, changeTemplate = templateLinker.link($scope, element); @@ -143,11 +144,13 @@ define( }); } - function unchanged(canRepresent, id, key) { + function unchanged(canRepresent, canEdit, id, key) { return canRepresent && couldRepresent && id === lastId && - key === lastKey; + key === lastKey && + canEdit && + couldEdit; } // General-purpose refresh mechanism; should set up the scope @@ -159,10 +162,11 @@ define( path = representation && getPath(representation), uses = ((representation || {}).uses || []), canRepresent = !!(path && domainObject), + canEdit = !!(domainObject && domainObject.hasCapability('editor')), id = domainObject && domainObject.getId(), key = $scope.key; - if (unchanged(canRepresent, id, key)) { + if (unchanged(canRepresent, canEdit, id, key)) { return; } @@ -190,6 +194,7 @@ define( // To allow simplified change detection next time around couldRepresent = canRepresent; + couldEdit = canEdit; lastId = id; lastKey = key;