From c305fba0a74e10be336f1d4ca5168890eeb750f8 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 11 May 2016 17:58:03 -0700 Subject: [PATCH] Modified dirty function --- .../commonUI/edit/src/capabilities/EditorCapability.js | 2 +- platform/commonUI/edit/src/services/TransactionService.js | 4 ++++ platform/representation/bundle.js | 5 +---- platform/representation/src/gestures/DropGesture.js | 7 ++----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index df305de73c..69eb773d73 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -112,7 +112,7 @@ define( * modifications since the last persist, false otherwise. */ EditorCapability.prototype.dirty = function () { - return (this.domainObject.getModel().modified || 0) > (this.domainObject.getModel().persisted || 0); + return this.transactionService.size() > 0; }; return EditorCapability; diff --git a/platform/commonUI/edit/src/services/TransactionService.js b/platform/commonUI/edit/src/services/TransactionService.js index 6affde28d8..c6e0bcb5da 100644 --- a/platform/commonUI/edit/src/services/TransactionService.js +++ b/platform/commonUI/edit/src/services/TransactionService.js @@ -140,5 +140,9 @@ define( }); }; + TransactionService.prototype.size = function () { + return this.onCommits.length + this.onCancels.length; + }; + return TransactionService; }); diff --git a/platform/representation/bundle.js b/platform/representation/bundle.js index ae8cb0ed8e..01484ccb78 100644 --- a/platform/representation/bundle.js +++ b/platform/representation/bundle.js @@ -86,10 +86,7 @@ define([ "implementation": DropGesture, "depends": [ "dndService", - "$q", - "navigationService", - "instantiate", - "typeService" + "$q" ] }, { diff --git a/platform/representation/src/gestures/DropGesture.js b/platform/representation/src/gestures/DropGesture.js index f276460b53..f2d64024a3 100644 --- a/platform/representation/src/gestures/DropGesture.js +++ b/platform/representation/src/gestures/DropGesture.js @@ -38,7 +38,7 @@ define( * @param {DomainObject} domainObject the domain object whose * composition should be modified as a result of the drop. */ - function DropGesture(dndService, $q, navigationService, instantiate, typeService, element, domainObject) { + function DropGesture(dndService, $q, element, domainObject) { var actionCapability = domainObject.getCapability('action'), scope = element.scope && element.scope(), action; // Action for the drop, when it occurs @@ -70,8 +70,6 @@ define( } function dragOver(e) { - actionCapability = domainObject.getCapability('action'); - var event = (e || {}).originalEvent || e, selectedObject = dndService.getData( GestureConstants.MCT_EXTENDED_DRAG_TYPE @@ -105,8 +103,7 @@ define( e.preventDefault(); //Use scope.apply, drop event is outside digest cycle - // and if not applied here causes visual artifacts. - scope.$apply( function() { + scope.$apply(function () { if (domainObjectType !== 'folder') { domainObject.getCapability('action').perform('edit'); }