Browse Source

fix(nc-gui): calendar duplication not copying all ranges

pull/7611/head
DarkPhoenix2704 7 months ago
parent
commit
bcfdb1e479
  1. 42
      packages/nc-gui/components/dlg/ViewCreate.vue

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

@ -35,7 +35,7 @@ interface Form {
fk_geo_data_col_id: string | null fk_geo_data_col_id: string | null
// for calendar view only // for calendar view only
calendarRange: Array<{ calendar_range: Array<{
fk_from_column_id: string fk_from_column_id: string
fk_to_column_id: string | undefined // for ee only fk_to_column_id: string | undefined // for ee only
}> }>
@ -88,15 +88,7 @@ const form = reactive<Form>({
copy_from_id: null, copy_from_id: null,
fk_grp_col_id: null, fk_grp_col_id: null,
fk_geo_data_col_id: null, fk_geo_data_col_id: null,
calendarRange: calendar_range: props.calendarRange || [],
ViewTypes.CALENDAR === props.type
? props.calendarRange
: [
{
fk_from_column_id: '',
fk_to_column_id: null,
},
],
}) })
const viewSelectFieldOptions = ref<SelectProps['options']>([]) const viewSelectFieldOptions = ref<SelectProps['options']>([])
@ -197,7 +189,7 @@ async function onSubmit() {
case ViewTypes.CALENDAR: case ViewTypes.CALENDAR:
data = await api.dbView.calendarCreate(tableId.value, { data = await api.dbView.calendarCreate(tableId.value, {
...form, ...form,
calendar_range: form.calendarRange.map((range) => ({ calendar_range: form.calendar_range.map((range) => ({
fk_from_column_id: range.fk_from_column_id, fk_from_column_id: range.fk_from_column_id,
fk_to_column_id: range.fk_to_column_id, fk_to_column_id: range.fk_to_column_id,
})), })),
@ -226,7 +218,7 @@ async function onSubmit() {
} }
const addCalendarRange = async () => { const addCalendarRange = async () => {
form.calendarRange.push({ form.calendar_range.push({
fk_from_column_id: viewSelectFieldOptions.value[0].value, fk_from_column_id: viewSelectFieldOptions.value[0].value,
fk_to_column_id: null, fk_to_column_id: null,
}) })
@ -298,12 +290,14 @@ onMounted(async () => {
if (viewSelectFieldOptions.value?.length) { if (viewSelectFieldOptions.value?.length) {
// take the first option // take the first option
form.calendarRange = [ if (form.calendar_range.length === 0) {
{ form.calendar_range = [
fk_from_column_id: viewSelectFieldOptions.value[0].value as string, {
fk_to_column_id: null, // for ee only fk_from_column_id: viewSelectFieldOptions.value[0].value as string,
}, fk_to_column_id: null, // for ee only
] },
]
}
} else { } else {
// if there is no grouping field column, disable the create button // if there is no grouping field column, disable the create button
isNecessaryColumnsPresent.value = false isNecessaryColumnsPresent.value = false
@ -431,7 +425,7 @@ onMounted(async () => {
/> />
</a-form-item> </a-form-item>
<template v-if="form.type === ViewTypes.CALENDAR"> <template v-if="form.type === ViewTypes.CALENDAR">
<div v-for="(range, index) in form.calendarRange" :key="`range-${index}`" class="flex w-full mb-2 items-center gap-2"> <div v-for="(range, index) in form.calendar_range" :key="`range-${index}`" class="flex w-full mb-2 items-center gap-2">
<span> <span>
{{ $t('labels.organiseBy') }} {{ $t('labels.organiseBy') }}
</span> </span>
@ -441,7 +435,7 @@ onMounted(async () => {
// If the fk_from_column_id of first range is Date, then all the other ranges should be Date // If the fk_from_column_id of first range is Date, then all the other ranges should be Date
// If the fk_from_column_id of first range is DateTime, then all the other ranges should be DateTime // If the fk_from_column_id of first range is DateTime, then all the other ranges should be DateTime
if (index === 0) return true if (index === 0) return true
const firstRange = viewSelectFieldOptions.find((f) => f.value === form.calendarRange[0].fk_from_column_id) const firstRange = viewSelectFieldOptions.find((f) => f.value === form.calendar_range[0].fk_from_column_id)
return firstRange?.uidt === f.uidt return firstRange?.uidt === f.uidt
})" })"
:key="id" :key="id"
@ -449,7 +443,7 @@ onMounted(async () => {
> >
<div class="flex items-center"> <div class="flex items-center">
<SmartsheetHeaderIcon :column="option" /> <SmartsheetHeaderIcon :column="option" />
<NcTooltip class="truncate flex-1" placement="top" show-on-truncate-only> <NcTooltip class="truncate flex-1 max-w-18" placement="top" show-on-truncate-only>
<template #title>{{ option.label }}</template> <template #title>{{ option.label }}</template>
{{ option.label }} {{ option.label }}
</NcTooltip> </NcTooltip>
@ -481,7 +475,7 @@ onMounted(async () => {
// If the fk_from_column_id of first range is Date, then all the other ranges should be Date // If the fk_from_column_id of first range is Date, then all the other ranges should be Date
// If the fk_from_column_id of first range is DateTime, then all the other ranges should be DateTime // If the fk_from_column_id of first range is DateTime, then all the other ranges should be DateTime
const firstRange = viewSelectFieldOptions.find((f) => f.value === form.calendarRange[0].fk_from_column_id) const firstRange = viewSelectFieldOptions.find((f) => f.value === form.calendar_range[0].fk_from_column_id)
return firstRange?.uidt === f.uidt return firstRange?.uidt === f.uidt
})" })"
:key="id" :key="id"
@ -489,7 +483,7 @@ onMounted(async () => {
> >
<div class="flex items-center"> <div class="flex items-center">
<SmartsheetHeaderIcon :column="option" /> <SmartsheetHeaderIcon :column="option" />
<NcTooltip class="truncate flex-1" placement="top" show-on-truncate-only> <NcTooltip class="truncate flex-1 max-w-18" placement="top" show-on-truncate-only>
<template #title>{{ option.label }}</template> <template #title>{{ option.label }}</template>
{{ option.label }} {{ option.label }}
</NcTooltip> </NcTooltip>
@ -507,7 +501,7 @@ onMounted(async () => {
type="secondary" type="secondary"
@click=" @click="
() => { () => {
form.calendarRange = form.calendarRange.filter((_, i) => i !== index) form.calendar_range = form.calendar_range.filter((_, i) => i !== index)
} }
" "
> >

Loading…
Cancel
Save