From 06a23ea29aee0d3fd59003516fea82551382ad41 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Thu, 28 Mar 2024 15:45:39 +0100 Subject: [PATCH] [web] Check validity of URL --- web-src/src/components/ModalDialogAddRss.vue | 9 ++++++++- .../src/components/ModalDialogAddUrlStream.vue | 17 +++++++++++++---- web-src/src/mystyles.scss | 8 ++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/web-src/src/components/ModalDialogAddRss.vue b/web-src/src/components/ModalDialogAddRss.vue index c861575a..8a02200e 100644 --- a/web-src/src/components/ModalDialogAddRss.vue +++ b/web-src/src/components/ModalDialogAddRss.vue @@ -13,10 +13,11 @@ v-model="url" class="input is-shadowless" type="url" - pattern="http[s]?://.*" + pattern="http[s]?://.+" required :placeholder="$t('dialog.add.rss.placeholder')" :disabled="loading" + @input="check_url" />

@@ -38,6 +39,7 @@ @@ -66,6 +68,7 @@ export default { data() { return { + disabled: true, loading: false, url: '' } @@ -96,6 +99,10 @@ export default { .catch(() => { this.loading = false }) + }, + check_url(event) { + const { validity } = event.target + this.disabled = validity.patternMismatch || validity.valueMissing } } } diff --git a/web-src/src/components/ModalDialogAddUrlStream.vue b/web-src/src/components/ModalDialogAddUrlStream.vue index 125509a3..4408f3a5 100644 --- a/web-src/src/components/ModalDialogAddUrlStream.vue +++ b/web-src/src/components/ModalDialogAddUrlStream.vue @@ -13,10 +13,11 @@ v-model="url" class="input is-shadowless" type="url" - pattern="http[s]?://.*" + pattern="http[s]?://.+" required :placeholder="$t('dialog.add.stream.placeholder')" :disabled="loading" + @input="check_url" />

@@ -36,11 +37,16 @@
- + @@ -69,6 +75,7 @@ export default { data() { return { + disabled: true, loading: false, url: '' } @@ -78,7 +85,6 @@ export default { show() { if (this.show) { this.loading = false - // We need to delay setting the focus to the input field until the field is part of the dom and visible setTimeout(() => { this.$refs.url_field.focus() @@ -100,7 +106,10 @@ export default { this.loading = false }) }, - + check_url(event) { + const { validity } = event.target + this.disabled = validity.patternMismatch || validity.valueMissing + }, play() { this.loading = true webapi diff --git a/web-src/src/mystyles.scss b/web-src/src/mystyles.scss index b8e31573..43ab6d9a 100644 --- a/web-src/src/mystyles.scss +++ b/web-src/src/mystyles.scss @@ -215,6 +215,14 @@ a.navbar-item { min-height: calc(100vh - calc(2 * $navbar-height)); } +.is-disabled { + cursor: not-allowed; + opacity: 0.5; + > * { + pointer-events: none; + } +} + .fd-cover { align-items: center; display: flex;