feat: default date/datetime value as current date

This commit is contained in:
Pranav C
2024-08-19 07:55:03 +00:00
parent fbf4d937d7
commit f4e68271e2
16 changed files with 153 additions and 26 deletions

View File

@@ -15,6 +15,7 @@ interface Props {
} | null
isCellInputField?: boolean
pickerType?: 'date' | 'time' | 'year' | 'month'
showCurrentDateOption?: boolean
}
const props = withDefaults(defineProps<Props>(), {
@@ -29,7 +30,7 @@ const props = withDefaults(defineProps<Props>(), {
isCellInputField: false,
pickerType: 'date',
})
const emit = defineEmits(['update:selectedDate', 'update:pageDate', 'update:selectedWeek', 'update:pickerType'])
const emit = defineEmits(['update:selectedDate', 'update:pageDate', 'update:selectedWeek', 'update:pickerType', 'currentDate'])
// Page date is the date we use to manage which month/date that is currently being displayed
const pageDate = useVModel(props, 'pageDate', emit)
@@ -250,10 +251,19 @@ const paginate = (action: 'next' | 'prev') => {
</span>
</span>
</div>
<div v-if="isCellInputField" class="flex items-center justify-center px-2 pb-2 pt-1">
<div v-if="isCellInputField" class="flex items-center justify-center px-2 pb-2 pt-1 gap-2">
<NcButton class="nc-date-picker-now-btn !h-7" size="small" type="secondary" @click="handleSelectDate(dayjs())">
<span class="text-small"> {{ $t('labels.today') }} </span>
</NcButton>
<NcButton
v-if="showCurrentDateOption"
class="nc-date-picker-now-btn !h-7"
size="small"
type="secondary"
@click="emit('currentDate')"
>
<span class="text-small"> {{ $t('labels.currentDate') }} </span>
</NcButton>
</div>
</div>
</div>