refactored setOutput

This commit is contained in:
Joel McKinnon 2020-02-12 13:31:55 -08:00
parent 2415d785cc
commit 6e5e8f0ce8

View File

@ -58,13 +58,13 @@
> >
<option value="">- Select Output -</option> <option value="">- Select Output -</option>
<option v-for="option in outputOptions" <option v-for="option in outputOptions"
:key="option.key" :key="option"
:value="option.key" :value="option"
> >
{{ option.text }} {{ option.charAt(0).toUpperCase() + option.slice(1) }}
</option> </option>
</select> </select>
<input v-if="selectedOutputKey === outputOptions[2].key" <input v-if="selectedOutputKey === outputOptions[2]"
v-model="domainObject.configuration.output" v-model="domainObject.configuration.output"
class="t-condition-name-input" class="t-condition-name-input"
type="text" type="text"
@ -179,20 +179,7 @@ export default {
trigger: 'any', trigger: 'any',
selectedOutputKey: '', selectedOutputKey: '',
stringOutputField: false, stringOutputField: false,
outputOptions: [ outputOptions: ['false', 'true', 'string']
{
key: 'false',
text: 'False'
},
{
key: 'true',
text: 'True'
},
{
key: 'string',
text: 'String'
}
]
}; };
}, },
destroyed() { destroyed() {
@ -262,13 +249,11 @@ export default {
}, },
setOutput() { setOutput() {
let conditionOutput = this.domainObject.configuration.output; let conditionOutput = this.domainObject.configuration.output;
if (conditionOutput !== 'false' && conditionOutput !== 'true') { if (conditionOutput) {
this.selectedOutputKey = this.outputOptions[2].key; if (conditionOutput !== 'false' && conditionOutput !== 'true') {
} else { this.selectedOutputKey = 'string';
if (conditionOutput === 'true') {
this.selectedOutputKey = this.outputOptions[1].key;
} else { } else {
this.selectedOutputKey = this.outputOptions[0].key; this.selectedOutputKey = conditionOutput;
} }
} }
}, },
@ -276,14 +261,14 @@ export default {
this.openmct.objects.mutate(this.domainObject, 'configuration', this.domainObject.configuration); this.openmct.objects.mutate(this.domainObject, 'configuration', this.domainObject.configuration);
}, },
checkInputValue() { checkInputValue() {
if (this.selectedOutputOption === this.outputOptions[2].key) { if (this.selectedOutputOption === 'string') {
this.domainObject.configuration.output = ''; this.domainObject.configuration.output = '';
} else { } else {
this.domainObject.configuration.output = this.selectedOutputOption; this.domainObject.configuration.output = this.selectedOutputOption;
} }
}, },
updateOutputOption(ev) { updateOutputOption(ev) {
if (this.selectedOutputOption === this.outputOptions[2].key) { if (this.selectedOutputOption === 'string') {
this.domainObject.configuration.output = ''; this.domainObject.configuration.output = '';
} else { } else {
this.domainObject.configuration.output = this.selectedOutputOption; this.domainObject.configuration.output = this.selectedOutputOption;