Browse Source

chore(gui): lint

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4222/head
Pranav C 2 years ago
parent
commit
6dba597fef
  1. 57
      packages/nc-gui/components/cell/attachment/index.vue
  2. 8
      packages/nc-gui/components/smartsheet/Grid.vue
  3. 85
      packages/nc-gui/composables/useMultiSelect/index.ts

57
packages/nc-gui/components/cell/attachment/index.vue

@ -123,37 +123,36 @@ watch(
} }
} }
}, },
{ {
immediate: true immediate: true,
} },
, )
)
/** updates attachments array for autosave */ /** updates attachments array for autosave */
function updateModelValue(data: string | Record<string, any>[]) { function updateModelValue(data: string | Record<string, any>[]) {
emits('update:modelValue', data) emits('update:modelValue', data)
} }
/** Close modal on escape press, disable dropzone as well */ /** Close modal on escape press, disable dropzone as well */
onKeyDown('Escape', () => { onKeyDown('Escape', () => {
modalVisible.value = false modalVisible.value = false
isOverDropZone.value = false isOverDropZone.value = false
}) })
/** sync storedFiles state with row state */ /** sync storedFiles state with row state */
watch( watch(
() => storedFiles.value.length || 0, () => storedFiles.value.length || 0,
() => { () => {
rowState.value[column.value!.title!] = storedFiles.value rowState.value[column.value!.title!] = storedFiles.value
}, },
) )
useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e) => { useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e) => {
if (e.key === 'Enter' && !isReadonly.value) { if (e.key === 'Enter' && !isReadonly.value) {
e.stopPropagation() e.stopPropagation()
modalVisible.value = true modalVisible.value = true
} }
}) })
</script> </script>
<template> <template>

8
packages/nc-gui/components/smartsheet/Grid.vue

@ -206,25 +206,25 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange
selected.row = 0 selected.row = 0
selected.col = selected.col ?? 0 selected.col = selected.col ?? 0
scrollToCell?.() scrollToCell?.()
editEnabled = false; editEnabled = false
return true return true
case 'ArrowDown': case 'ArrowDown':
selected.row = data.value.length - 1 selected.row = data.value.length - 1
selected.col = selected.col ?? 0 selected.col = selected.col ?? 0
scrollToCell?.() scrollToCell?.()
editEnabled = false; editEnabled = false
return true return true
case 'ArrowRight': case 'ArrowRight':
selected.row = selected.row ?? 0 selected.row = selected.row ?? 0
selected.col = fields.value?.length - 1 selected.col = fields.value?.length - 1
scrollToCell?.() scrollToCell?.()
editEnabled = false; editEnabled = false
return true return true
case 'ArrowLeft': case 'ArrowLeft':
selected.row = selected.row ?? 0 selected.row = selected.row ?? 0
selected.col = 0 selected.col = 0
scrollToCell?.() scrollToCell?.()
editEnabled = false; editEnabled = false
return true return true
} }
} }

85
packages/nc-gui/composables/useMultiSelect/index.ts

@ -1,6 +1,6 @@
import type { MaybeRef } from '@vueuse/core' import type { MaybeRef } from '@vueuse/core'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import { message, reactive, unref, useCopy, useEventListener, useI18n, ref } from '#imports' import { message, reactive, ref, unref, useCopy, useEventListener, useI18n } from '#imports'
interface SelectedBlock { interface SelectedBlock {
row: number | null row: number | null
@ -227,60 +227,61 @@ export function useMultiSelect(
editEnabled.value = false editEnabled.value = false
} }
break break
default: { default:
const rowObj = unref(data)[selected.row] {
const rowObj = unref(data)[selected.row]
const columnObj = unref(fields)[selected.col] const columnObj = unref(fields)[selected.col]
let cptext = '' // variable for save the text to be copy let cptext = '' // variable for save the text to be copy
if (!isNaN(rangeRows.minRow) && !isNaN(rangeRows.maxRow) && !isNaN(rangeRows.minCol) && !isNaN(rangeRows.maxCol)) { if (!isNaN(rangeRows.minRow) && !isNaN(rangeRows.maxRow) && !isNaN(rangeRows.minCol) && !isNaN(rangeRows.maxCol)) {
const cprows = unref(data).slice(rangeRows.minRow, rangeRows.maxRow + 1) // slice the selected rows for copy const cprows = unref(data).slice(rangeRows.minRow, rangeRows.maxRow + 1) // slice the selected rows for copy
const cpcols = unref(fields).slice(rangeRows.minCol, rangeRows.maxCol + 1) // slice the selected cols for copy const cpcols = unref(fields).slice(rangeRows.minCol, rangeRows.maxCol + 1) // slice the selected cols for copy
cprows.forEach((row) => { cprows.forEach((row) => {
cpcols.forEach((col) => { cpcols.forEach((col) => {
// todo: JSON stringify the attachment cell and LTAR contents for copy // todo: JSON stringify the attachment cell and LTAR contents for copy
// filter attachment cells and LATR cells from copy // filter attachment cells and LATR cells from copy
if (col.uidt !== UITypes.Attachment && col.uidt !== UITypes.LinkToAnotherRecord) { if (col.uidt !== UITypes.Attachment && col.uidt !== UITypes.LinkToAnotherRecord) {
cptext = `${cptext} ${row.row[col.title]} \t` cptext = `${cptext} ${row.row[col.title]} \t`
} }
}) })
cptext = `${cptext.trim()}\n`
})
cptext.trim() cptext = `${cptext.trim()}\n`
} else { })
cptext = rowObj.row[columnObj.title] || ''
}
if ((!unref(editEnabled) && e.metaKey) || e.ctrlKey) { cptext.trim()
switch (e.keyCode) { } else {
// copy - ctrl/cmd +c cptext = rowObj.row[columnObj.title] || ''
case 67:
await copy(cptext)
break
} }
}
if (unref(editEnabled) || e.ctrlKey || e.altKey || e.metaKey) { if ((!unref(editEnabled) && e.metaKey) || e.ctrlKey) {
return switch (e.keyCode) {
} // copy - ctrl/cmd +c
case 67:
await copy(cptext)
break
}
}
/** on letter key press make cell editable and empty */ if (unref(editEnabled) || e.ctrlKey || e.altKey || e.metaKey) {
if (e.key.length === 1) { return
if (!unref(isPkAvail) && !rowObj.rowMeta.new) {
// Update not allowed for table which doesn't have primary Key
return message.info(t('msg.info.updateNotAllowedWithoutPK'))
} }
if (makeEditable(rowObj, columnObj)) {
rowObj.row[columnObj.title] = '' /** on letter key press make cell editable and empty */
if (e.key.length === 1) {
if (!unref(isPkAvail) && !rowObj.rowMeta.new) {
// Update not allowed for table which doesn't have primary Key
return message.info(t('msg.info.updateNotAllowedWithoutPK'))
}
if (makeEditable(rowObj, columnObj)) {
rowObj.row[columnObj.title] = ''
}
// editEnabled = true
} }
// editEnabled = true
} }
}
break break
} }
} }

Loading…
Cancel
Save