From 14607680f7b694f017e3245e15b92fac0aba9d86 Mon Sep 17 00:00:00 2001 From: Romain Thouvenin Date: Tue, 8 Jun 2021 18:08:03 +0200 Subject: [PATCH] Ignore modified_date when checking for changes during mailing auto-save --- ang/crmMailing/EditMailingCtrl.js | 7 ++++++- ang/crmMailingAB/services.js | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ang/crmMailing/EditMailingCtrl.js b/ang/crmMailing/EditMailingCtrl.js index 5651d4f8d6..7e72365116 100644 --- a/ang/crmMailing/EditMailingCtrl.js +++ b/ang/crmMailing/EditMailingCtrl.js @@ -121,7 +121,12 @@ return true; }, model: function() { - return [$scope.mailing, $scope.attachments.getAutosaveSignature()]; + //modified date is unset so that it gets ignored in comparison + //its value is overwritten with the save response from the server and may differ from the local value, + //which would result in an unnecessary auto-save + var mailing = angular.copy($scope.mailing); + mailing.modified_date = undefined; + return [mailing, $scope.attachments.getAutosaveSignature()]; }, form: function() { return $scope.crmMailing; diff --git a/ang/crmMailingAB/services.js b/ang/crmMailingAB/services.js index a1d64b7da6..eac6d84ebe 100644 --- a/ang/crmMailingAB/services.js +++ b/ang/crmMailingAB/services.js @@ -51,9 +51,16 @@ angular.extend(CrmMailingAB.prototype, { getAutosaveSignature: function() { + //modified date is unset so that it gets ignored in comparison + //its value is overwritten with the save response from the server and may differ from the local value, + //which would result in an unnecessary auto-save + var mailings = angular.copy(this.mailings); + _.each(mailings, function(mailing) { + mailing.modified_date = undefined; + }); return [ this.ab, - this.mailings, + mailings, this.attachments.a.getAutosaveSignature(), this.attachments.b.getAutosaveSignature(), this.attachments.c.getAutosaveSignature() -- 2.25.1