diff --git a/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue b/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue index a70edb7d0c..1e8906ff66 100644 --- a/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue +++ b/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue @@ -83,6 +83,7 @@ async function onOpenModal({ view, tableId: table.value.id!, baseId: base.value.id!, + doNotSwitchTab: true, }) $e('a:view:create', { view: view.type }) diff --git a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue index 9fea597e9d..9c56d8f896 100644 --- a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue +++ b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue @@ -230,7 +230,7 @@ if (props.fromTableExplorer) { 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() diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue index 486f422d60..6b104d1e20 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([]) @@ -481,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 @@ -569,7 +580,78 @@ const toggleVisibility = async (checked: boolean, field: Field) => { }) } -const isColumnsValid = computed(() => fields.value.every((f) => isColumnValid(f))) +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]) + 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', () => { + if (document.activeElement?.tagName === 'INPUT') return + const isDeletedField = fieldStatus(activeField.value) === 'delete' + if (!isDeletedField && activeField.value) { + onFieldDelete(activeField.value) + } +}) + +onKeyDown('Backspace', () => { + if (document.activeElement?.tagName === 'INPUT') return + const isDeletedField = fieldStatus(activeField.value) === 'delete' + if (!isDeletedField && activeField.value) { + onFieldDelete(activeField.value) + } +}) + +onKeyDown('ArrowRight', () => { + if (document.activeElement?.tagName === 'INPUT') return + if (activeField.value) { + const input = document.querySelector('.nc-fields-input') + if (input) { + input.focus() + } + } +}) + +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, () => { + 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 @@ -647,7 +729,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]) } " @@ -730,7 +812,7 @@ onMounted(async () => { - +
Delete @@ -748,7 +830,12 @@ onMounted(async () => {
-