|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
|
import { onClickOutside, useEventListener } from '@vueuse/core' |
|
|
|
|
import type { ColumnType } from 'nocodb-sdk' |
|
|
|
|
import { isVirtualCol } from 'nocodb-sdk' |
|
|
|
|
import { UITypes, isVirtualCol } from 'nocodb-sdk' |
|
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
|
import { |
|
|
|
|
inject, |
|
|
|
@ -228,6 +228,12 @@ useEventListener(document, 'keydown', onKeyDown)
|
|
|
|
|
/** On clicking outside of table reset active cell */ |
|
|
|
|
const smartTable = ref(null) |
|
|
|
|
onClickOutside(smartTable, () => { |
|
|
|
|
if (selected.col === null) return |
|
|
|
|
|
|
|
|
|
const activeCol = fields.value[selected.col] |
|
|
|
|
|
|
|
|
|
if (editEnabled && (isVirtualCol(activeCol) || activeCol.uidt === UITypes.JSON)) return |
|
|
|
|
|
|
|
|
|
selected.row = null |
|
|
|
|
selected.col = null |
|
|
|
|
}) |
|
|
|
@ -255,7 +261,7 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
<a-dropdown v-model:visible="contextMenu" :trigger="['contextmenu']"> |
|
|
|
|
<table ref="smartTable" class="xc-row-table nc-grid backgroundColorDefault" @contextmenu.prevent="contextMenu = true"> |
|
|
|
|
<thead> |
|
|
|
|
<tr class="group"> |
|
|
|
|
<tr> |
|
|
|
|
<th> |
|
|
|
|
<div class="flex align-center w-[80px]"> |
|
|
|
|
<div class="group-hover:hidden" :class="{ hidden: selectedAllRecords }">#</div> |
|
|
|
@ -264,6 +270,7 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
class="group-hover:flex w-full align-center" |
|
|
|
|
> |
|
|
|
|
<a-checkbox v-model:checked="selectedAllRecords" /> |
|
|
|
|
|
|
|
|
|
<span class="flex-1" /> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -279,6 +286,7 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
@xcresized="resizingCol = null" |
|
|
|
|
> |
|
|
|
|
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" /> |
|
|
|
|
|
|
|
|
|
<SmartsheetHeaderCell v-else :column="col" /> |
|
|
|
|
</th> |
|
|
|
|
<!-- v-if="!isLocked && !isVirtual && !isPublicView && _isUIAllowed('add-column')" --> |
|
|
|
@ -287,6 +295,7 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
<div class="h-full w-[60px] flex align-center justify-center"> |
|
|
|
|
<MdiPlus class="text-sm" /> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<template #overlay> |
|
|
|
|
<SmartsheetColumnEditOrAdd @click.stop @cancel="addColumnDropdown = false" /> |
|
|
|
|
</template> |
|
|
|
@ -295,7 +304,7 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
</tr> |
|
|
|
|
</thead> |
|
|
|
|
<tbody> |
|
|
|
|
<tr v-for="(row, rowIndex) of data" :key="rowIndex" class="nc-grid-row"> |
|
|
|
|
<tr v-for="(row, rowIndex) of data" :key="rowIndex" class="nc-grid-row group"> |
|
|
|
|
<td key="row-index" class="caption nc-grid-cell group"> |
|
|
|
|
<div class="flex items-center w-[80px]"> |
|
|
|
|
<div class="group-hover:hidden" :class="{ hidden: row.rowMeta.selected }">{{ rowIndex + 1 }}</div> |
|
|
|
@ -304,6 +313,7 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
class="group-hover:flex w-full items-center justify-between p-1" |
|
|
|
|
> |
|
|
|
|
<a-checkbox v-model:checked="row.rowMeta.selected" /> |
|
|
|
|
<span class="flex-1" /> |
|
|
|
|
<div class="cursor-pointer flex items-center border-1 active:ring rounded p-1 hover:bg-primary/10"> |
|
|
|
|
<MdiArrowExpand class="select-none transform hover:(text-pink-500 scale-120)" /> |
|
|
|
|
</div> |
|
|
|
@ -313,10 +323,11 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
<td |
|
|
|
|
v-for="(columnObj, colIndex) of fields" |
|
|
|
|
:key="rowIndex + columnObj.title" |
|
|
|
|
class="cell pointer nc-grid-cell" |
|
|
|
|
class="cell relative cursor-pointer nc-grid-cell" |
|
|
|
|
:class="{ |
|
|
|
|
active: !isPublicView && selected.col === colIndex && selected.row === rowIndex, |
|
|
|
|
}" |
|
|
|
|
:data-key="rowIndex + columnObj.id" |
|
|
|
|
:data-col="columnObj.id" |
|
|
|
|
:data-title="columnObj.title" |
|
|
|
|
@click="selectCell(rowIndex, colIndex)" |
|
|
|
@ -338,6 +349,7 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
v-model="row.row[columnObj.title]" |
|
|
|
|
:column="columnObj" |
|
|
|
|
:edit-enabled="editEnabled && selected.col === colIndex && selected.row === rowIndex" |
|
|
|
|
:row-index="rowIndex" |
|
|
|
|
@update:edit-enabled="editEnabled = false" |
|
|
|
|
@save="updateOrSaveRow(row, columnObj.title)" |
|
|
|
|
@navigate="onNavigate" |
|
|
|
@ -366,14 +378,18 @@ const onNavigate = (dir: NavigateDir) => {
|
|
|
|
|
</tbody> |
|
|
|
|
</table> |
|
|
|
|
<template #overlay> |
|
|
|
|
<div class="bg-white shadow" @click="contextMenu = false"> |
|
|
|
|
<div v-if="contextMenuTarget" class="nc-menu-item" @click="deleteRow(contextMenuTarget.row)">Delete row</div> |
|
|
|
|
<div class="nc-menu-item" @click="deleteSelectedRows">Delete all selected rows</div> |
|
|
|
|
<div v-if="contextMenuTarget" class="nc-menu-item" @click="clearCell(contextMenuTarget)">Clear cell</div> |
|
|
|
|
<div v-if="contextMenuTarget" class="nc-menu-item" @click="addEmptyRow(contextMenuTarget.row + 1)"> |
|
|
|
|
Insert new row |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<a-menu class="bg-white shadow" @click="contextMenu = false"> |
|
|
|
|
<a-menu-item v-if="contextMenuTarget" @click="deleteRow(contextMenuTarget.row)" |
|
|
|
|
><span class="text-xs">Delete row</span></a-menu-item |
|
|
|
|
> |
|
|
|
|
<a-menu-item @click="deleteSelectedRows"><span class="text-xs">Delete all selected rows</span></a-menu-item> |
|
|
|
|
<a-menu-item v-if="contextMenuTarget" @click="clearCell(contextMenuTarget)" |
|
|
|
|
><span class="text-xs">Clear cell</span> |
|
|
|
|
</a-menu-item> |
|
|
|
|
<a-menu-item v-if="contextMenuTarget" @click="addEmptyRow(contextMenuTarget.row + 1)"> |
|
|
|
|
<span class="text-xs">Insert new row</span> |
|
|
|
|
</a-menu-item> |
|
|
|
|
</a-menu> |
|
|
|
|
</template> |
|
|
|
|
</a-dropdown> |
|
|
|
|
</div> |
|
|
|
|