From 205d4ecfe6ec2b07f87f9250d969f6d8cc2538ef Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sat, 28 Oct 2023 05:58:21 +0000 Subject: [PATCH 1/9] feat(nc-gui): keyboard support for multi fields editor --- .../components/smartsheet/details/Fields.vue | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue index 486f422d60..966fa572ad 100644 --- a/packages/nc-gui/components/smartsheet/details/Fields.vue +++ b/packages/nc-gui/components/smartsheet/details/Fields.vue @@ -3,6 +3,7 @@ import { diff } from 'deep-object-diff' import { message } from 'ant-design-vue' import { UITypes, isSystemColumn } from 'nocodb-sdk' import Draggable from 'vuedraggable' +import { onKeyDown, useMagicKeys } from '@vueuse/core' import type { ColumnType, SelectOptionsType } from 'nocodb-sdk' import { Icon } from '@iconify/vue' import { type Field, getUniqueColumnName, ref, useSmartsheetStoreOrThrow } from '#imports' @@ -39,6 +40,8 @@ const { getMeta } = useMetas() const { meta, view } = useSmartsheetStoreOrThrow() +const { openedViewsTab } = storeToRefs(useViewsStore()) + const moveOps = ref([]) const visibilityOps = ref([]) @@ -569,6 +572,33 @@ const toggleVisibility = async (checked: boolean, field: Field) => { }) } +onKeyDown('ArrowDown', () => { + const index = fields.value.findIndex((f) => compareCols(f, activeField.value)) + if (index === -1) changeField(fields.value[0]) + else if (index === fields.value.length - 1) changeField(fields.value[0]) + else changeField(fields.value[index + 1]) +}) +onKeyDown('ArrowUp', () => { + const index = fields.value.findIndex((f) => compareCols(f, activeField.value)) + if (index === -1) changeField(fields.value[0]) + else if (index === 0) changeField(fields.value[fields.value.length - 1]) + else changeField(fields.value[index - 1]) +}) + +onKeyDown('Delete', () => { + const isDeletedField = fieldStatus(activeField.value) === 'delete' + if (!isDeletedField && activeField.value) { + onFieldDelete(activeField.value) + } +}) + +const keys = useMagicKeys() + +whenever(keys.alt_c, () => { + if (!meta.value?.id) return + if (openedViewsTab.value === 'field') addField() +}) + const isColumnsValid = computed(() => fields.value.every((f) => isColumnValid(f))) onMounted(async () => { From ba86b5bcb5c891dd566842d15fca8766a94e119a Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sat, 28 Oct 2023 05:58:22 +0000 Subject: [PATCH 2/9] fix(nc-gui): delete menu background color --- packages/nc-gui/components/smartsheet/details/Fields.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue index 966fa572ad..34850da9df 100644 --- a/packages/nc-gui/components/smartsheet/details/Fields.vue +++ b/packages/nc-gui/components/smartsheet/details/Fields.vue @@ -760,7 +760,7 @@ onMounted(async () => { - +
Delete From dc3859aa583231ab6aeaaf41c3921afec6868c95 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sat, 28 Oct 2023 05:58:23 +0000 Subject: [PATCH 3/9] fix(nc-gui): creating new table in fields tab won't push to new table --- packages/nc-gui/composables/useTableNew.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/composables/useTableNew.ts b/packages/nc-gui/composables/useTableNew.ts index 9711342bcd..e2680d3b20 100644 --- a/packages/nc-gui/composables/useTableNew.ts +++ b/packages/nc-gui/composables/useTableNew.ts @@ -82,7 +82,7 @@ export function useTableNew(param: { onTableCreate?: (tableMeta: TableType) => v const views = viewsByTable.value.get(table.id as string) ?? [] - getMeta(table.id as string, (route.value.params?.viewId as string) !== table.id) + await getMeta(table.id as string, (route.value.params?.viewId as string) !== table.id) if (openedViewsTab.value !== 'view' && views.length && views[0].id) { await navigateTo({ From f8ec82dac6fbf9690cbbddb6bd883e8331f2fc5f Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sat, 28 Oct 2023 05:58:23 +0000 Subject: [PATCH 4/9] fix(nc-gui): new select options doesn't get saved on duplicate --- .../components/smartsheet/column/SelectOptions.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/column/SelectOptions.vue b/packages/nc-gui/components/smartsheet/column/SelectOptions.vue index d834c586d0..e9206cdd5a 100644 --- a/packages/nc-gui/components/smartsheet/column/SelectOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/SelectOptions.vue @@ -120,12 +120,6 @@ onMounted(() => { } }) -const optionChanged = (changedId: string) => { - if (changedId && changedId === defaultOption.value?.id) { - vModel.value.cdf = defaultOption.value.title - } -} - const getNextColor = () => { let tempColor = colors.value[0] if (options.value.length && options.value[options.value.length - 1].color) { @@ -191,6 +185,13 @@ const removeRenderedOption = (index: number) => { } } +const optionChanged = (changedId: string) => { + if (changedId && changedId === defaultOption.value?.id) { + vModel.value.cdf = defaultOption.value.title + } + syncOptions() +} + const undoRemoveRenderedOption = (index: number) => { renderedOptions.value[index].status = undefined syncOptions() From 6b2cacc991b7f04c485acae39401f4744147b74c Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sat, 28 Oct 2023 05:58:23 +0000 Subject: [PATCH 5/9] feat(nc-gui): cmd +s for saving fields in fields esitor --- .../components/smartsheet/details/Fields.vue | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue index 34850da9df..7e5ad0baad 100644 --- a/packages/nc-gui/components/smartsheet/details/Fields.vue +++ b/packages/nc-gui/components/smartsheet/details/Fields.vue @@ -484,7 +484,15 @@ const clearChanges = () => { changeField() } +const isColumnsValid = computed(() => fields.value.every((f) => isColumnValid(f))) + const saveChanges = async () => { + if (!isColumnsValid.value) { + message.error('Please complete the configuration of all fields before saving') + return + } else if (!loading.value && ops.value.length < 1 && moveOps.value.length < 1 && visibilityOps.value.length < 1) { + return + } try { if (!meta.value?.id) return @@ -572,6 +580,18 @@ const toggleVisibility = async (checked: boolean, field: Field) => { }) } +useEventListener(document, 'keydown', async (e: KeyboardEvent) => { + const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey + if (cmdOrCtrl) { + switch (e.key.toLowerCase()) { + case 's': + if (openedViewsTab.value !== 'field') return + e.preventDefault() + break + } + } +}) + onKeyDown('ArrowDown', () => { const index = fields.value.findIndex((f) => compareCols(f, activeField.value)) if (index === -1) changeField(fields.value[0]) @@ -594,12 +614,20 @@ onKeyDown('Delete', () => { const keys = useMagicKeys() -whenever(keys.alt_c, () => { +whenever(keys.altleft_c, () => { if (!meta.value?.id) return if (openedViewsTab.value === 'field') addField() }) -const isColumnsValid = computed(() => fields.value.every((f) => isColumnValid(f))) +whenever(keys.meta_s, () => { + if (!meta.value?.id) return + if (openedViewsTab.value === 'field') saveChanges() +}) + +whenever(keys.ctrl_s, () => { + if (!meta.value?.id) return + if (openedViewsTab.value === 'field') saveChanges() +}) onMounted(async () => { if (!meta.value?.id) return @@ -677,7 +705,7 @@ onMounted(async () => { visibilityOps.find((op) => op.column.fk_column_id === field.id)?.visible ?? viewFieldsMap[field.id].show " @change=" - (event) => { + (event: any) => { toggleVisibility(event.target.checked, viewFieldsMap[field.id]) } " @@ -778,7 +806,12 @@ onMounted(async () => {
-