Victor Woeltjen 8f288751db [Edit] Persist in a group
Invoke persist calls when leaving Edit mode in a group, instead of
in-order, to allow these revision-checking to be handling for the
group as a whole. WTD-1033.
2015-03-24 10:01:45 -07:00

34 lines
1.1 KiB
JavaScript

/*global define,Promise*/
/**
* Module defining EditController. Created by vwoeltje on 11/14/14.
*/
define(
["../objects/EditableDomainObject"],
function (EditableDomainObject) {
"use strict";
/**
* Controller which is responsible for populating the scope for
* Edit mode; introduces an editable version of the currently
* navigated domain object into the scope.
* @constructor
*/
function EditController($scope, $q, navigationService) {
function setNavigation(domainObject) {
// Wrap the domain object such that all mutation is
// confined to edit mode (until Save)
$scope.navigatedObject =
domainObject && new EditableDomainObject(domainObject, $q);
}
setNavigation(navigationService.getNavigation());
navigationService.addListener(setNavigation);
$scope.$on("$destroy", function () {
navigationService.removeListener(setNavigation);
});
}
return EditController;
}
);