[Conditionals] default condition handling (#2827)

* Sisplay default condition output by... default
This commit is contained in:
David Tsay 2020-03-31 12:32:06 -07:00 committed by GitHub
parent 079201273e
commit 4220a8a68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 4 deletions

View File

@ -86,7 +86,6 @@
<select v-model="selectedOutputSelection"
@change="setOutputValue"
>
<option value="">- Select Output -</option>
<option v-for="option in outputOptions"
:key="option"
:value="option"

View File

@ -110,10 +110,14 @@ export default {
conditions: [],
telemetryObjs: [],
moveIndex: Number,
isDragging: false
isDragging: false,
defaultOutput: undefined
};
},
watch: {
defaultOutput(newOutput, oldOutput) {
this.$emit('updateDefaultOutput', newOutput);
},
testData: {
handler() {
this.updateTestData();
@ -141,6 +145,7 @@ export default {
this.observeForChanges();
this.conditionManager = new ConditionManager(this.domainObject, this.openmct);
this.conditionManager.on('conditionSetResultUpdated', this.handleConditionSetResultUpdated);
this.updateDefaultCondition();
},
methods: {
handleConditionSetResultUpdated(data) {
@ -149,8 +154,14 @@ export default {
observeForChanges() {
this.stopObservingForChanges = this.openmct.objects.observe(this.domainObject, 'configuration.conditionCollection', (newConditionCollection) => {
this.conditionCollection = newConditionCollection;
this.updateDefaultCondition();
});
},
updateDefaultCondition() {
const defaultCondition = this.domainObject.configuration.conditionCollection
.find(conditionConfiguration => conditionConfiguration.isDefault);
this.defaultOutput = defaultCondition.configuration.output;
},
setMoveIndex(index) {
this.moveIndex = index;
this.isDragging = true;

View File

@ -30,7 +30,9 @@
<template v-if="currentConditionOutput">
{{ currentConditionOutput }}
</template>
<template v-else>No output selected</template>
<template v-else>
{{ defaultConditionOutput }}
</template>
</div>
</section>
<TestData :is-editing="isEditing"
@ -42,6 +44,7 @@
:is-editing="isEditing"
:test-data="testData"
@conditionSetResultUpdated="updateCurrentOutput"
@updateDefaultOutput="updateDefaultOutput"
@telemetryUpdated="updateTelemetry"
/>
</div>
@ -63,6 +66,7 @@ export default {
data() {
return {
currentConditionOutput: '',
defaultConditionOutput: '',
telemetryObjs: [],
testData: {}
}
@ -78,6 +82,9 @@ export default {
updateCurrentOutput(currentConditionResult) {
this.currentConditionOutput = currentConditionResult.output;
},
updateDefaultOutput(output) {
this.currentConditionOutput = output;
},
updateTelemetry(telemetryObjs) {
this.telemetryObjs = telemetryObjs;
},

View File

@ -44,7 +44,7 @@ export default function ConditionPlugin() {
id: uuid(),
configuration: {
name: 'Default',
output: 'false',
output: 'Default',
trigger: 'all',
criteria: []
},