diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue index 828b3af7ab..777c731908 100644 --- a/src/plugins/condition/components/ConditionCollection.vue +++ b/src/plugins/condition/components/ConditionCollection.vue @@ -23,19 +23,20 @@ v-show="isEditing" id="addCondition" class="c-cs-button c-cs-button--major add-condition-button" + @click="addCondition" > Add Condition -
- - - -
-
- - - +
+
+ +
+
+ +
@@ -46,7 +47,7 @@ import Condition from '../../condition/components/Condition.vue'; import ConditionEdit from '../../condition/components/ConditionEdit.vue'; export default { - inject: ['openmct'], + inject: ['openmct', 'domainObject'], components: { Condition, ConditionEdit @@ -56,10 +57,51 @@ export default { }, data() { return { - expanded: true + expanded: true, + conditions: [ + { + identifier: { + key: 'testConditionKey', + namespace: '' + }, + type: 'condition', + isDefault: true + } + ] }; }, + destroyed() { + this.composition.off('add', this.addCondition); + this.composition.off('remove', this.removeCondition); + this.composition.off('reorder', this.reorder); + }, + mounted() { + this.composition = this.openmct.composition.get(this.domainObject); + this.composition.on('add', this.addCondition); + this.composition.on('remove', this.removeCondition); + this.composition.on('reorder', this.reorder); + this.composition.load(); + }, methods: { + addCondition() { + let condition = {}; + condition.domainObject = this.domainObject; + condition.key = this.openmct.objects.makeKeyString(this.domainObject.identifier); + + this.conditions.unshift(condition); + }, + removeCondition(identifier) { + console.log(`remove condition`); + let index = _.findIndex(this.conditions, (condition) => this.openmct.objects.makeKeyString(identifier) === item.key); + + this.conditions.splice(index, 1); + }, + reorder(reorderPlan) { + let oldConditions = this.conditions.slice(); + reorderPlan.forEach((reorderEvent) => { + this.$set(this.conditions, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]); + }); + } } } diff --git a/src/plugins/condition/components/ConditionEdit.vue b/src/plugins/condition/components/ConditionEdit.vue index ff65284538..2eff394a24 100644 --- a/src/plugins/condition/components/ConditionEdit.vue +++ b/src/plugins/condition/components/ConditionEdit.vue @@ -37,6 +37,7 @@ >