|
|
@ -6,11 +6,15 @@ import type { Row } from '~/composables/useViewData' |
|
|
|
import { enumColor } from '~/utils' |
|
|
|
import { enumColor } from '~/utils' |
|
|
|
import { useNuxtApp } from '#app' |
|
|
|
import { useNuxtApp } from '#app' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type GroupingFieldColOptionsType = SelectOptionType & { collapsed: boolean } |
|
|
|
|
|
|
|
|
|
|
|
export function useKanbanViewData( |
|
|
|
export function useKanbanViewData( |
|
|
|
meta: Ref<TableType> | ComputedRef<TableType> | undefined, |
|
|
|
meta: Ref<TableType | undefined> | ComputedRef<TableType | undefined>, |
|
|
|
viewMeta: Ref<ViewType & { id: string }> | ComputedRef<ViewType & { id: string }> | undefined, |
|
|
|
viewMeta: Ref<ViewType & { id: string }> | ComputedRef<ViewType & { id: string }> | undefined, |
|
|
|
) { |
|
|
|
) { |
|
|
|
type GroupingFieldColOptionsType = SelectOptionType & { collapsed: boolean } |
|
|
|
if (!meta) { |
|
|
|
|
|
|
|
throw new Error('Table meta is not available') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
const { api } = useApi() |
|
|
|
const { api } = useApi() |
|
|
@ -66,7 +70,7 @@ export function useKanbanViewData( |
|
|
|
})) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
async function loadKanbanData() { |
|
|
|
async function loadKanbanData() { |
|
|
|
if ((!project?.value?.id || !meta?.value?.id || !viewMeta?.value?.id) && !isPublic.value) return |
|
|
|
if ((!project?.value?.id || !meta.value?.id || !viewMeta?.value?.id) && !isPublic.value) return |
|
|
|
|
|
|
|
|
|
|
|
// reset formattedData & countByStack to avoid storing previous data after changing grouping field
|
|
|
|
// reset formattedData & countByStack to avoid storing previous data after changing grouping field
|
|
|
|
formattedData.value = {} |
|
|
|
formattedData.value = {} |
|
|
@ -76,7 +80,7 @@ export function useKanbanViewData( |
|
|
|
groupingFieldColOptions.value.map(async (option: GroupingFieldColOptionsType) => { |
|
|
|
groupingFieldColOptions.value.map(async (option: GroupingFieldColOptionsType) => { |
|
|
|
const where = |
|
|
|
const where = |
|
|
|
option.title === 'Uncategorized' ? `(${groupingField.value},is,null)` : `(${groupingField.value},eq,${option.title})` |
|
|
|
option.title === 'Uncategorized' ? `(${groupingField.value},is,null)` : `(${groupingField.value},eq,${option.title})` |
|
|
|
const response = await api.dbViewRow.list('noco', project.value.id!, meta!.value.id!, viewMeta!.value.id, { |
|
|
|
const response = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta!.value.id, { |
|
|
|
where, |
|
|
|
where, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -87,11 +91,12 @@ export function useKanbanViewData( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function loadMoreKanbanData(stackTitle: string, params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) { |
|
|
|
async function loadMoreKanbanData(stackTitle: string, params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) { |
|
|
|
|
|
|
|
if ((!project?.value?.id || !meta.value?.id || !viewMeta?.value?.id) && !isPublic.value) return |
|
|
|
let where = `(${groupingField.value},eq,${stackTitle})` |
|
|
|
let where = `(${groupingField.value},eq,${stackTitle})` |
|
|
|
if (stackTitle === 'Uncategorized') { |
|
|
|
if (stackTitle === 'Uncategorized') { |
|
|
|
where = `(${groupingField.value},is,null)` |
|
|
|
where = `(${groupingField.value},is,null)` |
|
|
|
} |
|
|
|
} |
|
|
|
const response = await api.dbViewRow.list('noco', project.value.id!, meta!.value.id!, viewMeta!.value.id, { |
|
|
|
const response = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta!.value.id, { |
|
|
|
...params, |
|
|
|
...params, |
|
|
|
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), |
|
|
|
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), |
|
|
|
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), |
|
|
|
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), |
|
|
@ -191,7 +196,7 @@ export function useKanbanViewData( |
|
|
|
const insertedData = await $api.dbViewRow.create( |
|
|
|
const insertedData = await $api.dbViewRow.create( |
|
|
|
NOCO, |
|
|
|
NOCO, |
|
|
|
project?.value.id as string, |
|
|
|
project?.value.id as string, |
|
|
|
meta?.value.id as string, |
|
|
|
meta.value?.id as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
insertObj, |
|
|
|
insertObj, |
|
|
|
) |
|
|
|
) |
|
|
@ -210,12 +215,12 @@ export function useKanbanViewData( |
|
|
|
|
|
|
|
|
|
|
|
async function updateRowProperty(toUpdate: Row, property: string) { |
|
|
|
async function updateRowProperty(toUpdate: Row, property: string) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const id = extractPkFromRow(toUpdate.row, meta?.value.columns as ColumnType[]) |
|
|
|
const id = extractPkFromRow(toUpdate.row, meta?.value?.columns as ColumnType[]) |
|
|
|
|
|
|
|
|
|
|
|
const updatedRowData = await $api.dbViewRow.update( |
|
|
|
const updatedRowData = await $api.dbViewRow.update( |
|
|
|
NOCO, |
|
|
|
NOCO, |
|
|
|
project?.value.id as string, |
|
|
|
project?.value.id as string, |
|
|
|
meta?.value.id as string, |
|
|
|
meta.value?.id as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
id, |
|
|
|
id, |
|
|
|
{ |
|
|
|
{ |
|
|
@ -229,7 +234,7 @@ export function useKanbanViewData( |
|
|
|
// audit
|
|
|
|
// audit
|
|
|
|
$api.utils |
|
|
|
$api.utils |
|
|
|
.auditRowUpdate(id, { |
|
|
|
.auditRowUpdate(id, { |
|
|
|
fk_model_id: meta?.value.id as string, |
|
|
|
fk_model_id: meta.value?.id as string, |
|
|
|
column_name: property, |
|
|
|
column_name: property, |
|
|
|
row_id: id, |
|
|
|
row_id: id, |
|
|
|
value: getHTMLEncodedText(toUpdate.row[property]), |
|
|
|
value: getHTMLEncodedText(toUpdate.row[property]), |
|
|
@ -259,7 +264,7 @@ export function useKanbanViewData( |
|
|
|
await api.dbTableRow.bulkUpdateAll( |
|
|
|
await api.dbTableRow.bulkUpdateAll( |
|
|
|
'noco', |
|
|
|
'noco', |
|
|
|
project.value.id!, |
|
|
|
project.value.id!, |
|
|
|
meta!.value.id!, |
|
|
|
meta.value?.id as string, |
|
|
|
{ |
|
|
|
{ |
|
|
|
[groupingField.value]: null, |
|
|
|
[groupingField.value]: null, |
|
|
|
}, |
|
|
|
}, |
|
|
|