Files
PhotonVision/photon-client/src/components/common/cv-input.vue

65 lines
1.4 KiB
Vue
Raw Normal View History

2019-09-28 21:42:04 +03:00
<template>
<div>
<v-row
dense
align="center"
>
<v-col :cols="labelCols || (12 - (inputCols || 8))">
<tooltipped-label
:tooltip="tooltip"
:text="name"
/>
</v-col>
<v-col :cols="inputCols || 8">
<v-text-field
v-model="localValue"
dark
dense
color="accent"
:disabled="disabled"
:error-messages="errorMessage"
:rules="rules"
class="mt-1 pt-2"
@keydown="handleKeyboard"
/>
</v-col>
</v-row>
</div>
2019-09-28 21:42:04 +03:00
</template>
2019-09-28 21:42:04 +03:00
<script>
import TooltippedLabel from "./cv-tooltipped-label";
2019-09-28 21:42:04 +03:00
export default {
name: 'Input',
components: {
TooltippedLabel
},
// eslint-disable-next-line vue/require-prop-types
props: ['name', 'value', 'disabled', 'errorMessage', 'inputCols', 'labelCols', 'rules', 'tooltip'],
2019-09-28 21:42:04 +03:00
data() {
2019-10-29 23:58:06 +02:00
return {}
2019-09-28 21:42:04 +03:00
},
2019-10-29 23:58:06 +02:00
computed: {
localValue: {
get() {
2019-09-28 21:42:04 +03:00
return this.value;
},
2019-10-29 23:58:06 +02:00
set(value) {
this.$emit('input', value);
2019-09-28 21:42:04 +03:00
}
}
},
methods: {
handleKeyboard(event) {
if (event.key === "Enter") {
this.$emit("Enter");
}
}
2019-09-28 21:42:04 +03:00
}
}
</script>
<style lang="css" scoped>
</style>