|
|
@ -582,16 +582,31 @@ const toggleVisibility = async (checked: boolean, field: Field) => { |
|
|
|
|
|
|
|
|
|
|
|
useEventListener(document, 'keydown', async (e: KeyboardEvent) => { |
|
|
|
useEventListener(document, 'keydown', async (e: KeyboardEvent) => { |
|
|
|
const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey |
|
|
|
const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey |
|
|
|
if (cmdOrCtrl) { |
|
|
|
|
|
|
|
switch (e.key.toLowerCase()) { |
|
|
|
if (cmdOrCtrl && e.key.toLowerCase() === 's') { |
|
|
|
case 's': |
|
|
|
if (openedViewsTab.value !== 'field') return |
|
|
|
if (openedViewsTab.value !== 'field') return |
|
|
|
e.preventDefault() |
|
|
|
e.preventDefault() |
|
|
|
|
|
|
|
break |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For Windows and mac |
|
|
|
|
|
|
|
if ((e.altKey && e.key.toLowerCase() === 'c') || (e.altKey && e.code === 'KeyC')) { |
|
|
|
|
|
|
|
if (openedViewsTab.value !== 'field') return |
|
|
|
|
|
|
|
e.preventDefault() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addField() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const renderCmdOrCtrlKey = () => { |
|
|
|
|
|
|
|
return isMac() ? '⌘' : 'Ctrl' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const renderAltOrOptlKey = () => { |
|
|
|
|
|
|
|
return isMac() ? '⌥' : 'ALT' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onKeyDown('ArrowDown', () => { |
|
|
|
onKeyDown('ArrowDown', () => { |
|
|
|
const index = fields.value.findIndex((f) => compareCols(f, activeField.value)) |
|
|
|
const index = fields.value.findIndex((f) => compareCols(f, activeField.value)) |
|
|
|
if (index === -1) changeField(fields.value[0]) |
|
|
|
if (index === -1) changeField(fields.value[0]) |
|
|
@ -633,16 +648,6 @@ onKeyDown('ArrowRight', () => { |
|
|
|
|
|
|
|
|
|
|
|
const keys = useMagicKeys() |
|
|
|
const keys = useMagicKeys() |
|
|
|
|
|
|
|
|
|
|
|
whenever(keys.altleft_c, () => { |
|
|
|
|
|
|
|
if (!meta.value?.id) return |
|
|
|
|
|
|
|
if (openedViewsTab.value === 'field') addField() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
whenever(keys.option_c, () => { |
|
|
|
|
|
|
|
if (!meta.value?.id) return |
|
|
|
|
|
|
|
if (openedViewsTab.value === 'field') addField() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
whenever(keys.meta_s, () => { |
|
|
|
whenever(keys.meta_s, () => { |
|
|
|
if (!meta.value?.id) return |
|
|
|
if (!meta.value?.id) return |
|
|
|
if (openedViewsTab.value === 'field') saveChanges() |
|
|
|
if (openedViewsTab.value === 'field') saveChanges() |
|
|
@ -653,9 +658,20 @@ whenever(keys.ctrl_s, () => { |
|
|
|
if (openedViewsTab.value === 'field') saveChanges() |
|
|
|
if (openedViewsTab.value === 'field') saveChanges() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
|
|
|
meta, |
|
|
|
|
|
|
|
async (newMeta) => { |
|
|
|
|
|
|
|
if (newMeta?.id) { |
|
|
|
|
|
|
|
columnsHash.value = (await $api.dbTableColumn.hash(newMeta.id)).hash |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ deep: true }, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
onMounted(async () => { |
|
|
|
if (!meta.value?.id) return |
|
|
|
if (meta.value && meta.value.id) { |
|
|
|
columnsHash.value = (await $api.dbTableColumn.hash(meta.value?.id)).hash |
|
|
|
columnsHash.value = (await $api.dbTableColumn.hash(meta.value.id)).hash |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
@ -686,12 +702,15 @@ onMounted(async () => { |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</a-input> |
|
|
|
</a-input> |
|
|
|
<div class="flex gap-2"> |
|
|
|
<div class="flex gap-2"> |
|
|
|
<NcButton type="secondary" size="small" class="mr-1" :disabled="loading" @click="addField()"> |
|
|
|
<NcTooltip> |
|
|
|
<div class="flex items-center gap-2"> |
|
|
|
<template #title> {{ `${renderAltOrOptlKey()} + C` }} </template> |
|
|
|
<GeneralIcon icon="plus" class="h-3.5 mb-1 w-3.5" /> |
|
|
|
<NcButton type="secondary" size="small" class="mr-1" :disabled="loading" @click="addField()"> |
|
|
|
New field |
|
|
|
<div class="flex items-center gap-2"> |
|
|
|
</div> |
|
|
|
<GeneralIcon icon="plus" class="w-3" /> |
|
|
|
</NcButton> |
|
|
|
New Field |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</NcButton> |
|
|
|
|
|
|
|
</NcTooltip> |
|
|
|
<NcButton |
|
|
|
<NcButton |
|
|
|
type="secondary" |
|
|
|
type="secondary" |
|
|
|
size="small" |
|
|
|
size="small" |
|
|
@ -700,15 +719,19 @@ onMounted(async () => { |
|
|
|
> |
|
|
|
> |
|
|
|
Reset |
|
|
|
Reset |
|
|
|
</NcButton> |
|
|
|
</NcButton> |
|
|
|
<NcButton |
|
|
|
<NcTooltip> |
|
|
|
type="primary" |
|
|
|
<template #title> {{ `${renderCmdOrCtrlKey()} + S` }} </template> |
|
|
|
size="small" |
|
|
|
|
|
|
|
:loading="loading" |
|
|
|
<NcButton |
|
|
|
:disabled="isColumnsValid ? !loading && ops.length < 1 && moveOps.length < 1 && visibilityOps.length < 1 : true" |
|
|
|
type="primary" |
|
|
|
@click="saveChanges()" |
|
|
|
size="small" |
|
|
|
> |
|
|
|
:loading="loading" |
|
|
|
Save changes |
|
|
|
:disabled="isColumnsValid ? !loading && ops.length < 1 && moveOps.length < 1 && visibilityOps.length < 1 : true" |
|
|
|
</NcButton> |
|
|
|
@click="saveChanges()" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
Save changes |
|
|
|
|
|
|
|
</NcButton> |
|
|
|
|
|
|
|
</NcTooltip> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="flex flex-row rounded-lg border-1 border-gray-200"> |
|
|
|
<div class="flex flex-row rounded-lg border-1 border-gray-200"> |
|
|
|