|
|
@ -139,27 +139,27 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( |
|
|
|
: await $api.dbView.kanbanRead(viewMeta.value.id) |
|
|
|
: await $api.dbView.kanbanRead(viewMeta.value.id) |
|
|
|
// set groupingField
|
|
|
|
// set groupingField
|
|
|
|
groupingFieldColumn.value = |
|
|
|
groupingFieldColumn.value = |
|
|
|
(meta.value.columns as ColumnType[]).filter((f) => f.id === kanbanMetaData.value.grp_column_id)[0] || {} |
|
|
|
(meta.value.columns as ColumnType[]).filter((f) => f.id === kanbanMetaData.value.fk_grp_col_id)[0] || {} |
|
|
|
|
|
|
|
|
|
|
|
groupingField.value = groupingFieldColumn.value.title! |
|
|
|
groupingField.value = groupingFieldColumn.value.title! |
|
|
|
|
|
|
|
|
|
|
|
const { grp_column_id, meta: stack_meta } = kanbanMetaData.value |
|
|
|
const { fk_grp_col_id, meta: stack_meta } = kanbanMetaData.value |
|
|
|
|
|
|
|
|
|
|
|
stackMetaObj.value = stack_meta ? JSON.parse(stack_meta as string) : {} |
|
|
|
stackMetaObj.value = stack_meta ? JSON.parse(stack_meta as string) : {} |
|
|
|
|
|
|
|
|
|
|
|
if (stackMetaObj.value && grp_column_id && stackMetaObj.value[grp_column_id]) { |
|
|
|
if (stackMetaObj.value && fk_grp_col_id && stackMetaObj.value[fk_grp_col_id]) { |
|
|
|
// keep the existing order (index of the array) but update the values done outside kanban
|
|
|
|
// keep the existing order (index of the array) but update the values done outside kanban
|
|
|
|
let isChanged = false |
|
|
|
let isChanged = false |
|
|
|
let hasNewOptionsAdded = false |
|
|
|
let hasNewOptionsAdded = false |
|
|
|
for (const option of (groupingFieldColumn.value.colOptions as SelectOptionsType)?.options ?? []) { |
|
|
|
for (const option of (groupingFieldColumn.value.colOptions as SelectOptionsType)?.options ?? []) { |
|
|
|
const idx = stackMetaObj.value[grp_column_id].findIndex((ele) => ele.id === option.id) |
|
|
|
const idx = stackMetaObj.value[fk_grp_col_id].findIndex((ele) => ele.id === option.id) |
|
|
|
if (idx !== -1) { |
|
|
|
if (idx !== -1) { |
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
const { collapsed, ...rest } = stackMetaObj.value[grp_column_id][idx] |
|
|
|
const { collapsed, ...rest } = stackMetaObj.value[fk_grp_col_id][idx] |
|
|
|
if (!deepCompare(rest, option)) { |
|
|
|
if (!deepCompare(rest, option)) { |
|
|
|
// update the option in stackMetaObj
|
|
|
|
// update the option in stackMetaObj
|
|
|
|
stackMetaObj.value[grp_column_id][idx] = { |
|
|
|
stackMetaObj.value[fk_grp_col_id][idx] = { |
|
|
|
...stackMetaObj.value[grp_column_id][idx], |
|
|
|
...stackMetaObj.value[fk_grp_col_id][idx], |
|
|
|
...option, |
|
|
|
...option, |
|
|
|
} |
|
|
|
} |
|
|
|
// rename the key in formattedData & countByStack
|
|
|
|
// rename the key in formattedData & countByStack
|
|
|
@ -175,7 +175,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// new option found - add to stackMetaObj
|
|
|
|
// new option found - add to stackMetaObj
|
|
|
|
stackMetaObj.value[grp_column_id].push({ |
|
|
|
stackMetaObj.value[fk_grp_col_id].push({ |
|
|
|
...option, |
|
|
|
...option, |
|
|
|
collapsed: false, |
|
|
|
collapsed: false, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -188,11 +188,11 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
// handle deleted options
|
|
|
|
// handle deleted options
|
|
|
|
const columnOptionIds = (groupingFieldColumn.value?.colOptions as SelectOptionsType)?.options.map(({ id }) => id) |
|
|
|
const columnOptionIds = (groupingFieldColumn.value?.colOptions as SelectOptionsType)?.options.map(({ id }) => id) |
|
|
|
const cols = stackMetaObj.value[grp_column_id].filter(({ id }) => id !== 'uncategorized' && !columnOptionIds.includes(id)) |
|
|
|
const cols = stackMetaObj.value[fk_grp_col_id].filter(({ id }) => id !== 'uncategorized' && !columnOptionIds.includes(id)) |
|
|
|
for (const col of cols) { |
|
|
|
for (const col of cols) { |
|
|
|
const idx = stackMetaObj.value[grp_column_id].map((ele: Record<string, any>) => ele.id).indexOf(col.id) |
|
|
|
const idx = stackMetaObj.value[fk_grp_col_id].map((ele: Record<string, any>) => ele.id).indexOf(col.id) |
|
|
|
if (idx !== -1) { |
|
|
|
if (idx !== -1) { |
|
|
|
stackMetaObj.value[grp_column_id].splice(idx, 1) |
|
|
|
stackMetaObj.value[fk_grp_col_id].splice(idx, 1) |
|
|
|
// there are two cases
|
|
|
|
// there are two cases
|
|
|
|
// 1. delete option from Add / Edit Stack in kanban view
|
|
|
|
// 1. delete option from Add / Edit Stack in kanban view
|
|
|
|
// 2. delete option from grid view, then switch to kanban view
|
|
|
|
// 2. delete option from grid view, then switch to kanban view
|
|
|
@ -210,7 +210,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( |
|
|
|
isChanged = true |
|
|
|
isChanged = true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
groupingFieldColOptions.value = stackMetaObj.value[grp_column_id] |
|
|
|
groupingFieldColOptions.value = stackMetaObj.value[fk_grp_col_id] |
|
|
|
|
|
|
|
|
|
|
|
if (isChanged) { |
|
|
|
if (isChanged) { |
|
|
|
await updateKanbanStackMeta() |
|
|
|
await updateKanbanStackMeta() |
|
|
@ -237,9 +237,9 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function updateKanbanStackMeta() { |
|
|
|
async function updateKanbanStackMeta() { |
|
|
|
const { grp_column_id } = kanbanMetaData.value |
|
|
|
const { fk_grp_col_id } = kanbanMetaData.value |
|
|
|
if (grp_column_id) { |
|
|
|
if (fk_grp_col_id) { |
|
|
|
stackMetaObj.value[grp_column_id] = groupingFieldColOptions.value |
|
|
|
stackMetaObj.value[fk_grp_col_id] = groupingFieldColOptions.value |
|
|
|
await updateKanbanMeta({ |
|
|
|
await updateKanbanMeta({ |
|
|
|
meta: stackMetaObj.value, |
|
|
|
meta: stackMetaObj.value, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -391,7 +391,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( |
|
|
|
|
|
|
|
|
|
|
|
// update kanban stack meta
|
|
|
|
// update kanban stack meta
|
|
|
|
groupingFieldColOptions.value.splice(stackIdx, 1) |
|
|
|
groupingFieldColOptions.value.splice(stackIdx, 1) |
|
|
|
stackMetaObj.value[kanbanMetaData.value.grp_column_id!] = groupingFieldColOptions.value |
|
|
|
stackMetaObj.value[kanbanMetaData.value.fk_grp_col_id!] = groupingFieldColOptions.value |
|
|
|
await updateKanbanStackMeta() |
|
|
|
await updateKanbanStackMeta() |
|
|
|
$e('a:kanban:delete-stack') |
|
|
|
$e('a:kanban:delete-stack') |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|