fix: webcam create/edit form validation
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
parent
6fa1c28bc4
commit
a2d90df97c
@ -20,7 +20,7 @@
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card flat v-else>
|
<v-card flat v-else>
|
||||||
<v-form v-model="form.valid" @submit.prevent="saveWebcam">
|
<v-form v-model="form.valid" ref="webcamForm" @submit.prevent="saveWebcam">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
{{ form.id === null ? $t("Settings.WebcamsTab.CreateWebcam") : $t("Settings.WebcamsTab.EditWebcam") }}
|
{{ form.id === null ? $t("Settings.WebcamsTab.CreateWebcam") : $t("Settings.WebcamsTab.EditWebcam") }}
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
@ -65,7 +65,7 @@
|
|||||||
v-model="form.urlStream"
|
v-model="form.urlStream"
|
||||||
:label="$t('Settings.WebcamsTab.UrlStream')"
|
:label="$t('Settings.WebcamsTab.UrlStream')"
|
||||||
hide-details="auto"
|
hide-details="auto"
|
||||||
:rules="[rules.required]"
|
:rules="form.service !== 'mjpegstreamer-adaptive' ? [rules.required] : []"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
v-model="form.urlSnapshot"
|
v-model="form.urlSnapshot"
|
||||||
:label="$t('Settings.WebcamsTab.UrlSnapshot')"
|
:label="$t('Settings.WebcamsTab.UrlSnapshot')"
|
||||||
hide-details="auto"
|
hide-details="auto"
|
||||||
:rules="[rules.requiredMjpegAdaptive]"
|
:rules="form.service === 'mjpegstreamer-adaptive' ? [rules.required] : []"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@ -210,10 +210,13 @@ export default class SettingsWebcamsTab extends Mixins(BaseMixin) {
|
|||||||
|
|
||||||
private rules = {
|
private rules = {
|
||||||
required: (value: string) => value !== '' || this.$t('Settings.WebcamsTab.Required'),
|
required: (value: string) => value !== '' || this.$t('Settings.WebcamsTab.Required'),
|
||||||
requiredMjpegAdaptive: (value: string) => (value !== '' && this.form.service === 'mjpegstreamer-adaptive') || this.$t('Settings.WebcamsTab.Required'),
|
|
||||||
unique: (value: string) => !this.existsWebcamName(value) || this.$t('Settings.WebcamsTab.NameAlreadyExists'),
|
unique: (value: string) => !this.existsWebcamName(value) || this.$t('Settings.WebcamsTab.NameAlreadyExists'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$refs!: {
|
||||||
|
webcamForm: any
|
||||||
|
}
|
||||||
|
|
||||||
get webcams() {
|
get webcams() {
|
||||||
return this.$store.getters['gui/webcams/getWebcams'] ?? []
|
return this.$store.getters['gui/webcams/getWebcams'] ?? []
|
||||||
}
|
}
|
||||||
@ -278,6 +281,10 @@ export default class SettingsWebcamsTab extends Mixins(BaseMixin) {
|
|||||||
|
|
||||||
this.form.bool = true
|
this.form.bool = true
|
||||||
this.form.valid = false
|
this.form.valid = false
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.webcamForm?.validate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
saveWebcam() {
|
saveWebcam() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user