|
|
@ -6,7 +6,7 @@ import { useVirtualCell } from '~/composables/useVirtualCell' |
|
|
|
|
|
|
|
|
|
|
|
const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState((meta: Ref<TableType>, row: Ref<Row>) => { |
|
|
|
const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState((meta: Ref<TableType>, row: Ref<Row>) => { |
|
|
|
// state
|
|
|
|
// state
|
|
|
|
const state = ref<Record<string, Record<string, any> | Record<string, any>[]>>({}) |
|
|
|
const state = ref<Record<string, Record<string, any> | Record<string, any>[] | null>>({}) |
|
|
|
|
|
|
|
|
|
|
|
// getters
|
|
|
|
// getters
|
|
|
|
const isNew = computed(() => row.value?.rowMeta?.new) |
|
|
|
const isNew = computed(() => row.value?.rowMeta?.new) |
|
|
@ -16,18 +16,29 @@ const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState( |
|
|
|
const { isHm, isMm } = $(useVirtualCell(ref(column))) |
|
|
|
const { isHm, isMm } = $(useVirtualCell(ref(column))) |
|
|
|
if (isHm || isMm) { |
|
|
|
if (isHm || isMm) { |
|
|
|
state.value[column.title!] = state.value[column.title!] || [] |
|
|
|
state.value[column.title!] = state.value[column.title!] || [] |
|
|
|
state.value[column.title!].push(value) |
|
|
|
state.value[column.title!]!.push(value) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
state.value[column.title!] = value |
|
|
|
state.value[column.title!] = value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
|
|
|
|
const removeLTARRef = async (value: Record<string, any>, column: ColumnType) => { |
|
|
|
|
|
|
|
const { isHm, isMm } = $(useVirtualCell(ref(column))) |
|
|
|
|
|
|
|
if (isHm || isMm) { |
|
|
|
|
|
|
|
state.value[column.title!]?.splice(state.value[column.title!]?.indexOf(value), 1) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
state.value[column.title!] = null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
row, |
|
|
|
row, |
|
|
|
state, |
|
|
|
state, |
|
|
|
isNew, |
|
|
|
isNew, |
|
|
|
// todo: use better name
|
|
|
|
// todo: use better name
|
|
|
|
addLTARRef, |
|
|
|
addLTARRef, |
|
|
|
|
|
|
|
removeLTARRef, |
|
|
|
} |
|
|
|
} |
|
|
|
}, 'smartsheet-row-store') |
|
|
|
}, 'smartsheet-row-store') |
|
|
|
|
|
|
|
|
|
|
|