deriving current output from current (blue) condition output and persisting

This commit is contained in:
Joel McKinnon 2020-01-14 17:07:32 -08:00
parent 78b885c508
commit 06a5207c6d
3 changed files with 26 additions and 36 deletions

View File

@ -47,8 +47,9 @@
<li> <li>
<label>Output</label> <label>Output</label>
<span class="controls"> <span class="controls">
<select class=""> <select v-model="condition.output">
<option value="false">false</option> <option value="false">false</option>
<option value="true">true</option>
</select> </select>
</span> </span>
</li> </li>
@ -82,6 +83,7 @@ export default {
mounted() { mounted() {
}, },
updated() { updated() {
console.log('updated conditionEdit');
this.updateCurrentCondition(); this.updateCurrentCondition();
this.persist() this.persist()
}, },

View File

@ -2,7 +2,7 @@
<div class="c-object-view u-contents"> <div class="c-object-view u-contents">
<div class="c-cs-edit w-condition-set"> <div class="c-cs-edit w-condition-set">
<div class="c-sw-edit__ui holder"> <div class="c-sw-edit__ui holder">
<CurrentOutput :current-output="currentOutput" /> <CurrentOutput :condition-collection="domainObject.conditionCollection" />
<TestData :is-editing="isEditing" /> <TestData :is-editing="isEditing" />
<ConditionCollection :is-editing="isEditing" <ConditionCollection :is-editing="isEditing"
:condition-collection="domainObject.conditionCollection" :condition-collection="domainObject.conditionCollection"
@ -29,33 +29,9 @@ export default {
}, },
data() { data() {
let conditionCollection = this.domainObject.configuration.conditionCollection; let conditionCollection = this.domainObject.configuration.conditionCollection;
let currentConditionIndex = 0;
return { return {
currentOutput: conditionCollection[currentConditionIndex].output, conditionCollection
conditionCollection,
currentConditionIndex
}
},
mounted() {
this.currentConditionIndex = this.getCurrentConditionIndex();
},
methods: {
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);
}
},
getCurrentConditionIndex() {
let currentConditionIndex;
this.conditionCollection.forEach((condition, index) => {
if (condition.isCurrent) {
currentConditionIndex = index;
}
});
return currentConditionIndex;
} }
} }
}; };

View File

@ -12,7 +12,7 @@
class="c-cs__ui_content" class="c-cs__ui_content"
> >
<div> <div>
<span class="current-output">{{ currentOutput }}</span> <span class="current-output">{{ conditionCollection[currentConditionIndex].output }}</span>
</div> </div>
</div> </div>
</section> </section>
@ -20,21 +20,33 @@
<script> <script>
export default { export default {
inject: ['openmct'], inject: ['openmct', 'domainObject'],
props: { props: {
currentOutput: {
type: String,
default: ''
},
isEditing: Boolean isEditing: Boolean
}, },
data() { data() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
let currentConditionIndex = 0;
return { return {
expanded: true expanded: true,
}; conditionCollection,
currentConditionIndex
}
},
mounted() {
this.currentConditionIndex = this.getCurrentConditionIndex();
}, },
methods: { methods: {
getCurrentConditionIndex() {
let currentConditionIndex;
this.conditionCollection.forEach((condition, index) => {
if (condition.isCurrent) {
currentConditionIndex = index;
}
});
return currentConditionIndex;
}
} }
} }
</script> </script>