|
|
@ -1,6 +1,7 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { isVirtualCol } from 'nocodb-sdk' |
|
|
|
import { ColumnType, isVirtualCol } from 'nocodb-sdk' |
|
|
|
import { |
|
|
|
import { |
|
|
|
|
|
|
|
Row, |
|
|
|
inject, |
|
|
|
inject, |
|
|
|
onKeyStroke, |
|
|
|
onKeyStroke, |
|
|
|
onMounted, |
|
|
|
onMounted, |
|
|
@ -118,6 +119,19 @@ watch(contextMenu, () => { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const clearCell = async (ctx: { row: number; col: number }) => { |
|
|
|
|
|
|
|
const rowObj = data.value[ctx.row] |
|
|
|
|
|
|
|
const columnObj = fields.value[ctx.col] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isVirtualCol(columnObj)) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowObj.row[columnObj.title] = null |
|
|
|
|
|
|
|
// update/save cell value |
|
|
|
|
|
|
|
await updateOrSaveRow(rowObj, columnObj.title) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 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) { |
|
|
@ -148,19 +162,8 @@ onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLe |
|
|
|
break |
|
|
|
break |
|
|
|
/** on delete key press clear cell */ |
|
|
|
/** on delete key press clear cell */ |
|
|
|
case 'Delete': |
|
|
|
case 'Delete': |
|
|
|
{ |
|
|
|
|
|
|
|
e.preventDefault() |
|
|
|
e.preventDefault() |
|
|
|
const rowObj = data.value[selected.row] |
|
|
|
await clearCell(selected as { row: number; col: number }) |
|
|
|
const columnObj = fields.value[selected.col] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isVirtualCol(columnObj)) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowObj.row[columnObj.title] = null |
|
|
|
|
|
|
|
// update/save cell value |
|
|
|
|
|
|
|
await updateOrSaveRow(rowObj, columnObj.title) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
/** on arrow key press navigate through cells */ |
|
|
|
/** on arrow key press navigate through cells */ |
|
|
|
case 'ArrowRight': |
|
|
|
case 'ArrowRight': |
|
|
@ -294,7 +297,7 @@ onKeyStroke(['Tab', 'Shift', 'Enter', 'Delete', 'ArrowDown', 'ArrowUp', 'ArrowLe |
|
|
|
<div class="bg-white shadow" @click="contextMenu = false"> |
|
|
|
<div class="bg-white shadow" @click="contextMenu = false"> |
|
|
|
<div v-if="contextMenuTarget" class="nc-menu-item" @click="deleteRow(contextMenuTarget.row)">Delete row</div> |
|
|
|
<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 class="nc-menu-item" @click="deleteSelectedRows">Delete all selected rows</div> |
|
|
|
<div v-if="contextMenuTarget" class="nc-menu-item" >Clear cell</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 v-if="contextMenuTarget" class="nc-menu-item" @click="addEmptyRow(contextMenuTarget.row + 1)">Insert new row</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|