Addressing issues from code review

This commit is contained in:
Henry
2016-02-29 17:22:13 -08:00
parent 2cc2c6a9d3
commit f192544be3
13 changed files with 147 additions and 98 deletions

View File

@ -36,8 +36,9 @@ define(
* @memberof platform/commonUI/edit
* @constructor
*/
function EditObjectController($scope, $location) {
function EditObjectController($scope, $location, policyService) {
this.scope = $scope;
this.policyService = policyService;
var navigatedObject;
function setViewForDomainObject(domainObject) {
@ -73,16 +74,14 @@ define(
*/
EditObjectController.prototype.getUnloadWarning = function () {
var navigatedObject = this.scope.domainObject,
editorCapability = navigatedObject &&
navigatedObject.getCapability("editor"),
statusCapability = navigatedObject &&
navigatedObject.getCapability("status"),
hasChanges = statusCapability && statusCapability.get('editing')
&& editorCapability && editorCapability.dirty();
policyMessage;
this.policyService.allow("navigation", navigatedObject, undefined, function(message) {
policyMessage = message;
});
return policyMessage;
return hasChanges ?
"Unsaved changes will be lost if you leave this page." :
undefined;
};
return EditObjectController;