From f17fda53a0ef7a0cd50a048a53b4a7ea53fa51d7 Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Thu, 28 Oct 2021 09:35:53 -0700 Subject: [PATCH] Save the object before adding it to the parent so that transaction committing works properly (#4388) --- .../commonUI/edit/src/actions/SaveAsAction.js | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/platform/commonUI/edit/src/actions/SaveAsAction.js b/platform/commonUI/edit/src/actions/SaveAsAction.js index cafc08b3cd..bf53334567 100644 --- a/platform/commonUI/edit/src/actions/SaveAsAction.js +++ b/platform/commonUI/edit/src/actions/SaveAsAction.js @@ -132,11 +132,14 @@ function ( return fetchObject(object.getModel().location); } - function saveObject(parent) { - return self.openmct.editor.save().then(() => { - // Force mutation for search indexing - return parent; - }); + function saveObject(object) { + //persist the object, which adds it to the transaction and then call editor.save + return object.getCapability("persistence").persist() + .then(() => { + return self.openmct.editor.save().then(() => { + return object; + }); + }); } function addSavedObjectToParent(parent) { @@ -150,17 +153,6 @@ function ( }); } - function undirty(object) { - return object.getCapability('persistence').refresh(); - } - - function undirtyOriginals(object) { - return object.getCapability("persistence").persist() - .then(function () { - return object; - }); - } - function indexForSearch(addedObject) { addedObject.useCapability('mutation', (model) => { return model; @@ -187,10 +179,9 @@ function ( return getParent(domainObject) .then(doWizardSave) .then(showBlockingDialog) - .then(getParent) .then(saveObject) + .then(getParent) .then(addSavedObjectToParent) - .then(undirtyOriginals) .then((addedObject) => { return fetchObject(addedObject.getId()); })