From 0bedc227f44ccc28e8c28a9458f868f980c306f5 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 26 Jul 2016 10:10:15 -0700 Subject: [PATCH] [Persistence] Allow nested transactions --- platform/commonUI/edit/src/services/TransactionService.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/commonUI/edit/src/services/TransactionService.js b/platform/commonUI/edit/src/services/TransactionService.js index 6de9cdbbc8..6dc8634dc4 100644 --- a/platform/commonUI/edit/src/services/TransactionService.js +++ b/platform/commonUI/edit/src/services/TransactionService.js @@ -38,6 +38,7 @@ define( this.$q = $q; this.$log = $log; this.transaction = undefined; + this.transactionStack = []; } /** @@ -48,8 +49,7 @@ define( */ TransactionService.prototype.startTransaction = function () { if (this.transaction) { - //Log error because this is a programming error if it occurs. - this.$log.error("Transaction already in progress"); + this.transactionStack.push(this.transaction); } this.transaction = new Transaction(this.$log); }; @@ -86,7 +86,7 @@ define( */ TransactionService.prototype.commit = function () { var transaction = this.transaction; - this.transaction = undefined; + this.transaction = this.transactionStack.pop(); return transaction && transaction.commit(); }; @@ -100,7 +100,7 @@ define( */ TransactionService.prototype.cancel = function () { var transaction = this.transaction; - this.transaction = undefined; + this.transaction = this.transactionStack.pop(); return transaction && transaction.cancel(); };