[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" <select v-model="selectedOutputSelection"
@change="setOutputValue" @change="setOutputValue"
> >
<option value="">- Select Output -</option>
<option v-for="option in outputOptions" <option v-for="option in outputOptions"
:key="option" :key="option"
:value="option" :value="option"

View File

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

View File

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

View File

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