Implemented personal settings
This commit is contained in:
65
frontend/src/components/form/InputStringWidget.vue
Normal file
65
frontend/src/components/form/InputStringWidget.vue
Normal file
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<label>
|
||||
<span :style="{ width: width + 'em' }">{{ $t(labelTr) }}</span>
|
||||
<input type="text" :value="value" :placeholder="$t(labelTr)" :title="$t(tooltipTr)"
|
||||
@input="validateAndUpdate($event.target.value)" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "InputStringWidget",
|
||||
props: {
|
||||
labelTr: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
tooltipTr: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
width: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 10
|
||||
},
|
||||
regex: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validateAndUpdate(value) {
|
||||
if (this.regex) {
|
||||
const pattern = new RegExp(this.regex);
|
||||
if (pattern.test(value)) {
|
||||
this.updateValue(value);
|
||||
}
|
||||
} else {
|
||||
this.updateValue(value);
|
||||
}
|
||||
},
|
||||
updateValue(value) {
|
||||
this.$emit("input", value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
label > span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
input {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user