|
|
@ -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>, |
|
|
|
) => { |
|
|
|
) => { |
|
|
@ -116,6 +123,8 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
const sideBarFilter = computed(() => { |
|
|
|
const sideBarFilter = computed(() => { |
|
|
|
let combinedFilters: any = [] |
|
|
|
let combinedFilters: any = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!calendarRange.value) return [] |
|
|
|
|
|
|
|
|
|
|
|
if (sideBarFilterOption.value === 'allRecords') { |
|
|
|
if (sideBarFilterOption.value === 'allRecords') { |
|
|
|
combinedFilters = [] |
|
|
|
combinedFilters = [] |
|
|
|
} else if (sideBarFilterOption.value === 'withoutDates') { |
|
|
|
} else if (sideBarFilterOption.value === 'withoutDates') { |
|
|
@ -329,6 +338,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const filterJSON = computed(() => { |
|
|
|
const filterJSON = computed(() => { |
|
|
|
|
|
|
|
if (!calendarRange.value) return [] |
|
|
|
const combinedFilters: any = { |
|
|
|
const combinedFilters: any = { |
|
|
|
is_group: true, |
|
|
|
is_group: true, |
|
|
|
logical_op: 'and', |
|
|
|
logical_op: 'and', |
|
|
@ -514,21 +524,24 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState( |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if (!base?.value?.id || !meta.value?.id || !viewMeta.value?.id) return |
|
|
|
if (!base?.value?.id || !meta.value?.id || !viewMeta.value?.id) return |
|
|
|
const res = !isPublic.value |
|
|
|
|
|
|
|
? await api.dbViewRow.calendarCount('noco', base.value.id!, meta.value!.id!, viewMeta.value.id, { |
|
|
|
try { |
|
|
|
...queryParams.value, |
|
|
|
const res = !isPublic.value |
|
|
|
...{}, |
|
|
|
? await api.dbViewRow.calendarCount('noco', base.value.id!, meta.value!.id!, viewMeta.value.id, { |
|
|
|
...{}, |
|
|
|
...queryParams.value, |
|
|
|
...{ filterArrJson: JSON.stringify([...activeDateFilter]) }, |
|
|
|
...{}, |
|
|
|
}) |
|
|
|
...{}, |
|
|
|
: await fetchSharedViewActiveDate({ |
|
|
|
...{ filterArrJson: JSON.stringify([...activeDateFilter]) }, |
|
|
|
sortsArr: sorts.value, |
|
|
|
}) |
|
|
|
filtersArr: activeDateFilter, |
|
|
|
: await fetchSharedViewActiveDate({ |
|
|
|
}) |
|
|
|
sortsArr: sorts.value, |
|
|
|
if (res) { |
|
|
|
filtersArr: activeDateFilter, |
|
|
|
|
|
|
|
}) |
|
|
|
activeDates.value = res.map((dateObj: unknown) => dayjs(dateObj)) |
|
|
|
activeDates.value = res.map((dateObj: unknown) => dayjs(dateObj)) |
|
|
|
} else { |
|
|
|
} catch (e) { |
|
|
|
activeDates.value = [] |
|
|
|
activeDates.value = [] |
|
|
|
|
|
|
|
message.error(`${t('msg.error.fetchingActiveDates')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -554,44 +567,55 @@ 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 |
|
|
|
const res = isPublic.value ? (sharedView.value?.view as CalendarType) : await $api.dbView.calendarRead(viewMeta.value.id) |
|
|
|
try { |
|
|
|
calendarMetaData.value = res |
|
|
|
const res = isPublic.value ? (sharedView.value?.view as CalendarType) : await $api.dbView.calendarRead(viewMeta.value.id) |
|
|
|
const calMeta = typeof res.meta === 'string' ? JSON.parse(res.meta) : res.meta |
|
|
|
calendarMetaData.value = res |
|
|
|
activeCalendarView.value = calMeta?.active_view |
|
|
|
const calMeta = typeof res.meta === 'string' ? JSON.parse(res.meta) : res.meta |
|
|
|
if (!activeCalendarView.value) activeCalendarView.value = 'month' |
|
|
|
activeCalendarView.value = calMeta?.active_view |
|
|
|
calendarRange.value = res?.calendar_range!.map((range: any) => { |
|
|
|
if (!activeCalendarView.value) activeCalendarView.value = 'month' |
|
|
|
return { |
|
|
|
calendarRange.value = res?.calendar_range?.map((range: any) => { |
|
|
|
fk_from_col: meta.value?.columns!.find((col) => col.id === range.fk_from_column_id), |
|
|
|
return { |
|
|
|
fk_to_col: range.fk_to_column_id ? meta.value?.columns!.find((col) => col.id === range.fk_to_column_id) : null, |
|
|
|
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, |
|
|
|
}) 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 |
|
|
|
isCalendarDataLoading.value = true |
|
|
|
try { |
|
|
|
const res = !isPublic.value |
|
|
|
isCalendarDataLoading.value = true |
|
|
|
? await api.dbViewRow.list( |
|
|
|
|
|
|
|
'noco', |
|
|
|
const res = !isPublic.value |
|
|
|
base.value.id!, |
|
|
|
? await api.dbViewRow.list( |
|
|
|
meta.value!.id!, |
|
|
|
'noco', |
|
|
|
viewMeta.value!.id!, |
|
|
|
base.value.id!, |
|
|
|
{ |
|
|
|
meta.value!.id!, |
|
|
|
...queryParams.value, |
|
|
|
viewMeta.value!.id!, |
|
|
|
...(isUIAllowed('filterSync') |
|
|
|
{ |
|
|
|
? { filterArrJson: JSON.stringify([...filterJSON.value]) } |
|
|
|
...queryParams.value, |
|
|
|
: { filterArrJson: JSON.stringify([nestedFilters.value, ...filterJSON.value]) }), |
|
|
|
...(isUIAllowed('filterSync') |
|
|
|
where: where?.value ?? '', |
|
|
|
? { filterArrJson: JSON.stringify([...filterJSON.value]) } |
|
|
|
}, |
|
|
|
: { filterArrJson: JSON.stringify([nestedFilters.value, ...filterJSON.value]) }), |
|
|
|
{ |
|
|
|
where: where?.value ?? '', |
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-ignore-pagination': true, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
) |
|
|
|
headers: { |
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: filterJSON.value }) |
|
|
|
'xc-ignore-pagination': true, |
|
|
|
formattedData.value = formatData(res!.list) |
|
|
|
}, |
|
|
|
isCalendarDataLoading.value = false |
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: filterJSON.value }) |
|
|
|
|
|
|
|
formattedData.value = formatData(res!.list) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
message.error(`${t('msg.error.fetchingCalendarData')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
isCalendarDataLoading.value = false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function updateCalendarMeta(updateObj: Partial<CalendarType>) { |
|
|
|
async function updateCalendarMeta(updateObj: Partial<CalendarType>) { |
|
|
@ -662,18 +686,24 @@ 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 |
|
|
|
isSidebarLoading.value = true |
|
|
|
try { |
|
|
|
const res = !isPublic.value |
|
|
|
isSidebarLoading.value = true |
|
|
|
? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value.id, { |
|
|
|
const res = !isPublic.value |
|
|
|
...queryParams.value, |
|
|
|
? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value.id, { |
|
|
|
...{}, |
|
|
|
...queryParams.value, |
|
|
|
...{}, |
|
|
|
...{}, |
|
|
|
...{ filterArrJson: JSON.stringify([...sideBarFilter.value]) }, |
|
|
|
...{}, |
|
|
|
}) |
|
|
|
...{ filterArrJson: JSON.stringify([...sideBarFilter.value]) }, |
|
|
|
: 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) |
|
|
|
isSidebarLoading.value = false |
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
message.error(`${t('msg.error.fetchingCalendarData')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
isSidebarLoading.value = false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function updateRowProperty(toUpdate: Row, property: string[], undo = false) { |
|
|
|
async function updateRowProperty(toUpdate: Row, property: string[], undo = false) { |
|
|
|