Skip to content

Commit

Permalink
fix(NcDateTimePickerNative): make 'id' non-required prop, generate de…
Browse files Browse the repository at this point in the history
…fault instead

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>

(cherry picked from commit f23681f)
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jan 29, 2025
1 parent a7e2303 commit c03ba4b
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
<NcSelect v-bind="props" v-model="type" />
<NcDateTimePickerNative
v-model="value"
:id="id"
:label="label"
:type="type" />
</div>
Expand All @@ -45,7 +44,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
},
type: 'datetime-local',
value: new Date(),
id: 'date-time-picker',
label: 'Select a new date or time',
}
},
Expand All @@ -66,7 +64,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
<span>Picked date: {{ value || 'null' }}</span>
<NcDateTimePickerNative
v-model="value"
:id="id"
:min="yesterdayDate"
:max="someDate"
:label="label"
Expand All @@ -79,7 +76,6 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p
data() {
return {
value: new Date(),
id: 'date-time-picker',
label: 'Please select a new date',
yesterdayDate: new Date(new Date().setDate(new Date().getDate() - 1)),
someDate: new Date(new Date().setDate(new Date().getDate() + 7)),
Expand Down Expand Up @@ -108,6 +104,7 @@ All available types are: 'date', 'datetime-local', 'month', 'time' and 'week', p

<script>
import ScopeComponent from '../../utils/ScopeComponent.js'
import GenRandomId from '../../utils/GenRandomId.js'

const inputDateTypes = ['date', 'datetime-local', 'month', 'time', 'week']

Expand All @@ -132,7 +129,8 @@ export default ScopeComponent({
*/
id: {
type: String,
required: true,
default: () => 'date-time-picker-' + GenRandomId(),
validator: id => id.trim() !== '',
},
/**
* type attribute of the input field
Expand Down

0 comments on commit c03ba4b

Please sign in to comment.