diff --git a/src/plugins/condition/ConditionSetViewProvider.js b/src/plugins/condition/ConditionSetViewProvider.js
index 958c41af5b..0906abc06a 100644
--- a/src/plugins/condition/ConditionSetViewProvider.js
+++ b/src/plugins/condition/ConditionSetViewProvider.js
@@ -58,7 +58,7 @@ export default class ConditionSetViewProvider {
isEditing
}
},
- template: ''
+ template: ''
});
},
onEditModeChange: (isEditing) => {
diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue
index e067997626..50808dd27b 100644
--- a/src/plugins/condition/components/ConditionCollection.vue
+++ b/src/plugins/condition/components/ConditionCollection.vue
@@ -28,18 +28,18 @@
Add Condition
-
-
-
-
-
@@ -63,41 +63,28 @@ export default {
data() {
return {
expanded: true,
- conditions: [
- {
- identifier: {
- key: 'testConditionKey',
- namespace: ''
- },
- type: 'condition',
- isDefault: true
- }
- ],
- parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier)
+ parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier),
+ conditionCollection: [{
+ isDefault: true
+ }]
};
},
destroyed() {
- this.composition.off('add', this.added);
- // this.composition.off('remove', this.removeCondition);
- // this.composition.off('reorder', this.reorder);
+
},
mounted() {
this.instantiate = this.openmct.$injector.get('instantiate');
- this.composition = this.openmct.composition.get(this.domainObject);
- this.composition.on('add', this.added);
- // this.composition.on('remove', this.removeCondition);
- // this.composition.on('reorder', this.reorder);
- this.composition.load();
+ this.conditionCollection = this.domainObject.configuration.conditionCollection;
},
methods: {
added(conditionDO) {
- this.conditions.unshift(conditionDO);
+ this.conditionCollection.unshift(conditionDO);
},
addCondition() {
let conditionObjId = uuid();
let conditionObj = {
"composition": [],
- "name": "Condition"+this.conditions.length,
+ "name": "condition" + this.conditionCollection.length,
"type": "condition",
"id": conditionObjId,
"location": this.parentKeyString,
@@ -112,19 +99,27 @@ export default {
newDO.useCapability('location').setPrimaryLocation(this.parentKeyString);
let conditionDO = newDO.useCapability('adapter');
- this.composition.add(conditionDO);
+ this.conditionCollection.unshift(conditionDO);
+
+ this.persist();
},
removeCondition(identifier) {
- console.log(`remove condition`);
- // let index = _.findIndex(this.conditions, (condition) => this.openmct.objects.makeKeyString(identifier) === item.key);
+ let index = _.findIndex(this.conditionCollection, (condition) => this.openmct.objects.makeKeyString(identifier) === condition.identifier.key);
- // this.conditions.splice(index, 1);
+ this.conditionCollection.splice(index, 1);
},
reorder(reorderPlan) {
- let oldConditions = this.conditions.slice();
+ let oldConditions = this.conditionCollection.slice();
reorderPlan.forEach((reorderEvent) => {
- this.$set(this.conditions, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
+ this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
});
+ },
+ persist(index) {
+ if (index) {
+ this.openmct.objects.mutate(this.domainObject, `configuration.conditionCollection[${index}]`, this.conditionCollection[index]);
+ } else {
+ this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
+ }
}
}
}
diff --git a/src/plugins/condition/components/ConditionEdit.vue b/src/plugins/condition/components/ConditionEdit.vue
index 2eff394a24..189c112689 100644
--- a/src/plugins/condition/components/ConditionEdit.vue
+++ b/src/plugins/condition/components/ConditionEdit.vue
@@ -1,6 +1,5 @@
-
@@ -77,21 +76,33 @@
diff --git a/src/plugins/condition/plugin.js b/src/plugins/condition/plugin.js
index ced6477808..6c4bba0005 100644
--- a/src/plugins/condition/plugin.js
+++ b/src/plugins/condition/plugin.js
@@ -20,6 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ConditionSetViewProvider from './ConditionSetViewProvider.js';
+// import Condition from './Condition.js';
export default function ConditionPlugin() {
@@ -41,6 +42,9 @@ export default function ConditionPlugin() {
creatable: true,
cssClass: 'icon-summary-widget', // TODO: replace with class for new icon
initialize: function (domainObject) {
+ domainObject.configuration = {
+ conditionCollection: []
+ };
domainObject.composition = [];
}
});