ultrawidify/src/options/controls-settings/command-builder/CommandAddEdit.vue

163 lines
4.3 KiB
Vue
Raw Normal View History

<template>
<div class="">
<div class="window-content">
<!-- ACTION SELECT -->
<div class="flex flex-row">
<div class="flex label-secondary form-label">
<span class="w100">
Select action:
</span>
</div>
<div class="flex flex-grow flex-input">
<select class=""
:value="selectedAction"
@change="setAction($event.target.value)"
>
<option :value="undefined" selected disabled>Select ...</option>
<option v-for="(action, key) in ActionList"
:value="key"
:key="key"
>
{{action.name}}
</option>
</select>
</div>
</div>
<!-- ARGUMENT SELECT -->
<div v-if="selectedAction && ActionList[selectedAction]"
class="flex flex-row">
<div class="flex label-secondary form-label">
<span class="w100">
Select action parameter:
</span>
</div>
<div class="flex flex-grow flex-input">
<select class=""
:value="selectedArgument ? selectedArgument.arg : undefined"
@change="setArgument($event.target.value)"
>
<option :value="undefined" selected disabled>Select ...</option>
2019-03-10 23:27:50 +01:00
<option v-for="arg of ActionList[selectedAction].args"
:key="arg.arg"
:value="arg.arg"
>
{{arg.name}}
</option>
</select>
</div>
</div>
<!-- CUSTOM ARGUMENT INPUT -->
<div v-if="selectedArgument && selectedArgument.customArg">
<div class="flex flex-row">
<div class="flex label-secondary form-label">
<span class="w100">
{{selectedArgument.name}}:
</span>
</div>
<div class="flex flex-grow flex-input">
<input type="text"
class="w100"
2020-11-22 22:12:37 +01:00
:value="customArgumentValue"
@input="setCustomValue($event.target.value, selectedArgument.customSetter)"
>
</div>
</div>
<div class="flex flex-row">
<div v-if="selectedArgument.hintHTML" v-html="selectedArgument.hintHTML">
</div>
</div>
</div>
</div>
2019-05-22 01:03:15 +02:00
<div class="flex flex-row flex-end close-save-button-margin">
<div class="button"
@click="$emit('close-popup')"
>
Cancel
</div>
<div class="button"
@click="emitCommand()"
>
Save
</div>
</div>
</div>
</template>
<script>
import ActionList from '../../../ext/conf/ActionList';
import StretchType from '../../../common/enums/StretchType.enum';
export default {
data () {
return {
2021-04-01 21:23:59 +02:00
StretchType: StretchType,
ActionList: ActionList,
selectedAction: undefined,
selectedArgument: undefined,
customArgumentValue: undefined
}
},
created () {
if (this.action) {
this.selectedAction = this.action.action;
this.selectedArgument = {
name: ActionList[this.action.action].args.find(x => x.arg === this.action.arg) || ActionList[this.action.action].args.find(x => x.customArg),
arg: this.action.arg
}
2019-03-10 23:27:50 +01:00
this.customArgumentValue = this.action.customArg;
}
},
mounted() {
},
props: {
action: Object,
scope: String,
},
methods: {
setAction(cmd) {
this.selectedAction = cmd;
this.selectedArgument = undefined;
this.customArgumentValue = undefined;
},
setArgument(arg) {
this.selectedArgument = ActionList[this.selectedAction].args.find(x => x.arg == arg);
this.customArgumentValue = undefined;
},
2020-11-22 22:12:37 +01:00
setCustomValue(value, customSetter) {
if (!customSetter) {
this.customArgumentValue = value;
} else {
this.customArgumentValue = customSetter(value);
}
},
emitCommand() {
this.$emit(
'set-command',
this.selectedAction,
2019-03-10 23:27:50 +01:00
this.selectedArgument.arg,
this.customArgumentValue
);
}
}
}
2019-05-22 01:03:15 +02:00
</script>
<style>
.form-label {
width: 15rem;
text-align: left;
/* text-align: right; */
vertical-align: baseline;
}
.close-save-button-margin {
padding-top: 25px;
}
</style>