diff --git a/packages/nc-gui/components/cell/DatePicker.vue b/packages/nc-gui/components/cell/DatePicker.vue index bbc33d93da..791988a3a6 100644 --- a/packages/nc-gui/components/cell/DatePicker.vue +++ b/packages/nc-gui/components/cell/DatePicker.vue @@ -9,7 +9,7 @@ interface Props { const { modelValue, isPk } = defineProps() -const emit = defineEmits(['update:modelValue']) +const emit = defineEmits(['update:modelValue', 'currentDate']) const { t } = useI18n() @@ -287,6 +287,11 @@ function handleSelectDate(value?: dayjs.Dayjs) { localState.value = value open.value = false } + +const currentDate = ($event) => { + emit('currentDate', $event) + open.value = false +} diff --git a/packages/nc-gui/components/cell/DateTimePicker.vue b/packages/nc-gui/components/cell/DateTimePicker.vue index 120ec17e26..9b31d20d9f 100644 --- a/packages/nc-gui/components/cell/DateTimePicker.vue +++ b/packages/nc-gui/components/cell/DateTimePicker.vue @@ -10,7 +10,7 @@ interface Props { const { modelValue, isPk, isUpdatedFromCopyNPaste } = defineProps() -const emit = defineEmits(['update:modelValue']) +const emit = defineEmits(['update:modelValue', 'currentDate']) const timeFormatsObj = { [timeFormats[0]]: 'hh:mm A', @@ -425,6 +425,11 @@ const cellValue = computed( localState.value?.format(parseProp(column.value.meta).is12hrFormat ? timeFormatsObj[timeFormat.value] : timeFormat.value) ?? '', ) + +const currentDate = ($event) => { + open.value = false + emit('currentDate', $event) +} diff --git a/packages/nc-gui/components/nc/DateWeekSelector.vue b/packages/nc-gui/components/nc/DateWeekSelector.vue index ffccab3a02..8c49fe7cf5 100644 --- a/packages/nc-gui/components/nc/DateWeekSelector.vue +++ b/packages/nc-gui/components/nc/DateWeekSelector.vue @@ -15,6 +15,7 @@ interface Props { } | null isCellInputField?: boolean pickerType?: 'date' | 'time' | 'year' | 'month' + showCurrentDateOption?: boolean } const props = withDefaults(defineProps(), { @@ -29,7 +30,7 @@ const props = withDefaults(defineProps(), { 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') => { -
+
{{ $t('labels.today') }} + + {{ $t('labels.currentDate') }} +
diff --git a/packages/nc-gui/components/nc/MonthYearSelector.vue b/packages/nc-gui/components/nc/MonthYearSelector.vue index 6fade88d10..136a20b89b 100644 --- a/packages/nc-gui/components/nc/MonthYearSelector.vue +++ b/packages/nc-gui/components/nc/MonthYearSelector.vue @@ -8,6 +8,7 @@ interface Props { hideCalendar?: boolean isCellInputField?: boolean pickerType?: 'date' | 'time' | 'year' | 'month' + showCurrentDateOption?: boolean } const props = withDefaults(defineProps(), { @@ -18,7 +19,7 @@ const props = withDefaults(defineProps(), { isCellInputField: false, pickerType: 'date', }) -const emit = defineEmits(['update:selectedDate', 'update:pageDate', 'update:pickerType']) +const emit = defineEmits(['update:selectedDate', 'update:pageDate', 'update:pickerType', 'currentDate']) const pageDate = useVModel(props, 'pageDate', emit) @@ -183,6 +184,12 @@ const compareYear = (date1: dayjs.Dayjs, date2: dayjs.Dayjs) => { + +
+ + {{ $t('labels.currentDate') }} + +
diff --git a/packages/nc-gui/components/nc/TimeSelector.vue b/packages/nc-gui/components/nc/TimeSelector.vue index 9d24ec00f2..e1d618a0c8 100644 --- a/packages/nc-gui/components/nc/TimeSelector.vue +++ b/packages/nc-gui/components/nc/TimeSelector.vue @@ -7,6 +7,7 @@ interface Props { isMinGranularityPicker?: boolean minGranularity?: number isOpen?: boolean + showCurrentDateOption?: boolean } const props = withDefaults(defineProps(), { @@ -16,7 +17,7 @@ const props = withDefaults(defineProps(), { minGranularity: 30, isOpen: false, }) -const emit = defineEmits(['update:selectedDate']) +const emit = defineEmits(['update:selectedDate', '']) const pageDate = ref(dayjs()) @@ -93,10 +94,20 @@ onMounted(() => {
-
+
{{ $t('general.now') }} + + + {{ $t('labels.currentDate') }} +
diff --git a/packages/nc-gui/components/smartsheet/Cell.vue b/packages/nc-gui/components/smartsheet/Cell.vue index 4b8509a3c4..d17ee293e6 100644 --- a/packages/nc-gui/components/smartsheet/Cell.vue +++ b/packages/nc-gui/components/smartsheet/Cell.vue @@ -19,6 +19,8 @@ const emit = defineEmits(['update:modelValue', 'save', 'navigate', 'update:editE const column = toRef(props, 'column') +const meta = inject(MetaInj, ref()) + const active = toRef(props, 'active', false) const readOnly = toRef(props, 'readOnly', false) @@ -51,11 +53,9 @@ const { currentRow } = useSmartsheetRowStoreOrThrow() const { sqlUis } = storeToRefs(useBase()) -const sqlUi = ref( - column.value?.source_id && sqlUis.value[column.value?.source_id] - ? sqlUis.value[column.value?.source_id] - : Object.values(sqlUis.value)[0], -) +const sourceId = meta.value?.source_id || column.value?.source_id + +const sqlUi = ref(sourceId && sqlUis.value[sourceId] ? sqlUis.value[sourceId] : Object.values(sqlUis.value)[0]) const abstractType = computed(() => column.value && sqlUi.value.getAbstractType(column.value)) @@ -123,6 +123,18 @@ const onContextmenu = (e: MouseEvent) => { e.stopPropagation() } } + +const showCurrentDateOption = computed(() => { + return ( + isEditColumnMenu.value && + (isDate(column.value, abstractType.value) || isDateTime(column.value, abstractType.value)) && + sqlUi.value?.getNowDefaultVal?.() + ) +}) + +const currentDate = () => { + vModel.value = sqlUi.value?.getNowDefaultVal?.() +}