fixed set output field

This commit is contained in:
Joel McKinnon 2020-02-12 12:45:38 -08:00
parent 2b5d6beb84
commit 2415d785cc

View File

@ -58,15 +58,15 @@
> >
<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="option.key"
:value="option" :value="option.key"
> >
{{ option }} {{ option.text }}
</option> </option>
</select> </select>
<input v-if="selectedOutputKey === outputOptions[2]" <input v-if="selectedOutputKey === outputOptions[2].key"
v-model="domainObject.configuration.output" v-model="domainObject.configuration.output"
class="t-condition-input__output" class="t-condition-name-input"
type="text" type="text"
> >
</span> </span>
@ -178,8 +178,21 @@ export default {
expanded: true, expanded: true,
trigger: 'any', trigger: 'any',
selectedOutputKey: '', selectedOutputKey: '',
stringOutputField: {}, stringOutputField: false,
outputOptions: ['false', 'true', 'string'] outputOptions: [
{
key: 'false',
text: 'False'
},
{
key: 'true',
text: 'True'
},
{
key: 'string',
text: 'String'
}
]
}; };
}, },
destroyed() { destroyed() {
@ -197,8 +210,8 @@ export default {
}, },
methods: { methods: {
initialize() { initialize() {
if (!this.domainObject.isDefault) {
this.setOutput(); this.setOutput();
if (!this.domainObject.isDefault) {
this.conditionClass = new ConditionClass(this.domainObject, this.openmct); this.conditionClass = new ConditionClass(this.domainObject, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this)); this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
} }
@ -249,8 +262,6 @@ export default {
}, },
setOutput() { setOutput() {
let conditionOutput = this.domainObject.configuration.output; let conditionOutput = this.domainObject.configuration.output;
if (!conditionOutput) {
if (conditionOutput !== 'false' && conditionOutput !== 'true') { if (conditionOutput !== 'false' && conditionOutput !== 'true') {
this.selectedOutputKey = this.outputOptions[2].key; this.selectedOutputKey = this.outputOptions[2].key;
} else { } else {
@ -260,23 +271,22 @@ export default {
this.selectedOutputKey = this.outputOptions[0].key; this.selectedOutputKey = this.outputOptions[0].key;
} }
} }
}
}, },
persist() { persist() {
this.openmct.objects.mutate(this.domainObject, 'configuration', this.domainObject.configuration); this.openmct.objects.mutate(this.domainObject, 'configuration', this.domainObject.configuration);
}, },
checkInputValue() { checkInputValue() {
if (this.selectedOutputKey === this.outputOptions[2].key) { if (this.selectedOutputOption === this.outputOptions[2].key) {
this.domainObject.configuration.output = ''; this.domainObject.configuration.output = '';
} else { } else {
this.domainObject.configuration.output = this.selectedOutputKey; this.domainObject.configuration.output = this.selectedOutputOption;
} }
}, },
updateOutputOption(ev) { updateOutputOption(ev) {
if (this.selectedOutputKey === this.outputOptions[2].key) { if (this.selectedOutputOption === this.outputOptions[2].key) {
this.domainObject.configuration.output = ''; this.domainObject.configuration.output = '';
} else { } else {
this.domainObject.configuration.output = this.selectedOutputKey; this.domainObject.configuration.output = this.selectedOutputOption;
} }
}, },
updateCurrentCondition() { updateCurrentCondition() {