Browse Source

Merge pull request #9915 from nocodb/nc-disable-enddate

fix: disable endDate for created-at, updated-at, formula
pull/9920/head
Anbarasu 1 month ago committed by GitHub
parent
commit
74f1765538
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      packages/nc-gui/components/dlg/ViewCreate.vue
  2. 137
      packages/nc-gui/components/smartsheet/toolbar/Calendar/Range.vue

9
packages/nc-gui/components/dlg/ViewCreate.vue

@ -535,8 +535,9 @@ const isCalendarReadonly = (calendarRange?: Array<{ fk_from_column_id: string; f
const isDisabled = computed(() => {
return (
viewSelectFieldOptions.value.find((f) => f.value === form.calendar_range[0]?.fk_from_column_id)?.uidt === UITypes.DateTime &&
!isRangeEnabled.value
[UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime, UITypes.Formula].includes(
viewSelectFieldOptions.value.find((f) => f.value === form.calendar_range[0]?.fk_from_column_id)?.uidt,
) && !isRangeEnabled.value
)
})
@ -1053,9 +1054,9 @@ const getPluralName = (name: string) => {
</a-select-option>
</a-select>
</div>
<div class="w-full space-y-2">
<div v-if="isEeUI" class="w-full space-y-2">
<NcTooltip v-if="range.fk_to_column_id === null" placement="left" :disabled="!isDisabled">
<NcButton size="small" type="text" :disabled="!isEeUI || isDisabled" @click="range.fk_to_column_id = undefined">
<NcButton size="small" type="text" :disabled="isDisabled" @click="range.fk_to_column_id = undefined">
<div class="flex items-center gap-1">
<component :is="iconMap.plus" class="h-4 w-4" />
{{ $t('activity.endDate') }}

137
packages/nc-gui/components/smartsheet/toolbar/Calendar/Range.vue

@ -145,8 +145,9 @@ const removeRange = async (id: number) => {
const isDisabled = computed(() => {
return (
dateFieldOptions.value.find((f) => f.value === calendarRange.value[0]?.fk_from_column_id)?.uidt === UITypes.DateTime &&
!isRangeEnabled.value
[UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime, UITypes.Formula].includes(
dateFieldOptions.value.find((f) => f.value === calendarRange.value[0]?.fk_from_column_id)?.uidt,
) && !isRangeEnabled.value
)
})
@ -250,76 +251,74 @@ const onValueChange = async () => {
</div>
</a-select-option>
</a-select>
<NcTooltip v-if="range.fk_to_column_id === null && isRangeEnabled" placement="left" :disabled="!isDisabled">
<NcButton
size="small"
data-testid="nc-calendar-range-add-end-date"
class="w-23"
type="text"
:shadow="false"
:disabled="!isEeUI || isLocked || isDisabled"
@click="range.fk_to_column_id = undefined"
>
<div class="flex gap-1 items-center">
<component :is="iconMap.plus" class="h-4 w-4" />
{{ $t('activity.endDate') }}
</div>
</NcButton>
<template #title> Coming Soon!! Currently, range support is only available for Date field. </template>
</NcTooltip>
<template v-else-if="isEeUI">
<span>
{{ $t('activity.withEndDate') }}
</span>
<div class="flex">
<a-select
v-model:value="range.fk_to_column_id"
class="!rounded-r-none nc-select-shadow w-full flex-1"
allow-clear
:disabled="!range.fk_from_column_id || isLocked || isDisabled"
:placeholder="$t('placeholder.notSelected')"
data-testid="nc-calendar-range-to-field-select"
dropdown-class-name="!rounded-lg"
@change="saveCalendarRanges"
@click.stop
<div v-if="!isEeUI" class="w-full space-y-2">
<NcTooltip v-if="range.fk_to_column_id === null && isRangeEnabled" placement="left" :disabled="!isDisabled">
<NcButton
size="small"
data-testid="nc-calendar-range-add-end-date"
class="w-23"
type="text"
:shadow="false"
:disabled="isLocked || isDisabled"
@click="range.fk_to_column_id = undefined"
>
<template #suffixIcon><GeneralIcon icon="arrowDown" class="text-gray-700" /></template>
<a-select-option
v-for="(option, opId) in [...dateFieldOptions].filter((f) => {
const firstRange = dateFieldOptions.find((f) => f.value === calendarRange[0].fk_from_column_id)
return firstRange?.uidt === f.uidt && f.value !== range.fk_from_column_id
})"
:key="opId"
:value="option.value"
<div class="flex gap-1 items-center">
<component :is="iconMap.plus" class="h-4 w-4" />
{{ $t('activity.endDate') }}
</div>
</NcButton>
<template #title> Coming Soon!! Currently, range support is only available for Date field. </template>
</NcTooltip>
<template v-else-if="isEeUI">
<span>
{{ $t('activity.withEndDate') }}
</span>
<div class="flex">
<a-select
v-model:value="range.fk_to_column_id"
class="!rounded-r-none nc-select-shadow w-full flex-1"
allow-clear
:disabled="!range.fk_from_column_id || isLocked || isDisabled"
:placeholder="$t('placeholder.notSelected')"
data-testid="nc-calendar-range-to-field-select"
dropdown-class-name="!rounded-lg"
@change="saveCalendarRanges"
@click.stop
>
<div class="w-full flex gap-2 items-center justify-between" :title="option.label">
<div class="flex items-center gap-1 max-w-[calc(100%_-_20px)]">
<SmartsheetHeaderIcon :column="option" />
<NcTooltip class="flex-1 max-w-[calc(100%_-_20px)] truncate" show-on-truncate-only>
<template #title>
{{ option.label }}
</template>
<template #default>{{ option.label }}</template>
</NcTooltip>
<template #suffixIcon><GeneralIcon icon="arrowDown" class="text-gray-700" /></template>
<a-select-option
v-for="(option, opId) in [...dateFieldOptions].filter((f) => {
const firstRange = dateFieldOptions.find((f) => f.value === calendarRange[0].fk_from_column_id)
return firstRange?.uidt === f.uidt && f.value !== range.fk_from_column_id
})"
:key="opId"
:value="option.value"
>
<div class="w-full flex gap-2 items-center justify-between" :title="option.label">
<div class="flex items-center gap-1 max-w-[calc(100%_-_20px)]">
<SmartsheetHeaderIcon :column="option" />
<NcTooltip class="flex-1 max-w-[calc(100%_-_20px)] truncate" show-on-truncate-only>
<template #title>
{{ option.label }}
</template>
<template #default>{{ option.label }}</template>
</NcTooltip>
</div>
<GeneralIcon
v-if="option.value === range.fk_from_column_id"
id="nc-selected-item-icon"
icon="check"
class="flex-none text-primary w-4 h-4"
/>
</div>
<GeneralIcon
v-if="option.value === range.fk_from_column_id"
id="nc-selected-item-icon"
icon="check"
class="flex-none text-primary w-4 h-4"
/>
</div>
</a-select-option>
</a-select>
</div>
</template>
<NcButton v-if="id !== 0" size="small" type="secondary" @click="removeRange(id)">
<component :is="iconMap.close" />
</NcButton>
</a-select-option>
</a-select>
</div>
</template>
</div>
</div>
<div v-if="!isSetup" class="flex items-center gap-2 !mt-2">

Loading…
Cancel
Save