remove condition with persistance

This commit is contained in:
Joel McKinnon 2020-01-10 12:59:43 -08:00
parent d819c6efe2
commit d0e8f650be
2 changed files with 15 additions and 11 deletions

View File

@ -31,6 +31,7 @@
<div class="condition-collection"> <div class="condition-collection">
<div v-for="condition in conditionCollection" <div v-for="condition in conditionCollection"
:key="condition.key" :key="condition.key"
class="conditionArea"
> >
<div v-if="isEditing"> <div v-if="isEditing">
<ConditionEdit :is-default="condition.isDefault" <ConditionEdit :is-default="condition.isDefault"
@ -74,7 +75,7 @@ export default {
}, },
mounted() { mounted() {
this.instantiate = this.openmct.$injector.get('instantiate'); this.instantiate = this.openmct.$injector.get('instantiate');
this.conditionCollection = this.domainObject.configuration.conditionCollection; this.conditionCollection = this.domainObject.configuration.conditionCollection || this.conditionCollection;
}, },
methods: { methods: {
added(conditionDO) { added(conditionDO) {

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="conditionArea c-cs-editui__conditions" <div class="c-cs-editui__conditions"
:class="['widget-condition', { 'widget-condition--current': isCurrent }]" :class="['widget-condition', { 'widget-condition--current': isCurrent }]"
> >
<div class="title-bar"> <div class="title-bar">
@ -94,16 +94,19 @@ export default {
}, },
methods: { methods: {
removeCondition(ev) { removeCondition(ev) {
let conditionDiv = ev.target.closest('.conditionArea'); const conditionDiv = ev.target.closest('.conditionArea');
let conditionCollectionDiv = conditionDiv.closest('.condition-collection'); const conditionCollectionDiv = conditionDiv.closest('.condition-collection');
let index = Array.from(conditionDiv.parentNode.children).indexOf(conditionDiv) const index = Array.from(conditionCollectionDiv.children).indexOf(conditionDiv);
//Array.from(element.parentNode.children).indexOf(element) this.domainObject.configuration.conditionCollection.splice(index, 1);
//console.log(`conditionDiv.nodeName: ${conditionDiv.nodeName}`); this.persist()
console.log(`index: ${index}`); },
console.log(`conditionCollectionDiv.children.length: ${conditionCollectionDiv.childNodes.length}`); persist(index) {
console.log(this.domainObject.configuration.conditionCollection.length); if (index) {
// this.conditions.splice(index, 1); this.openmct.objects.mutate(this.domainObject, `configuration.conditionCollection[${index}]`, this.domainObject.configuration.conditionCollection[index]);
} else {
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.domainObject.configuration.conditionCollection);
}
} }
} }
} }