|
|
@ -25,7 +25,14 @@ const formatData = (list: Record<string, any>[]) => |
|
|
|
const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
( |
|
|
|
( |
|
|
|
meta: Ref<((CalendarType & { id: string }) | TableType) | undefined>, |
|
|
|
meta: Ref<((CalendarType & { id: string }) | TableType) | undefined>, |
|
|
|
viewMeta: Ref<(ViewType | CalendarType | undefined) & { id: string }> | ComputedRef<(ViewType & { id: string }) | undefined>, |
|
|
|
viewMeta: |
|
|
|
|
|
|
|
| Ref<(ViewType | CalendarType | undefined) & { id: string }> |
|
|
|
|
|
|
|
| ComputedRef< |
|
|
|
|
|
|
|
| (ViewType & { |
|
|
|
|
|
|
|
id: string |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
| undefined |
|
|
|
|
|
|
|
>, |
|
|
|
shared = false, |
|
|
|
shared = false, |
|
|
|
where?: ComputedRef<string | undefined>, |
|
|
|
where?: ComputedRef<string | undefined>, |
|
|
|
) => { |
|
|
|
) => { |
|
|
@ -529,6 +536,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
}) |
|
|
|
}) |
|
|
|
activeDates.value = res.map((dateObj: unknown) => dayjs(dateObj)) |
|
|
|
activeDates.value = res.map((dateObj: unknown) => dayjs(dateObj)) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
activeDates.value = [] |
|
|
|
message.error(`${t('msg.error.fetchingActiveDates')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
message.error(`${t('msg.error.fetchingActiveDates')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
} |
|
|
@ -556,22 +564,28 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
async function loadCalendarMeta() { |
|
|
|
async function loadCalendarMeta() { |
|
|
|
if (!viewMeta?.value?.id || !meta?.value?.columns) return |
|
|
|
if (!viewMeta?.value?.id || !meta?.value?.columns) return |
|
|
|
|
|
|
|
try { |
|
|
|
const res = isPublic.value ? (sharedView.value?.view as CalendarType) : await $api.dbView.calendarRead(viewMeta.value.id) |
|
|
|
const res = isPublic.value ? (sharedView.value?.view as CalendarType) : await $api.dbView.calendarRead(viewMeta.value.id) |
|
|
|
calendarMetaData.value = res |
|
|
|
calendarMetaData.value = res |
|
|
|
const calMeta = typeof res.meta === 'string' ? JSON.parse(res.meta) : res.meta |
|
|
|
const calMeta = typeof res.meta === 'string' ? JSON.parse(res.meta) : res.meta |
|
|
|
activeCalendarView.value = calMeta?.active_view |
|
|
|
activeCalendarView.value = calMeta?.active_view |
|
|
|
if (!activeCalendarView.value) activeCalendarView.value = 'month' |
|
|
|
if (!activeCalendarView.value) activeCalendarView.value = 'month' |
|
|
|
calendarRange.value = res?.calendar_range!.map((range: any) => { |
|
|
|
calendarRange.value = res?.calendar_range?.map((range: any) => { |
|
|
|
return { |
|
|
|
return { |
|
|
|
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 |
|
|
|
}) as any |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
message.error(`Error loading calendar meta ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function loadCalendarData() { |
|
|
|
async function loadCalendarData() { |
|
|
|
if ((!base?.value?.id || !meta.value?.id || !viewMeta.value?.id || !filterJSON.value) && !isPublic?.value) return |
|
|
|
if ((!base?.value?.id || !meta.value?.id || !viewMeta.value?.id || !filterJSON.value) && !isPublic?.value) return |
|
|
|
|
|
|
|
try { |
|
|
|
isCalendarDataLoading.value = true |
|
|
|
isCalendarDataLoading.value = true |
|
|
|
|
|
|
|
|
|
|
|
const res = !isPublic.value |
|
|
|
const res = !isPublic.value |
|
|
|
? await api.dbViewRow.list( |
|
|
|
? await api.dbViewRow.list( |
|
|
|
'noco', |
|
|
|
'noco', |
|
|
@ -593,8 +607,13 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
) |
|
|
|
) |
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: filterJSON.value }) |
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: filterJSON.value }) |
|
|
|
formattedData.value = formatData(res!.list) |
|
|
|
formattedData.value = formatData(res!.list) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
message.error(`${t('msg.error.fetchingCalendarData')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
|
|
|
|
} finally { |
|
|
|
isCalendarDataLoading.value = false |
|
|
|
isCalendarDataLoading.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function updateCalendarMeta(updateObj: Partial<CalendarType>) { |
|
|
|
async function updateCalendarMeta(updateObj: Partial<CalendarType>) { |
|
|
|
if (!viewMeta?.value?.id || !isUIAllowed('dataEdit') || isPublic.value) return |
|
|
|
if (!viewMeta?.value?.id || !isUIAllowed('dataEdit') || isPublic.value) return |
|
|
@ -664,6 +683,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
const loadSidebarData = async () => { |
|
|
|
const loadSidebarData = async () => { |
|
|
|
if (!base?.value?.id || !meta.value?.id || !viewMeta.value?.id) return |
|
|
|
if (!base?.value?.id || !meta.value?.id || !viewMeta.value?.id) return |
|
|
|
|
|
|
|
try { |
|
|
|
isSidebarLoading.value = true |
|
|
|
isSidebarLoading.value = true |
|
|
|
const res = !isPublic.value |
|
|
|
const res = !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, { |
|
|
@ -675,8 +695,13 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: sideBarFilter.value }) |
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: sideBarFilter.value }) |
|
|
|
|
|
|
|
|
|
|
|
formattedSideBarData.value = formatData(res!.list) |
|
|
|
formattedSideBarData.value = formatData(res!.list) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
message.error(`${t('msg.error.fetchingCalendarData')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
|
|
|
|
} finally { |
|
|
|
isSidebarLoading.value = false |
|
|
|
isSidebarLoading.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function updateRowProperty(toUpdate: Row, property: string[], undo = false) { |
|
|
|
async function updateRowProperty(toUpdate: Row, property: string[], undo = false) { |
|
|
|
try { |
|
|
|
try { |
|
|
|