mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Merge pull request #3805 from nichwall/text_input_date_validation
Text input date validation
This commit is contained in:
commit
e6181196a7
@ -113,6 +113,10 @@ export default {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
console.log('updateResult', updateResult)
|
console.log('updateResult', updateResult)
|
||||||
|
} else if (!lastEpisodeCheck) {
|
||||||
|
this.$toast.error(this.$strings.ToastDateTimeInvalidOrIncomplete)
|
||||||
|
this.checkingNewEpisodes = false
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$axios
|
this.$axios
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<ui-dropdown v-model="newEpisode.episodeType" :label="$strings.LabelEpisodeType" :items="episodeTypes" small />
|
<ui-dropdown v-model="newEpisode.episodeType" :label="$strings.LabelEpisodeType" :items="episodeTypes" small />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-2/5 p-1">
|
<div class="w-2/5 p-1">
|
||||||
<ui-text-input-with-label v-model="pubDateInput" @input="updatePubDate" type="datetime-local" :label="$strings.LabelPubDate" />
|
<ui-text-input-with-label v-model="pubDateInput" ref="pubdate" type="datetime-local" :label="$strings.LabelPubDate" @input="updatePubDate" />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full p-1">
|
<div class="w-full p-1">
|
||||||
<ui-text-input-with-label v-model="newEpisode.title" :label="$strings.LabelTitle" />
|
<ui-text-input-with-label v-model="newEpisode.title" :label="$strings.LabelTitle" />
|
||||||
@ -145,11 +145,18 @@ export default {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check pubdate is valid if it is being updated. Cannot be set to null in the web client
|
||||||
|
if (this.newEpisode.pubDate === null && this.$refs.pubdate?.$refs?.input?.isInvalidDate) {
|
||||||
|
this.$toast.error(this.$strings.ToastDateTimeInvalidOrIncomplete)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const updatedDetails = this.getUpdatePayload()
|
const updatedDetails = this.getUpdatePayload()
|
||||||
if (!Object.keys(updatedDetails).length) {
|
if (!Object.keys(updatedDetails).length) {
|
||||||
this.$toast.info(this.$strings.ToastNoUpdatesNecessary)
|
this.$toast.info(this.$strings.ToastNoUpdatesNecessary)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.updateDetails(updatedDetails)
|
return this.updateDetails(updatedDetails)
|
||||||
},
|
},
|
||||||
async updateDetails(updatedDetails) {
|
async updateDetails(updatedDetails) {
|
||||||
|
@ -1,24 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="wrapper" class="relative">
|
<div ref="wrapper" class="relative">
|
||||||
<input
|
<input :id="inputId" :name="inputName" ref="input" v-model="inputValue" :type="actualType" :step="step" :min="min" :readonly="readonly" :disabled="disabled" :placeholder="placeholder" dir="auto" class="rounded bg-primary text-gray-200 focus:bg-bg focus:outline-none border h-full w-full" :class="classList" @keyup="keyup" @change="change" @focus="focused" @blur="blurred" />
|
||||||
:id="inputId"
|
|
||||||
:name="inputName"
|
|
||||||
ref="input"
|
|
||||||
v-model="inputValue"
|
|
||||||
:type="actualType"
|
|
||||||
:step="step"
|
|
||||||
:min="min"
|
|
||||||
:readonly="readonly"
|
|
||||||
:disabled="disabled"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
dir="auto"
|
|
||||||
class="rounded bg-primary text-gray-200 focus:border-gray-300 focus:bg-bg focus:outline-none border border-gray-600 h-full w-full"
|
|
||||||
:class="classList"
|
|
||||||
@keyup="keyup"
|
|
||||||
@change="change"
|
|
||||||
@focus="focused"
|
|
||||||
@blur="blurred"
|
|
||||||
/>
|
|
||||||
<div v-if="clearable && inputValue" class="absolute top-0 right-0 h-full px-2 flex items-center justify-center">
|
<div v-if="clearable && inputValue" class="absolute top-0 right-0 h-full px-2 flex items-center justify-center">
|
||||||
<span class="material-symbols text-gray-300 cursor-pointer" style="font-size: 1.1rem" @click.stop.prevent="clear">close</span>
|
<span class="material-symbols text-gray-300 cursor-pointer" style="font-size: 1.1rem" @click.stop.prevent="clear">close</span>
|
||||||
</div>
|
</div>
|
||||||
@ -65,7 +47,8 @@ export default {
|
|||||||
showPassword: false,
|
showPassword: false,
|
||||||
isHovering: false,
|
isHovering: false,
|
||||||
isFocused: false,
|
isFocused: false,
|
||||||
hasCopied: false
|
hasCopied: false,
|
||||||
|
isInvalidDate: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -84,6 +67,10 @@ export default {
|
|||||||
if (this.noSpinner) _list.push('no-spinner')
|
if (this.noSpinner) _list.push('no-spinner')
|
||||||
if (this.textCenter) _list.push('text-center')
|
if (this.textCenter) _list.push('text-center')
|
||||||
if (this.customInputClass) _list.push(this.customInputClass)
|
if (this.customInputClass) _list.push(this.customInputClass)
|
||||||
|
|
||||||
|
if (this.isInvalidDate) _list.push('border-error')
|
||||||
|
else _list.push('focus:border-gray-300 border-gray-600')
|
||||||
|
|
||||||
return _list.join(' ')
|
return _list.join(' ')
|
||||||
},
|
},
|
||||||
actualType() {
|
actualType() {
|
||||||
@ -118,6 +105,14 @@ export default {
|
|||||||
},
|
},
|
||||||
keyup(e) {
|
keyup(e) {
|
||||||
this.$emit('keyup', e)
|
this.$emit('keyup', e)
|
||||||
|
|
||||||
|
if (this.type === 'datetime-local') {
|
||||||
|
if (e.target.validity?.badInput) {
|
||||||
|
this.isInvalidDate = true
|
||||||
|
} else {
|
||||||
|
this.isInvalidDate = false
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
blur() {
|
blur() {
|
||||||
if (this.$refs.input) this.$refs.input.blur()
|
if (this.$refs.input) this.$refs.input.blur()
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<slot>
|
<slot>
|
||||||
<label :for="identifier" class="px-1 text-sm font-semibold" :class="{ 'text-gray-400': disabled }"
|
<label :for="identifier" class="px-1 text-sm font-semibold" :class="{ 'text-gray-400': disabled }">
|
||||||
>{{ label }}<em v-if="note" class="font-normal text-xs pl-2">{{ note }}</em></label
|
{{ label }}
|
||||||
>
|
<em v-if="note" class="font-normal text-xs pl-2">{{ note }}</em>
|
||||||
|
</label>
|
||||||
</slot>
|
</slot>
|
||||||
<ui-text-input :placeholder="placeholder || label" :inputId="identifier" ref="input" v-model="inputValue" :disabled="disabled" :readonly="readonly" :type="type" class="w-full" :class="inputClass" @blur="inputBlurred" />
|
<ui-text-input :placeholder="placeholder || label" :inputId="identifier" ref="input" v-model="inputValue" :disabled="disabled" :readonly="readonly" :type="type" class="w-full" :class="inputClass" @blur="inputBlurred" />
|
||||||
</div>
|
</div>
|
||||||
@ -57,4 +58,4 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -964,6 +964,7 @@
|
|||||||
"ToastCollectionRemoveSuccess": "Collection removed",
|
"ToastCollectionRemoveSuccess": "Collection removed",
|
||||||
"ToastCollectionUpdateSuccess": "Collection updated",
|
"ToastCollectionUpdateSuccess": "Collection updated",
|
||||||
"ToastCoverUpdateFailed": "Cover update failed",
|
"ToastCoverUpdateFailed": "Cover update failed",
|
||||||
|
"ToastDateTimeInvalidOrIncomplete": "Date and time is invalid or incomplete",
|
||||||
"ToastDeleteFileFailed": "Failed to delete file",
|
"ToastDeleteFileFailed": "Failed to delete file",
|
||||||
"ToastDeleteFileSuccess": "File deleted",
|
"ToastDeleteFileSuccess": "File deleted",
|
||||||
"ToastDeviceAddFailed": "Failed to add device",
|
"ToastDeviceAddFailed": "Failed to add device",
|
||||||
|
Loading…
Reference in New Issue
Block a user