Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a native datetime picker #3063

Merged
merged 1 commit into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions src/components/NcActionInput/NcActionInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ For the multiselect component, all events will be passed through. Please see the

<template>
<li class="action" :class="{ 'action--disabled': disabled }">
<span :class="{ 'action-input--picker': isDatePickerType , 'action-input-picker--disabled': disabled}"
<span :class="{ 'action-input--picker': datePickerType , 'action-input-picker--disabled': disabled}"
class="action-input"
@mouseleave="onLeave">
<!-- @slot Manually provide icon -->
Expand All @@ -54,18 +54,26 @@ For the multiselect component, all events will be passed through. Please see the
:disabled="disabled"
@submit.prevent="onSubmit">

<NcDatetimePicker v-if="isDatePickerType"
<NcDatetimePicker v-if="datePickerType"
ref="datetimepicker"
:value="value"
:placeholder="text"
:disabled="disabled"
:type="isDatePickerType"
:type="datePickerType"
:input-class="['mx-input', { focusable: isFocusable }]"
class="action-input__picker"
v-bind="$attrs"
@input="onInput"
@change="onChange" />

<NcDateTimePickerNative v-else-if="isNativePicker"
:id="idNativeDateTimePicker"
:value="value"
:type="nativeDatePickerType"
v-bind="$attrs"
@input="$emit('input', $event)"
@change="$emit('change', $event)" />

<NcMultiselect v-else-if="isMultiselectType"
:value="value"
:placeholder="text"
Expand Down Expand Up @@ -106,6 +114,7 @@ import ActionGlobalMixin from '../../mixins/actionGlobal.js'
import GenRandomId from '../../utils/GenRandomId.js'

import ArrowRight from 'vue-material-design-icons/ArrowRight.vue'
import NcDateTimePickerNative from '../NcDateTimePickerNative/index.js'

export default {
name: 'NcActionInput',
Expand All @@ -114,6 +123,7 @@ export default {
ArrowRight,
NcDatetimePicker,
NcMultiselect,
NcDateTimePickerNative,
},

mixins: [ActionGlobalMixin],
Expand Down Expand Up @@ -147,6 +157,20 @@ export default {
'email'].indexOf(type) > -1
},
},
/**
* id attribute for the native date time picker
*/
idNativeDateTimePicker: {
type: String,
default: 'date-time-picker_id',
},
/**
* Flag to use a native date time picker
*/
isNativePicker: {
type: Boolean,
default: false,
JuliaKirschenheuter marked this conversation as resolved.
Show resolved Hide resolved
},
/**
* value attribute of the input field
*/
Expand Down Expand Up @@ -190,15 +214,29 @@ export default {
return this.type === 'multiselect'
},

isDatePickerType() {
nativeDatePickerType() {
switch (this.type) {
case 'date':
case 'month':
case 'time':
case 'week':
case 'datetime-local':
return this.type
}
return false
},

case 'datetime-local':
return 'datetime'
datePickerType() {
if (!this.isNativePicker) {
switch (this.type) {
case 'date':
case 'month':
case 'time':
return this.type

case 'datetime-local':
return 'datetime'
}
}
return false
},
Expand Down
Loading