Merge branch 'open1035' into open-master

Merge WTD-1035; resolving conflicts to avoid WTD-1069

Conflicts:
	platform/commonUI/edit/src/controllers/EditController.js
	platform/commonUI/edit/src/objects/EditableDomainObjectCache.js
This commit is contained in:
Victor Woeltjen
2015-04-06 08:32:54 -07:00
10 changed files with 275 additions and 8 deletions

View File

@ -15,10 +15,12 @@ define(
* @constructor
*/
function EditController($scope, $q, navigationService) {
var navigatedObject;
function setNavigation(domainObject) {
// Wrap the domain object such that all mutation is
// confined to edit mode (until Save)
$scope.navigatedObject =
navigatedObject =
domainObject && new EditableDomainObject(domainObject, $q);
}
@ -27,6 +29,31 @@ define(
$scope.$on("$destroy", function () {
navigationService.removeListener(setNavigation);
});
return {
/**
* Get the domain object which is navigated-to.
* @returns {DomainObject} the domain object that is navigated-to
*/
navigatedObject: function () {
return navigatedObject;
},
/**
* Get the warning to show if the user attempts to navigate
* away from Edit mode while unsaved changes are present.
* @returns {string} the warning to show, or undefined if
* there are no unsaved changes
*/
getUnloadWarning: function () {
var editorCapability = navigatedObject &&
navigatedObject.getCapability("editor"),
hasChanges = editorCapability && editorCapability.dirty();
return hasChanges ?
"Unsaved changes will be lost if you leave this page." :
undefined;
}
};
}
return EditController;