|
|
@ -1,7 +1,6 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { isVirtualCol } from 'nocodb-sdk' |
|
|
|
import { isVirtualCol } from 'nocodb-sdk' |
|
|
|
import { |
|
|
|
import { |
|
|
|
Row, |
|
|
|
|
|
|
|
inject, |
|
|
|
inject, |
|
|
|
onKeyStroke, |
|
|
|
onKeyStroke, |
|
|
|
onMounted, |
|
|
|
onMounted, |
|
|
@ -22,8 +21,9 @@ import { |
|
|
|
PaginationDataInj, |
|
|
|
PaginationDataInj, |
|
|
|
ReloadViewDataHookInj, |
|
|
|
ReloadViewDataHookInj, |
|
|
|
} from '~/context' |
|
|
|
} from '~/context' |
|
|
|
import MdiPlusIcon from '~icons/mdi/plus' |
|
|
|
import { NavigateDir } from '~/lib' |
|
|
|
import MdiArrowExpandIcon from '~icons/mdi/arrow-expand' |
|
|
|
import MdiArrowExpandIcon from '~icons/mdi/arrow-expand' |
|
|
|
|
|
|
|
import MdiPlusIcon from '~icons/mdi/plus' |
|
|
|
|
|
|
|
|
|
|
|
const meta = inject(MetaInj) |
|
|
|
const meta = inject(MetaInj) |
|
|
|
const view = inject(ActiveViewInj) |
|
|
|
const view = inject(ActiveViewInj) |
|
|
@ -42,10 +42,7 @@ const addColumnDropdown = ref(false) |
|
|
|
const contextMenu = ref(false) |
|
|
|
const contextMenu = ref(false) |
|
|
|
const contextMenuTarget = ref(false) |
|
|
|
const contextMenuTarget = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const visibleColLength = $computed(() => { |
|
|
|
const visibleColLength = $computed(() => fields.value?.length) |
|
|
|
const cols = fields.value |
|
|
|
|
|
|
|
return cols.filter((col) => !isVirtualCol(col)).length |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
|
loadData, |
|
|
|
loadData, |
|
|
@ -131,7 +128,7 @@ const clearCell = async (ctx: { row: number; col: number }) => { |
|
|
|
|
|
|
|
|
|
|
|
/** handle keypress events */ |
|
|
|
/** handle keypress events */ |
|
|
|
onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'], async (e: KeyboardEvent) => { |
|
|
|
onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'], async (e: KeyboardEvent) => { |
|
|
|
if (selected.row !== null && selected.col !== null) { |
|
|
|
if (selected.row === null || selected.col === null) return |
|
|
|
/** on tab key press navigate through cells */ |
|
|
|
/** on tab key press navigate through cells */ |
|
|
|
switch (e.key) { |
|
|
|
switch (e.key) { |
|
|
|
case 'Tab': |
|
|
|
case 'Tab': |
|
|
@ -180,8 +177,29 @@ onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLe |
|
|
|
if (selected.row < data.value.length - 1) selected.row++ |
|
|
|
if (selected.row < data.value.length - 1) selected.row++ |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onNavigate = (dir: NavigateDir) => { |
|
|
|
|
|
|
|
if (selected.row === null || selected.col === null) return |
|
|
|
|
|
|
|
switch (dir) { |
|
|
|
|
|
|
|
case NavigateDir.NEXT: |
|
|
|
|
|
|
|
if (selected.col < visibleColLength - 1) { |
|
|
|
|
|
|
|
selected.col++ |
|
|
|
|
|
|
|
} else if (selected.row < data.value.length - 1) { |
|
|
|
|
|
|
|
selected.row++ |
|
|
|
|
|
|
|
selected.col = 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
case NavigateDir.PREV: |
|
|
|
|
|
|
|
if (selected.col > 0) { |
|
|
|
|
|
|
|
selected.col-- |
|
|
|
|
|
|
|
} else if (selected.row > 0) { |
|
|
|
|
|
|
|
selected.row-- |
|
|
|
|
|
|
|
selected.col = visibleColLength - 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -255,15 +273,25 @@ onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLe |
|
|
|
@dblclick="editEnabled = true" |
|
|
|
@dblclick="editEnabled = true" |
|
|
|
@contextmenu="contextMenuTarget = { row: rowIndex, col: colIndex }" |
|
|
|
@contextmenu="contextMenuTarget = { row: rowIndex, col: colIndex }" |
|
|
|
> |
|
|
|
> |
|
|
|
<SmartsheetVirtualCell v-if="isVirtualCol(columnObj)" v-model="row.row[columnObj.title]" :column="columnObj" /> |
|
|
|
<div class="w-full h-full"> |
|
|
|
|
|
|
|
<SmartsheetVirtualCell |
|
|
|
|
|
|
|
v-if="isVirtualCol(columnObj)" |
|
|
|
|
|
|
|
v-model="row.row[columnObj.title]" |
|
|
|
|
|
|
|
:column="columnObj" |
|
|
|
|
|
|
|
@navigate="onNavigate" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<SmartsheetCell |
|
|
|
<SmartsheetCell |
|
|
|
v-else |
|
|
|
v-else |
|
|
|
v-model="row.row[columnObj.title]" |
|
|
|
v-model="row.row[columnObj.title]" |
|
|
|
:column="columnObj" |
|
|
|
:column="columnObj" |
|
|
|
:edit-enabled="editEnabled && selected.col === colIndex && selected.row === rowIndex" |
|
|
|
:edit-enabled="editEnabled && selected.col === colIndex && selected.row === rowIndex" |
|
|
|
|
|
|
|
@update:edit-enabled="editEnabled = false" |
|
|
|
@save="updateOrSaveRow(row, columnObj.title)" |
|
|
|
@save="updateOrSaveRow(row, columnObj.title)" |
|
|
|
|
|
|
|
@navigate="onNavigate" |
|
|
|
|
|
|
|
@cancel="editEnabled = false" |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
</td> |
|
|
|
</td> |
|
|
|
</tr> |
|
|
|
</tr> |
|
|
|
|
|
|
|
|
|
|
@ -318,13 +346,13 @@ onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLe |
|
|
|
min-height: 41px !important; |
|
|
|
min-height: 41px !important; |
|
|
|
height: 41px !important; |
|
|
|
height: 41px !important; |
|
|
|
position: relative; |
|
|
|
position: relative; |
|
|
|
padding: 0 5px; |
|
|
|
//padding: 0 5px; |
|
|
|
|
|
|
|
|
|
|
|
& > * { |
|
|
|
& > div { |
|
|
|
|
|
|
|
overflow: hidden; |
|
|
|
@apply flex align-center h-auto; |
|
|
|
@apply flex align-center h-auto; |
|
|
|
|
|
|
|
padding: 0 5px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
overflow: hidden; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
table, |
|
|
|
table, |
|
|
@ -360,7 +388,7 @@ onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
td.active::before { |
|
|
|
td.active::before { |
|
|
|
background: #0040bc /*var(--v-primary-base)*/; |
|
|
|
background: #0040bc; |
|
|
|
opacity: 0.1; |
|
|
|
opacity: 0.1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|