|
|
@ -9,8 +9,8 @@ import { |
|
|
|
type ViewType, |
|
|
|
type ViewType, |
|
|
|
} from 'nocodb-sdk' |
|
|
|
} from 'nocodb-sdk' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import { addDays, addMonths, addYears } from '~/utils' |
|
|
|
import { addDays, addMonths, addYears, extractPkFromRow, extractSdkResponseErrorMsg } from '~/utils' |
|
|
|
import { IsPublicInj, type Row, ref, storeToRefs, useBase, useInjectionState } from '#imports' |
|
|
|
import { IsPublicInj, type Row, ref, storeToRefs, useBase, useInjectionState, useUndoRedo } from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
const formatData = (list: Record<string, any>[]) => |
|
|
|
const formatData = (list: Record<string, any>[]) => |
|
|
|
list.map( |
|
|
|
list.map( |
|
|
@ -48,7 +48,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
const selectedTime = ref<Date | null>(null) |
|
|
|
const selectedTime = ref<Date | null>(null) |
|
|
|
|
|
|
|
|
|
|
|
const selectedMonth = ref<Date | null>(new Date()) |
|
|
|
const selectedMonth = ref<Date>(new Date()) |
|
|
|
|
|
|
|
|
|
|
|
const isCalendarDataLoading = ref<boolean>(false) |
|
|
|
const isCalendarDataLoading = ref<boolean>(false) |
|
|
|
|
|
|
|
|
|
|
@ -76,6 +76,10 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
const { $api } = useNuxtApp() |
|
|
|
const { $api } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { addUndo, clone, defineViewScope } = useUndoRedo() |
|
|
|
|
|
|
|
|
|
|
|
const { isUIAllowed } = useRoles() |
|
|
|
const { isUIAllowed } = useRoles() |
|
|
|
|
|
|
|
|
|
|
|
const isPublic = ref(shared) || inject(IsPublicInj, ref(false)) |
|
|
|
const isPublic = ref(shared) || inject(IsPublicInj, ref(false)) |
|
|
@ -102,7 +106,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
const calDataType = computed(() => { |
|
|
|
const calDataType = computed(() => { |
|
|
|
if (!calendarRange.value || !calendarRange.value[0]) return null |
|
|
|
if (!calendarRange.value || !calendarRange.value[0]) return null |
|
|
|
return calendarRange.value[0].fk_from_col.uidt |
|
|
|
return calendarRange.value[0]!.fk_from_col.uidt |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const sideBarFilter = computed(() => { |
|
|
|
const sideBarFilter = computed(() => { |
|
|
@ -297,7 +301,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
if (isSidebarLoading.value) return |
|
|
|
if (isSidebarLoading.value) return |
|
|
|
try { |
|
|
|
try { |
|
|
|
const response = !isPublic.value |
|
|
|
const response = !isPublic.value |
|
|
|
? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value.id, { |
|
|
|
? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value!.id, { |
|
|
|
...params, |
|
|
|
...params, |
|
|
|
offset: params.offset, |
|
|
|
offset: params.offset, |
|
|
|
...{}, |
|
|
|
...{}, |
|
|
@ -503,7 +507,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
fk_from_col: meta.value?.columns!.find((col) => col.id === range.fk_from_column_id), |
|
|
|
fk_from_col: meta.value?.columns!.find((col) => col.id === range.fk_from_column_id), |
|
|
|
fk_to_col: range.fk_to_column_id ? meta.value?.columns!.find((col) => col.id === range.fk_to_column_id) : null, |
|
|
|
fk_to_col: range.fk_to_column_id ? meta.value?.columns!.find((col) => col.id === range.fk_to_column_id) : null, |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) as any |
|
|
|
displayField.value = meta.value.columns.find((col) => col.pv) |
|
|
|
displayField.value = meta.value.columns.find((col) => col.pv) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -584,6 +588,35 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
isSidebarLoading.value = false |
|
|
|
isSidebarLoading.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function updateRowProperty(toUpdate: Row, property: [], undo = false) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const id = extractPkFromRow(toUpdate.row, meta?.value?.columns as ColumnType[]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateObj = property.reduce((acc, curr) => { |
|
|
|
|
|
|
|
acc[curr] = toUpdate.row[curr] |
|
|
|
|
|
|
|
return acc |
|
|
|
|
|
|
|
}, {}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await $api.dbViewRow.update( |
|
|
|
|
|
|
|
NOCO, |
|
|
|
|
|
|
|
base?.value.id as string, |
|
|
|
|
|
|
|
meta.value?.id as string, |
|
|
|
|
|
|
|
viewMeta?.value?.id as string, |
|
|
|
|
|
|
|
id, |
|
|
|
|
|
|
|
updateObj, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
query: { ignoreWebhook: !undo }, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// todo:
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// query: { ignoreWebhook: !saved }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} catch (e: any) { |
|
|
|
|
|
|
|
message.error(`${t('msg.error.rowUpdateFailed')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
watch(selectedDate, async () => { |
|
|
|
watch(selectedDate, async () => { |
|
|
|
if (activeCalendarView.value === 'month' || activeCalendarView.value === 'week') { |
|
|
|
if (activeCalendarView.value === 'month' || activeCalendarView.value === 'week') { |
|
|
|
await loadSidebarData() |
|
|
|
await loadSidebarData() |
|
|
@ -634,6 +667,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
selectedTime, |
|
|
|
selectedTime, |
|
|
|
updateCalendarMeta, |
|
|
|
updateCalendarMeta, |
|
|
|
calendarMetaData, |
|
|
|
calendarMetaData, |
|
|
|
|
|
|
|
updateRowProperty, |
|
|
|
activeCalendarView, |
|
|
|
activeCalendarView, |
|
|
|
pageDate, |
|
|
|
pageDate, |
|
|
|
paginationData, |
|
|
|
paginationData, |
|
|
|