|
|
@ -248,7 +248,8 @@ const onKeyDown = async (e: KeyboardEvent) => { |
|
|
|
e.preventDefault() |
|
|
|
e.preventDefault() |
|
|
|
if (selected.row < data.value.length - 1) selected.row++ |
|
|
|
if (selected.row < data.value.length - 1) selected.row++ |
|
|
|
break |
|
|
|
break |
|
|
|
default: { |
|
|
|
default: |
|
|
|
|
|
|
|
{ |
|
|
|
const rowObj = data.value[selected.row] |
|
|
|
const rowObj = data.value[selected.row] |
|
|
|
const columnObj = fields.value[selected.col] |
|
|
|
const columnObj = fields.value[selected.col] |
|
|
|
|
|
|
|
|
|
|
@ -326,16 +327,21 @@ const showContextMenu = (e: MouseEvent, target?: { row: number; col: number }) = |
|
|
|
|
|
|
|
|
|
|
|
const rowRefs = $ref<any[]>() |
|
|
|
const rowRefs = $ref<any[]>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** save/update records before unmounting the component */ |
|
|
|
onBeforeUnmount(async () => { |
|
|
|
onBeforeUnmount(async () => { |
|
|
|
console.log(rowRefs) |
|
|
|
console.log(rowRefs) |
|
|
|
for (const [index, currentRow] of Object.entries(data.value)) { |
|
|
|
let index = -1 |
|
|
|
|
|
|
|
for (const currentRow of data.value) { |
|
|
|
|
|
|
|
index++ |
|
|
|
|
|
|
|
/** if new record save row and save the LTAR cells */ |
|
|
|
if (currentRow.rowMeta.new) { |
|
|
|
if (currentRow.rowMeta.new) { |
|
|
|
const syncLTARRefs = rowRefs[index]!.syncLTARRefs |
|
|
|
const syncLTARRefs = rowRefs[index]!.syncLTARRefs |
|
|
|
const savedRow = await updateOrSaveRow(currentRow, null) |
|
|
|
const savedRow = await updateOrSaveRow(currentRow, '') |
|
|
|
await syncLTARRefs(savedRow) |
|
|
|
await syncLTARRefs(savedRow) |
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** if existing row check updated cell and invoke update method */ |
|
|
|
if (currentRow.rowMeta.changed) { |
|
|
|
if (currentRow.rowMeta.changed) { |
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
for (const field of meta?.value.columns ?? []) { |
|
|
|
for (const field of meta?.value.columns ?? []) { |
|
|
@ -347,7 +353,6 @@ onBeforeUnmount(async () => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -423,7 +428,7 @@ onBeforeUnmount(async () => { |
|
|
|
</tr> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
</thead> |
|
|
|
<tbody> |
|
|
|
<tbody> |
|
|
|
<SmartsheetRow ref="rowRefs" v-for="(row, rowIndex) of data" :key="rowIndex" :row="row"> |
|
|
|
<SmartsheetRow v-for="(row, rowIndex) of data" ref="rowRefs" :key="rowIndex" :row="row"> |
|
|
|
<template #default="{ state }"> |
|
|
|
<template #default="{ state }"> |
|
|
|
<tr class="nc-grid-row"> |
|
|
|
<tr class="nc-grid-row"> |
|
|
|
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1"> |
|
|
|
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1"> |
|
|
@ -443,8 +448,7 @@ onBeforeUnmount(async () => { |
|
|
|
<a-checkbox v-model:checked="row.rowMeta.selected" /> |
|
|
|
<a-checkbox v-model:checked="row.rowMeta.selected" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<span class="flex-1" /> |
|
|
|
<span class="flex-1" /> |
|
|
|
<div v-if="!readOnly && !isLocked" class="nc-expand" |
|
|
|
<div v-if="!readOnly && !isLocked" class="nc-expand" :class="{ 'nc-comment': row.rowMeta?.commentCount }"> |
|
|
|
:class="{ 'nc-comment': row.rowMeta?.commentCount }"> |
|
|
|
|
|
|
|
<span |
|
|
|
<span |
|
|
|
v-if="row.rowMeta?.commentCount" |
|
|
|
v-if="row.rowMeta?.commentCount" |
|
|
|
class="py-1 px-3 rounded-full text-xs cursor-pointer select-none transform hover:(scale-110)" |
|
|
|
class="py-1 px-3 rounded-full text-xs cursor-pointer select-none transform hover:(scale-110)" |
|
|
@ -515,9 +519,9 @@ onBeforeUnmount(async () => { |
|
|
|
</SmartsheetRow> |
|
|
|
</SmartsheetRow> |
|
|
|
|
|
|
|
|
|
|
|
<!-- |
|
|
|
<!-- |
|
|
|
TODO: add relationType !== 'bt' ? |
|
|
|
TODO: add relationType !== 'bt' ? |
|
|
|
v1: <tr v-if="!isView && !isLocked && !isPublicView && isEditable && relationType !== 'bt'"> |
|
|
|
v1: <tr v-if="!isView && !isLocked && !isPublicView && isEditable && relationType !== 'bt'"> |
|
|
|
--> |
|
|
|
--> |
|
|
|
<tr v-if="!isView && !isLocked && isUIAllowed('xcDatatableEditable') && !isSqlView"> |
|
|
|
<tr v-if="!isView && !isLocked && isUIAllowed('xcDatatableEditable') && !isSqlView"> |
|
|
|
<td |
|
|
|
<td |
|
|
|
v-t="['c:row:add:grid-bottom']" |
|
|
|
v-t="['c:row:add:grid-bottom']" |
|
|
|