mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
committed by
GitHub
44 changed files with 672 additions and 177 deletions
@ -1,11 +1,40 @@ |
|||||||
<script setup lang="ts"> |
<script setup lang="ts"> |
||||||
import { CellValueInj, inject } from '#imports' |
import { CellValueInj, inject, refAutoReset } from '#imports' |
||||||
|
|
||||||
const value = inject(CellValueInj) |
const value = inject(CellValueInj) |
||||||
|
|
||||||
|
const timeout = 3000 // in ms |
||||||
|
|
||||||
|
const showEditWarning = refAutoReset(false, timeout) |
||||||
|
const showClearWarning = refAutoReset(false, timeout) |
||||||
|
|
||||||
|
useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e: KeyboardEvent) => { |
||||||
|
switch (e.key) { |
||||||
|
case 'Enter': |
||||||
|
showEditWarning.value = true |
||||||
|
break |
||||||
|
case 'Delete': |
||||||
|
showClearWarning.value = true |
||||||
|
break |
||||||
|
} |
||||||
|
}) |
||||||
</script> |
</script> |
||||||
|
|
||||||
<template> |
<template> |
||||||
|
<div> |
||||||
<span class="text-center pl-3"> |
<span class="text-center pl-3"> |
||||||
{{ value }} |
{{ value }} |
||||||
</span> |
</span> |
||||||
|
|
||||||
|
<div> |
||||||
|
<div v-if="showEditWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs"> |
||||||
|
<!-- TODO: i18n --> |
||||||
|
Warning: Computed field - unable to edit content. |
||||||
|
</div> |
||||||
|
<div v-if="showClearWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs"> |
||||||
|
<!-- TODO: i18n --> |
||||||
|
Warning: Computed field - unable to clear content. |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
</template> |
</template> |
||||||
|
@ -0,0 +1,21 @@ |
|||||||
|
import { isClient } from '@vueuse/core' |
||||||
|
import type { Ref } from 'vue' |
||||||
|
|
||||||
|
export function useSelectedCellKeyupListener(selected: Ref<boolean>, handler: (e: KeyboardEvent) => void) { |
||||||
|
if (isClient) { |
||||||
|
watch(selected, (nextVal, _, cleanup) => { |
||||||
|
// bind listener when `selected` is truthy
|
||||||
|
if (nextVal) { |
||||||
|
document.addEventListener('keydown', handler, true) |
||||||
|
// if `selected` is falsy then remove the event handler
|
||||||
|
} else { |
||||||
|
document.removeEventListener('keydown', handler, true) |
||||||
|
} |
||||||
|
|
||||||
|
// cleanup is called whenever the watcher is re-evaluated or stopped
|
||||||
|
cleanup(() => { |
||||||
|
document.removeEventListener('keydown', handler, true) |
||||||
|
}) |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
// refer - https://stackoverflow.com/a/11752084
|
||||||
|
export const isMac = () => /Mac/i.test(navigator.platform) |
@ -0,0 +1,14 @@ |
|||||||
|
import { UITypes } from 'nocodb-sdk'; |
||||||
|
import { MetaTable } from '../utils/globals'; |
||||||
|
import { NcUpgraderCtx } from './NcUpgrader'; |
||||||
|
|
||||||
|
// The Count and AutoNumber types are removed
|
||||||
|
// so convert all existing Count and AutoNumber fields to Number type
|
||||||
|
export default async function (ctx: NcUpgraderCtx) { |
||||||
|
// directly update uidt of all existing Count and AutoNumber fields to Number
|
||||||
|
await ctx.ncMeta.knex |
||||||
|
.update({ uidt: UITypes.Number }) |
||||||
|
.where({ uidt: UITypes.Count }) |
||||||
|
.orWhere({ uidt: UITypes.AutoNumber }) |
||||||
|
.table(MetaTable.COLUMNS); |
||||||
|
} |
Loading…
Reference in new issue