Skip to content

Commit

Permalink
fix: handling of empty values in NcDateTimePickerNative
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
  • Loading branch information
st3iny committed Oct 4, 2023
1 parent 41e2117 commit e8d5ec3
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/components/NcDateTimePickerNative/NcDateTimePickerNative.vue
Expand Up @@ -2,6 +2,7 @@
- @copyright Copyright (c) 2022 Julia Kirschenheuter <julia.kirschenheuter@nextcloud.com>
-
- @author Julia Kirschenheuter <julia.kirschenheuter@nextcloud.com>
- @author Richard Steinmetz <richard@steinmetz.cloud>
-
- @license GNU AGPL version 3 or any later version
-
Expand Down Expand Up @@ -33,13 +34,16 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
#### Usage: type='datetime-local'
```vue
<template>
<span>
<NcDateTimePickerNative
v-model="value"
:id="id"
:label="label"
type="datetime-local" />
</span>
<div>
<span>
<span>Picked date: {{ valueString }}</span>
<NcDateTimePickerNative
v-model="value"
:id="id"
:label="label"
type="datetime-local" />
</span>
</div>
</template>
<script>
export default {
Expand All @@ -50,6 +54,14 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
label: 'please select a new date',
}
},
computed: {
valueString() {
if (this.value === null) {
return 'null'
}
return this.value.toString()
}
}
}
</script>
```
Expand Down Expand Up @@ -163,10 +175,11 @@ export default {
* The date is – like the `Date` object in JavaScript – tied to UTC.
* The selected time zone does not have an influence of the selected time and date value.
* You have to translate the time yourself when you want to factor in time zones.
* Pass null to clear the input field.
*/
value: {
type: Date,
required: true,
default: null,
},
/**
Expand Down Expand Up @@ -265,7 +278,7 @@ export default {
*
* @return {string} empty string
*/
return this.$emit('input', '')
return this.$emit('input', null)
}
if (this.type === 'time') {
const time = $event.target.value
Expand Down

0 comments on commit e8d5ec3

Please sign in to comment.