Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nasa/openmct.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/formActions/EditPropertiesAction.js')
-rw-r--r--src/plugins/formActions/EditPropertiesAction.js34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/plugins/formActions/EditPropertiesAction.js b/src/plugins/formActions/EditPropertiesAction.js
index 65ceaaadd..f2cb232f5 100644
--- a/src/plugins/formActions/EditPropertiesAction.js
+++ b/src/plugins/formActions/EditPropertiesAction.js
@@ -22,6 +22,7 @@
import PropertiesAction from './PropertiesAction';
import CreateWizard from './CreateWizard';
+
export default class EditPropertiesAction extends PropertiesAction {
constructor(openmct) {
super(openmct);
@@ -52,24 +53,31 @@ export default class EditPropertiesAction extends PropertiesAction {
* @private
*/
_onSave(changes) {
+ if (!this.openmct.objects.isTransactionActive()) {
+ this.openmct.objects.startTransaction();
+ }
+
try {
Object.entries(changes).forEach(([key, value]) => {
- const properties = key.split('.');
- let object = this.domainObject;
- const propertiesLength = properties.length;
- properties.forEach((property, index) => {
- const isComplexProperty = propertiesLength > 1 && index !== propertiesLength - 1;
- if (isComplexProperty && object[property] !== null) {
- object = object[property];
- } else {
- object[property] = value;
- }
- });
+ const existingValue = this.domainObject[key];
+ if (!(Array.isArray(existingValue)) && (typeof existingValue === 'object')) {
+ value = {
+ ...existingValue,
+ ...value
+ };
+ }
- object = value;
this.openmct.objects.mutate(this.domainObject, key, value);
- this.openmct.notifications.info('Save successful');
});
+ const transaction = this.openmct.objects.getActiveTransaction();
+
+ return transaction.commit()
+ .catch(error => {
+ throw error;
+ }).finally(() => {
+ this.openmct.objects.endTransaction();
+ });
+
} catch (error) {
this.openmct.notifications.error('Error saving objects');
console.error(error);