diff --git a/platform/commonUI/edit/bundle.json b/platform/commonUI/edit/bundle.json index e5e9f0f90e..475fae23db 100644 --- a/platform/commonUI/edit/bundle.json +++ b/platform/commonUI/edit/bundle.json @@ -93,7 +93,7 @@ "representers": [ { "implementation": "EditRepresenter.js", - "depends": [ "$q" ] + "depends": [ "$q", "$log" ] } ] } diff --git a/platform/commonUI/edit/src/EditRepresenter.js b/platform/commonUI/edit/src/EditRepresenter.js index e291899474..d6c988c443 100644 --- a/platform/commonUI/edit/src/EditRepresenter.js +++ b/platform/commonUI/edit/src/EditRepresenter.js @@ -22,9 +22,8 @@ define( * * @constructor */ - function EditRepresenter($q, scope) { - var watches = [], - domainObject, + function EditRepresenter($q, $log, scope) { + var domainObject, key; // Mutate and persist a new version of a domain object's model. @@ -40,12 +39,20 @@ define( } // Handle changes to model and/or view configuration - function update() { + function commit(message) { // Look up from scope; these will have been populated by // mct-representation. var model = scope.model, configuration = scope.configuration; + // Log the commit message + $log.debug([ + "Committing ", + domainObject && domainObject.getModel().name, + "(" + (domainObject && domainObject.getId()) + "):", + message + ].join(" ")); + // Update the configuration stored in the model, and persist. if (domainObject && domainObject.hasCapability("persistence")) { // Configurations for specific views are stored by @@ -60,9 +67,7 @@ define( // Respond to the destruction of the current representation. function destroy() { - // Stop watching for changes - watches.forEach(function (deregister) { deregister(); }); - watches = []; + // No op } // Handle a specific representation of a specific domain object @@ -74,16 +79,11 @@ define( // Ensure existing watches are released destroy(); - - // Watch for changes to model or configuration; keep the - // results, as $watch returns an de-registration function. - // Use the "editor" capability to check if we are in Edit mode. - watches = representedObject.hasCapability("editor") ? [ - scope.$watch("model", update, true), - scope.$watch("configuration", update, true) - ] : []; } + // Place the "commit" method in the scope + scope.commit = commit; + return { /** * Set the current representation in use, and the domain diff --git a/platform/features/layout/src/LayoutController.js b/platform/features/layout/src/LayoutController.js index 88e8755ae1..9ebab58017 100644 --- a/platform/features/layout/src/LayoutController.js +++ b/platform/features/layout/src/LayoutController.js @@ -158,6 +158,10 @@ define( // Store the position of this panel. $scope.configuration.panels[activeDragId] = rawPositions[activeDragId]; + // Mark this object as dirty to encourage persistence + if ($scope.commit) { + $scope.commit("Moved frame."); + } } };