Browse Source

Merge pull request #6486 from nocodb/fix/link

fix: preloader fix in link modal
nc-refactor/rename-to-base-and-src
Sreehari jayaraj 12 months ago committed by GitHub
parent
commit
63aa51854f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/nc-gui/assets/nc-icons/project.svg
  2. 12
      packages/nc-gui/assets/nc-icons/record.svg
  3. 16
      packages/nc-gui/assets/nc-icons/table.svg
  4. 3
      packages/nc-gui/components/cell/Text.vue
  5. 5
      packages/nc-gui/components/cell/TextArea.vue
  6. 4
      packages/nc-gui/components/dashboard/TreeView/TableNode.vue
  7. 2
      packages/nc-gui/components/dashboard/settings/Metadata.vue
  8. 5
      packages/nc-gui/components/dashboard/settings/UIAcl.vue
  9. 2
      packages/nc-gui/components/dlg/TableDelete.vue
  10. 2
      packages/nc-gui/components/general/ProjectIcon.vue
  11. 1
      packages/nc-gui/components/general/TableIcon.vue
  12. 27
      packages/nc-gui/components/general/UserIcon.vue
  13. 2
      packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue
  14. 21
      packages/nc-gui/components/smartsheet/expanded-form/Comments.vue
  15. 115
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  16. 15
      packages/nc-gui/components/virtual-cell/Links.vue
  17. 4
      packages/nc-gui/components/virtual-cell/components/Header.vue
  18. 168
      packages/nc-gui/components/virtual-cell/components/ListChildItems.vue
  19. 9
      packages/nc-gui/components/virtual-cell/components/ListItems.vue
  20. 3
      packages/nc-gui/lang/en.json
  21. 9
      packages/nc-gui/utils/iconUtils.ts
  22. 22
      tests/playwright/pages/Dashboard/ExpandedForm/index.ts
  23. 29
      tests/playwright/tests/db/features/expandedFormUrl.spec.ts
  24. 4
      tests/playwright/tests/db/features/keyboardShortcuts.spec.ts

16
packages/nc-gui/assets/nc-icons/project.svg

@ -1,9 +1,9 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.99294 14.8095L14.548 12.28C14.8177 12.1572 14.9569 11.9975 14.9659 11.8367H1C1.00896 11.9975 1.14826 12.1572 1.4179 12.28L6.97294 14.8095C7.53075 15.0635 8.43514 15.0635 8.99294 14.8095Z" fill="#142966"/>
<path d="M14.9999 9.27893H1.00513V11.8367H14.9999V9.27893Z" fill="#142966"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.99294 12.2518L14.548 9.72223C14.8177 9.59946 14.9569 9.4398 14.9659 9.27893H1C1.00896 9.4398 1.14826 9.59946 1.4179 9.72223L6.97294 12.2518C7.53075 12.5058 8.43514 12.5058 8.99294 12.2518Z" fill="#142966"/>
<path d="M14.9999 6.72107H1.00513V9.27885H14.9999V6.72107Z" fill="#142966"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.99294 10.9729L14.548 8.44332C14.8177 8.32054 14.9569 8.16088 14.9659 8H1C1.00896 8.16088 1.14826 8.32054 1.4179 8.44332L6.97294 10.9729C7.53075 11.2269 8.43514 11.2269 8.99294 10.9729Z" fill="#36BFFF"/>
<path d="M14.9997 4.16309H1.00491V8.00309H14.9997V4.16309Z" fill="#36BFFF"/>
<path d="M14.5484 4.63991L8.99337 7.16947C8.43561 7.42348 7.53121 7.42348 6.9734 7.16947L1.41836 4.63991C0.860546 4.3859 0.860546 3.97408 1.41836 3.72007L6.9734 1.19051C7.53121 0.936498 8.43561 0.936498 8.99337 1.19051L14.5484 3.72007C15.1063 3.97408 15.1063 4.3859 14.5484 4.63991Z" fill="#36BFFF"/>
<svg width="16" height="16" viewBox="0 0 1073 1073" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0_1749_80944" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="94" y="40" width="885" height="993">
<path d="M978.723 40H94V1033H978.723V40Z" fill="white"/>
</mask>
<g mask="url(#mask0_1749_80944)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M638.951 291.265L936.342 462.949C966.129 480.145 980.256 502.958 978.723 525.482V774.266C980.256 796.789 966.129 819.602 936.342 836.798L638.951 1008.48C582.292 1041.19 490.431 1041.19 433.773 1008.48L136.381 836.798C106.595 819.602 92.4675 796.789 93.9999 774.266L93.9999 525.482C92.4675 502.957 106.595 480.145 136.381 462.949L433.773 291.265C490.431 258.556 582.292 258.556 638.951 291.265Z" fill="#142966"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M638.951 65.0055L936.342 236.69C966.129 253.886 980.256 276.699 978.723 299.222V548.006C980.256 570.529 966.129 593.343 936.342 610.538L638.951 782.223C582.292 814.931 490.431 814.931 433.773 782.223L136.381 610.538C106.595 593.343 92.4675 570.529 93.9999 548.006L93.9999 299.222C92.4675 276.699 106.595 253.886 136.381 236.69L433.773 65.0055C490.431 32.2968 582.292 32.2968 638.951 65.0055Z" fill="#36BFFF"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

12
packages/nc-gui/assets/nc-icons/record.svg

@ -0,0 +1,12 @@
<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1409_68546)">
<path d="M12.3571 5.96842L4.64282 10.4219" stroke="#1F293A" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="1.15184" width="9.06208" height="9.06208" rx="1.335" transform="matrix(0.866044 -0.499967 0.866044 0.499967 -0.345705 8.77119)" stroke="#1F293A" stroke-width="1.33"/>
<path d="M4 6.33984L11.7143 10.7933" stroke="#1F293A" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_1409_68546">
<rect width="16" height="16" fill="white" transform="translate(0.5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 712 B

16
packages/nc-gui/assets/nc-icons/table.svg

@ -1,12 +1,12 @@
<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1409_68546)">
<path d="M12.3571 5.96842L4.64282 10.4219" stroke="#1F293A" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="1.15184" width="9.06208" height="9.06208" rx="1.335" transform="matrix(0.866044 -0.499967 0.866044 0.499967 -0.345705 8.77119)" stroke="#1F293A" stroke-width="1.33"/>
<path d="M4 6.33984L11.7143 10.7933" stroke="#1F293A" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1613_80692)">
<path d="M11.8571 5.96903L4.14285 10.4225" stroke="#374151" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="1.15184" width="9.06208" height="9.06208" rx="1.335" transform="matrix(0.866044 -0.499967 0.866044 0.499967 -0.845705 8.77156)" stroke="#374151" stroke-width="1.33"/>
<path d="M3.5 6.34009L11.2143 10.7935" stroke="#374151" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_1409_68546">
<rect width="16" height="16" fill="white" transform="translate(0.5)"/>
<clipPath id="clip0_1613_80692">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 712 B

After

Width:  |  Height:  |  Size: 686 B

3
packages/nc-gui/components/cell/Text.vue

@ -34,6 +34,9 @@ const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value
v-model="vModel"
class="h-full w-full outline-none p-2 bg-transparent"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
:class="{
'px-1': isExpandedFormOpen,
}"
@blur="editEnabled = false"
@keydown.down.stop
@keydown.left.stop

5
packages/nc-gui/components/cell/TextArea.vue

@ -86,6 +86,7 @@ onClickOutside(inputWrapperRef, (e) => {
:class="{
'p-2': editEnabled,
'py-1 h-full': isForm,
'px-1': isExpandedFormOpen,
}"
:style="{
minHeight: `${height}px`,
@ -112,8 +113,8 @@ onClickOutside(inputWrapperRef, (e) => {
<span v-else>{{ vModel }}</span>
<div
v-if="active"
class="!absolute right-0 bottom-0 h-6 w-5 group cursor-pointer flex justify-end gap-1 items-center active:(ring ring-accent ring-opacity-100) rounded border-none p-1 hover:(bg-primary bg-opacity-10) dark:(!bg-slate-500)"
v-if="active && !isExpandedFormOpen"
class="!absolute right-0 bottom-0 h-6 w-5 group cursor-pointer flex justify-end gap-1 items-center rounded border-none p-1 hover:(bg-primary bg-opacity-10) dark:(!bg-slate-500)"
:class="{ 'right-2 bottom-2': editEnabled }"
data-testid="attachment-cell-file-picker-button"
@click.stop="isVisible = !isVisible"

4
packages/nc-gui/components/dashboard/TreeView/TableNode.vue

@ -204,8 +204,8 @@ const isTableOpened = computed(() => {
<template #title>
{{ $t('general.changeIcon') }}
</template>
<MdiTable
<component
:is="iconMap.table"
v-if="table.type === 'table'"
class="flex w-5 !text-gray-500 text-sm"
:class="{

2
packages/nc-gui/components/dashboard/settings/Metadata.vue

@ -165,7 +165,7 @@ const columns = [
<div v-if="column.key === 'table_name'">
<div class="flex items-center gap-1">
<div class="min-w-5 flex items-center justify-center">
<GeneralTableIcon :meta="record" class="text-gray-500"></GeneralTableIcon>
<GeneralTableIcon :meta="record" class="text-gray-500" />
</div>
<span class="overflow-ellipsis min-w-0 shrink-1">{{ record.title || record.table_name }}</span>
</div>

5
packages/nc-gui/components/dashboard/settings/UIAcl.vue

@ -171,10 +171,7 @@ const columns = [
<div v-if="column.name === 'table_name'">
<div class="flex items-center gap-1">
<div class="min-w-5 flex items-center justify-center">
<GeneralTableIcon
:meta="{ meta: record.table_meta, type: record.ptype }"
class="text-gray-500"
></GeneralTableIcon>
<GeneralTableIcon :meta="{ meta: record.table_meta, type: record.ptype }" class="text-gray-500" />
</div>
<GeneralTruncateText>
<span class="overflow-ellipsis min-w-0 shrink-1">{{ record._ptn }}</span>

2
packages/nc-gui/components/dlg/TableDelete.vue

@ -110,7 +110,7 @@ const onDelete = async () => {
<GeneralDeleteModal v-model:visible="visible" :entity-name="$t('objects.table')" :on-delete="onDelete">
<template #entity-preview>
<div v-if="table" class="flex flex-row items-center py-2.25 px-2.5 bg-gray-50 rounded-lg text-gray-700 mb-4">
<GeneralTableIcon :meta="table" class="nc-view-icon"></GeneralTableIcon>
<GeneralTableIcon :meta="table" class="nc-view-icon" />
<div
class="capitalize text-ellipsis overflow-hidden select-none w-full pl-1.75"
:style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }"

2
packages/nc-gui/components/general/ProjectIcon.vue

@ -7,7 +7,7 @@ const { hoverable } = defineProps<{
<template>
<GeneralIcon
icon="ncDatabase"
icon="project"
class="text-[#2824FB] nc-project-icon"
:class="{
'nc-project-icon-hoverable': hoverable,

1
packages/nc-gui/components/general/TableIcon.vue

@ -16,7 +16,6 @@ const { meta: tableMeta } = defineProps<{
:emoji="tableMeta.meta?.icon"
readonly
/>
<component :is="iconMap.eye" v-else-if="tableMeta?.type === 'view'" class="w-5 mx-0.75" />
<component :is="iconMap.table" v-else class="w-5 mx-0.5" />
</template>

27
packages/nc-gui/components/general/UserIcon.vue

@ -1,12 +1,27 @@
<script lang="ts" setup>
const props = defineProps<{
size?: 'small' | 'medium' | 'base' | 'large' | 'xlarge'
name?: string
}>()
const props = withDefaults(
defineProps<{
size?: 'small' | 'medium' | 'base' | 'large' | 'xlarge'
name?: string
email?: string
}>(),
{
email: '',
},
)
const { user } = useGlobal()
const backgroundColor = computed(() => (user.value?.id ? stringToColour(user.value?.id) : '#FFFFFF'))
const emailProp = toRef(props, 'email')
const backgroundColor = computed(() => {
// in comments we need to generate user icon from email
if (emailProp.value.length) {
return stringToColour(emailProp.value)
}
return user.value?.email ? stringToColour(user.value?.email) : '#FFFFFF'
})
const size = computed(() => props.size || 'medium')
@ -31,7 +46,7 @@ const usernameInitials = computed(() => {
<template>
<div
class="flex nc-user-avatar"
class="flex nc-user-avatar font-bold"
:class="{
'min-w-4 min-h-4': size === 'small',
'min-w-6 min-h-6': size === 'medium',

2
packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue

@ -80,7 +80,7 @@ const isLinks = computed(() => vModel.value.uidt === UITypes.Links)
<a-select-option v-for="table of refTables" :key="table.title" :value="table.id">
<div class="flex items-center gap-2">
<div class="min-w-5 flex items-center justify-center">
<GeneralTableIcon :meta="table" class="text-gray-500"></GeneralTableIcon>
<GeneralTableIcon :meta="table" class="text-gray-500" />
</div>
<span class="overflow-ellipsis min-w-0 shrink-1">{{ table.title }}</span>

21
packages/nc-gui/components/smartsheet/expanded-form/Comments.vue

@ -8,7 +8,9 @@ const { loadCommentsAndLogs, commentsAndLogs, saveComment, comment, updateCommen
const commentsWrapperEl = ref<HTMLDivElement>()
await loadCommentsAndLogs()
onMounted(async () => {
await loadCommentsAndLogs()
})
const { user } = useGlobal()
@ -91,7 +93,7 @@ const value = computed({
})
watch(
commentsAndLogs,
[commentsAndLogs, tab],
() => {
setTimeout(() => {
if (commentsWrapperEl.value) commentsWrapperEl.value.scrollTop = commentsWrapperEl.value?.scrollHeight
@ -148,23 +150,24 @@ const processedAudit = (log: string) => {
'pb-2': tab !== 'comments',
}"
>
<div v-if="tab === 'comments'" ref="commentsWrapperEl" class="flex flex-col h-full">
<div v-if="tab === 'comments'" class="flex flex-col h-full">
<div v-if="comments.length === 0" class="flex flex-col my-1 text-center justify-center h-full">
<div class="text-center text-3xl text-gray-700">
<GeneralIcon icon="commentHere" />
</div>
<div class="font-medium text-center my-6 text-gray-500">{{ $t('activity.startCommenting') }}</div>
</div>
<div v-else class="flex flex-col h-full py-2 pl-2 pr-1 space-y-2 nc-scrollbar-md">
<div v-else ref="commentsWrapperEl" class="flex flex-col h-full py-2 pl-2 pr-1 space-y-2 nc-scrollbar-md">
<div v-for="log of comments" :key="log.id">
<div class="bg-white rounded-xl group border-1 gap-2 border-gray-200">
<div class="flex flex-col p-4 gap-3">
<div class="flex justify-between">
<div class="flex items-center gap-2">
<GeneralUserIcon size="base" :name="log.display_name ?? log.user" />
<GeneralUserIcon size="base" :name="log.display_name ?? log.user" :email="log.user" />
<div class="flex flex-col">
<span class="truncate font-bold max-w-42">
{{ log.display_name ?? log.user.split('@')[0].slice(0, 2) ?? 'Shared base' }}
{{ log.display_name ?? log.user.split('@')[0] ?? 'Shared base' }}
</span>
<div v-if="log.id !== editLog?.id" class="text-xs text-gray-500">
{{ log.created_at !== log.updated_at ? `Edited ${timeAgo(log.updated_at)}` : timeAgo(log.created_at) }}
@ -237,11 +240,11 @@ const processedAudit = (log: string) => {
<div class="bg-white rounded-xl border-1 gap-3 border-gray-200">
<div class="flex flex-col p-4 gap-3">
<div class="flex justify-between">
<div class="flex font-bold items-center gap-2">
<GeneralUserIcon size="base" :name="log.display_name ?? log.user" />
<div class="flex items-center gap-2">
<GeneralUserIcon size="base" :name="log.display_name ?? log.user" :email="log.user" />
<div class="flex flex-col">
<span class="truncate max-w-50">
<span class="truncate max-w-50 font-bold">
{{ log.display_name ?? log.user.split('@')[0].slice(0, 2) ?? 'Shared base' }}
</span>
<div v-if="log.id !== editLog?.id" class="text-xs text-gray-500">

115
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -3,7 +3,6 @@ import type { TableType, ViewType } from 'nocodb-sdk'
import { isLinksOrLTAR, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
import type { Ref } from 'vue'
import MdiChevronDown from '~icons/mdi/chevron-down'
import TableIcon from '~icons/nc-icons/table'
import {
CellClickHookInj,
@ -15,6 +14,7 @@ import {
ReloadRowDataHookInj,
computedInject,
createEventHook,
iconMap,
inject,
message,
provide,
@ -66,6 +66,9 @@ const router = useRouter()
const isPublic = inject(IsPublicInj, ref(false))
// to check if a expanded form which is not yet saved exist or not
const isUnsavedFormExist = ref(false)
const { isUIAllowed } = useRoles()
const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook())
@ -151,6 +154,7 @@ const onClose = () => {
const onDuplicateRow = () => {
duplicatingRowInProgress.value = true
isUnsavedFormExist.value = true
const oldRow = { ...row.value.row }
delete oldRow.ncRecordId
const newRow = Object.assign(
@ -168,25 +172,38 @@ const onDuplicateRow = () => {
}, 500)
}
const save = async () => {
if (isNew.value) {
const data = await _save(rowState.value)
await syncLTARRefs(data)
reloadTrigger?.trigger()
} else {
await _save()
reloadTrigger?.trigger()
}
isUnsavedFormExist.value = false
}
const isPreventChangeModalOpen = ref(false)
const discardPreventModal = () => {
emits('next')
isPreventChangeModalOpen.value = false
}
const onNext = async () => {
if (changedColumns.value.size > 0) {
await Modal.confirm({
title: 'Do you want to save the changes?',
okText: 'Save',
cancelText: 'Discard',
onOk: async () => {
await save()
emits('next')
},
onCancel: () => {
emits('next')
},
})
isPreventChangeModalOpen.value = true
} else {
emits('next')
}
}
const saveChanges = async () => {
isUnsavedFormExist.value = false
await save()
emits('next')
}
const reloadParentRowHook = inject(ReloadRowDataHookInj, createEventHook())
// override reload trigger and use it to reload grid and the form itself
@ -208,6 +225,10 @@ if (isKanban.value) {
}
}
watch(isUnsavedFormExist, () => {
console.log(isUnsavedFormExist.value, 'HEHEH')
})
provide(IsExpandedFormOpenInj, isExpanded)
const cellWrapperEl = ref()
@ -230,18 +251,6 @@ const addNewRow = () => {
isExpanded.value = true
}, 500)
}
const save = async () => {
if (isNew.value) {
const data = await _save(rowState.value)
await syncLTARRefs(data)
reloadTrigger?.trigger()
} else {
await _save()
reloadTrigger?.trigger()
}
}
// attach keyboard listeners to switch between rows
// using alt + left/right arrow keys
useActiveKeyupListener(
@ -325,14 +334,9 @@ const onConfirmDeleteRowClick = async () => {
showDeleteRowModal.value = false
await deleteRowById(primaryKey.value)
message.success('Row deleted')
// if (!props.lastRow) {
// await onNext()
// } else if (!props.firstRow) {
// emits('prev')
// } else {
// }
reloadTrigger.trigger()
onClose()
showDeleteRowModal.value = false
}
watch(
@ -378,7 +382,7 @@ export default {
<div class="h-[85vh] xs:(max-h-full) max-h-215 flex flex-col p-6">
<div class="flex h-8 flex-shrink-0 w-full items-center nc-expanded-form-header relative mb-4 justify-between">
<template v-if="!isMobileMode">
<div class="flex gap-3">
<div class="flex gap-3 w-100">
<div class="flex gap-2">
<NcButton
v-if="props.showNextPrevIcons"
@ -399,13 +403,9 @@ export default {
<MdiChevronDown class="text-md" />
</NcButton>
</div>
<div v-if="displayValue" class="flex items-center truncate max-w-32 font-bold text-gray-800 text-xl">
<div v-if="displayValue" class="flex items-center truncate font-bold text-gray-800 text-xl">
{{ displayValue }}
</div>
<div class="bg-gray-100 px-2 gap-1 flex my-1 items-center rounded-lg text-gray-800 font-medium">
<TableIcon class="w-6 h-6 text-sm" />
All {{ meta.title }}
</div>
</div>
<div class="flex gap-2">
<NcDropdown v-if="!isNew">
@ -438,7 +438,7 @@ export default {
<NcMenuItem
v-if="isUIAllowed('dataEdit') && !isNew"
v-e="['c:row-expand:delete']"
class="!text-red-500"
class="!text-red-500 !hover:bg-red-50"
@click="!isNew && onDeleteRowClick()"
>
<component :is="iconMap.delete" data-testid="nc-expanded-form-delete" class="cursor-pointer nc-delete-row" />
@ -595,7 +595,7 @@ export default {
<NcMenuItem
v-if="isUIAllowed('dataEdit') && !isNew"
v-e="['c:row-expand:delete']"
class="!text-red-500"
class="!text-red-500 !hover:bg-red-50"
@click="!isNew && onDeleteRowClick()"
>
<div data-testid="nc-expanded-form-delete">
@ -624,6 +624,7 @@ export default {
type="primary"
size="medium"
class="nc-expand-form-save-btn !xs:(text-base)"
:disabled="changedColumns.size === 0 && !isUnsavedFormExist"
@click="save"
>
<div class="xs:px-1">Save</div>
@ -642,16 +643,32 @@ export default {
</div>
</NcModal>
<NcModal v-model:visible="showDeleteRowModal" class="!w-[25rem] !xs-">
<div class="">
<div class="prose-xl font-bold self-center">Delete row ?</div>
<div class="mt-4">Are you sure you want to delete this row?</div>
</div>
<div class="flex flex-row gap-x-2 mt-4 pt-1.5 justify-end pt-4 gap-x-3">
<NcButton v-if="isMobileMode" type="secondary" @click="showDeleteRowModal = false">{{ $t('general.cancel') }} </NcButton>
<NcButton v-e="['a:row-expand:delete']" @click="onConfirmDeleteRowClick">{{ $t('general.confirm') }} </NcButton>
<GeneralDeleteModal v-model:visible="showDeleteRowModal" entity-name="Record" :on-delete="() => onConfirmDeleteRowClick()">
<template #entity-preview>
<span>
<div class="flex flex-row items-center py-2.25 px-2.5 bg-gray-50 rounded-lg text-gray-700 mb-4">
<component :is="iconMap.table" class="nc-view-icon" />
<div class="capitalize text-ellipsis overflow-hidden select-none w-full pl-1.75 break-keep whitespace-nowrap">
{{ meta.title }}
</div>
</div>
</span>
</template>
</GeneralDeleteModal>
<!-- Prevent unsaved change modal -->
<NcModal v-model:visible="isPreventChangeModalOpen" size="small">
<template #header>
<div class="flex flex-row items-center gap-x-2">Do you want to save the changes ?</div>
</template>
<div class="mt-2">
<div class="flex flex-row justify-end gap-x-2 mt-6">
<NcButton type="secondary" @click="discardPreventModal">{{ $t('general.quit') }}</NcButton>
<NcButton key="submit" type="primary" label="Rename Table" loading-label="Renaming Table" @click="saveChanges">
{{ $t('activity.saveAndQuit') }}
</NcButton>
</div>
</div>
</NcModal>
</template>

15
packages/nc-gui/components/virtual-cell/Links.vue

@ -64,6 +64,20 @@ const textVal = computed(() => {
}
})
const toatlRecordsLinked = computed(() => {
if (isForm?.value) {
return state.value?.[colTitle.value]?.length
}
const parsedValue = +value?.value || 0
if (!parsedValue) {
return 0
} else if (parsedValue === 1) {
return 1
} else {
return parsedValue
}
})
const onAttachRecord = () => {
childListDlg.value = false
listItemsDlg.value = true
@ -121,6 +135,7 @@ const localCellValue = computed<any[]>(() => {
<LazyVirtualCellComponentsListChildItems
v-model="childListDlg"
:items="toatlRecordsLinked"
:column="relatedTableDisplayColumn"
:cell-value="localCellValue"
@attach-record="onAttachRecord"

4
packages/nc-gui/components/virtual-cell/components/Header.vue

@ -59,7 +59,9 @@ const relationMeta = computed(() => {
<div class="flex justify-end">
<div class="flex flex-shrink-0 rounded-md gap-1 text-brand-500 items-center bg-gray-100 px-2 py-1">
<FileIcon class="w-4 h-4" />
{{ displayValue }}
<GeneralTruncateText placement="top" length="25">
{{ displayValue }}
</GeneralTruncateText>
</div>
</div>
<NcTooltip class="flex-shrink-0">

168
packages/nc-gui/components/virtual-cell/components/ListChildItems.vue

@ -18,7 +18,14 @@ import {
useVModel,
} from '#imports'
const props = defineProps<{ modelValue?: boolean; cellValue: any; column: any }>()
interface Prop {
modelValue?: boolean
cellValue: any
column: any
items: number
}
const props = defineProps<Prop>()
const emit = defineEmits(['update:modelValue', 'attachRecord'])
@ -49,6 +56,8 @@ const {
displayValueProp,
} = useLTARStoreOrThrow()
isChildrenLoading.value = true
const { isNew, state, removeLTARRef, addLTARRef } = useSmartsheetRowStoreOrThrow()
watch(
@ -121,6 +130,46 @@ watch(expandedFormDlg, () => {
onKeyStroke('Escape', () => {
vModel.value = false
})
/*
to render same number of skelton as the number of cards
displayed
*/
const skeltonCount = computed(() => {
if (props.items < 10 && childrenListPagination.page === 1) {
return props.items
}
if (childrenListCount.value < 10 && childrenListPagination.page === 1) {
return childrenListCount.value || 10
}
const totalRows = Math.ceil(childrenListCount.value / 10)
if (totalRows === childrenListPagination.page) {
return childrenListCount.value % 10
}
return 10
})
const totalItemsToShow = computed(() => {
if (isChildrenLoading) {
return props.items
}
return childrenListCount.value
})
const isDataExist = computed<boolean>(() => {
return childrenList.value?.pageInfo?.totalRows || (isNew.value && state.value?.[colTitle.value]?.length)
})
const linkOrUnLink = (rowRef: Record<string, string>, id: string) => {
if (isPublic.value && !isForm.value) return
if (isNew.value || isChildrenListLinked.value[parseInt(id)]) {
unlinkRow(rowRef, parseInt(id))
} else {
linkRow(rowRef, parseInt(id))
}
}
</script>
<template>
@ -142,8 +191,6 @@ onKeyStroke('Escape', () => {
:related-table-title="relatedTableMeta?.title"
:display-value="row.row[displayValueProp]"
/>
<div v-if="!isForm" class="m-4 bg-gray-50 border-gray-50 border-b-2"></div>
<div v-if="!isForm" class="flex mt-2 mb-2 items-center gap-2">
<div
class="flex items-center border-1 p-1 rounded-md w-full border-gray-200"
@ -166,72 +213,61 @@ onKeyStroke('Escape', () => {
</div>
</div>
<template v-if="(isNew && state?.[colTitle]?.length) || childrenList?.pageInfo?.totalRows">
<div class="mt-2 mb-2">
<div
:class="{
'h-[420px]': !isForm,
'h-[250px]': isForm,
}"
class="overflow-scroll nc-scrollbar-md cursor-pointer pr-1"
>
<template v-if="isChildrenLoading">
<div
v-for="(x, i) in Array.from({ length: 10 })"
:key="i"
class="!border-2 flex flex-row gap-2 mb-2 transition-all !rounded-xl relative !border-gray-200 hover:bg-gray-50"
>
<a-skeleton-image class="h-24 w-24 !rounded-xl" />
<div class="flex flex-col m-[.5rem] gap-2 flex-grow justify-center">
<a-skeleton-input class="!w-48 !rounded-xl" active size="small" />
<div class="flex flex-row gap-6 w-10/12">
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
<div v-if="isDataExist || isChildrenLoading" class="mt-2 mb-2">
<div
:class="{
'h-105': !isForm,
'h-62.5': isForm,
}"
class="overflow-scroll nc-scrollbar-md cursor-pointer pr-1"
>
<template v-if="isChildrenLoading">
<div
v-for="(_, i) in Array.from({ length: skeltonCount })"
:key="i"
class="border-2 flex flex-row gap-2 mb-2 transition-all rounded-xl relative border-gray-200 hover:bg-gray-50"
>
<a-skeleton-image class="h-24 w-24 !rounded-xl" />
<div class="flex flex-col m-2 gap-2 flex-grow justify-center">
<a-skeleton-input class="!w-48 !rounded-xl" active size="small" />
<div class="flex flex-row gap-6 w-10/12">
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
<div class="flex flex-col gap-0.5">
<a-skeleton-input class="!h-4 !w-12" active size="small" />
<a-skeleton-input class="!h-4 !w-24" active size="small" />
</div>
</div>
</div>
</template>
<template v-else>
<LazyVirtualCellComponentsListItem
v-for="(refRow, id) in childrenList?.list ?? state?.[colTitle] ?? []"
:key="id"
:row="refRow"
:fields="fields"
data-testid="nc-child-list-item"
:attachment="attachmentCol"
:related-table-display-value-prop="relatedTableDisplayValueProp"
:is-linked="childrenList?.list ? isChildrenListLinked[Number.parseInt(id)] : true"
:is-loading="isChildrenListLoading[Number.parseInt(id)]"
@expand="onClick(refRow)"
@click="
() => {
if (isPublic && !isForm) return
isNew
? unlinkRow(refRow, Number.parseInt(id))
: isChildrenListLinked[Number.parseInt(id)]
? unlinkRow(refRow, Number.parseInt(id))
: linkRow(refRow, Number.parseInt(id))
}
"
/>
</template>
</div>
</div>
</template>
<template v-else>
<LazyVirtualCellComponentsListItem
v-for="(refRow, id) in childrenList?.list ?? state?.[colTitle] ?? []"
:key="id"
:row="refRow"
:fields="fields"
data-testid="nc-child-list-item"
:attachment="attachmentCol"
:related-table-display-value-prop="relatedTableDisplayValueProp"
:is-linked="childrenList?.list ? isChildrenListLinked[Number.parseInt(id)] : true"
:is-loading="isChildrenListLoading[Number.parseInt(id)]"
@expand="onClick(refRow)"
@click="linkOrUnLink(refRow, id)"
/>
</template>
</div>
</template>
</div>
<div
v-else
:class="{
@ -259,7 +295,7 @@ onKeyStroke('Escape', () => {
<div class="flex flex-row justify-between bg-white relative pt-1">
<div v-if="!isForm" class="flex items-center justify-center px-2 rounded-md text-gray-500 bg-brand-50">
{{ childrenListCount || 0 }} {{ $t('objects.records') }} {{ childrenListCount !== 0 ? $t('general.are') : '' }}
{{ totalItemsToShow || 0 }} {{ $t('objects.records') }} {{ totalItemsToShow !== 0 ? $t('general.are') : '' }}
{{ $t('general.linked') }}
</div>
<div v-else class="flex items-center justify-center px-2 rounded-md text-gray-500 bg-brand-50">

9
packages/nc-gui/components/virtual-cell/components/ListItems.vue

@ -49,6 +49,8 @@ const { addLTARRef, isNew, removeLTARRef, state: rowState } = useSmartsheetRowSt
const isPublic = inject(IsPublicInj, ref(false))
isChildrenExcludedLoading.value = true
const isForm = inject(IsFormInj, ref(false))
const saveRow = inject(SaveRowInj, () => {})
@ -213,7 +215,7 @@ onKeyStroke('Escape', () => {
</NcButton>
</div>
<template v-if="childrenExcludedList?.pageInfo?.totalRows">
<template v-if="childrenExcludedList?.pageInfo?.totalRows || isChildrenExcludedLoading">
<div class="pb-2 pt-1">
<div class="h-[420px] overflow-scroll nc-scrollbar-md pr-1 cursor-pointer">
<template v-if="isChildrenExcludedLoading">
@ -274,7 +276,10 @@ onKeyStroke('Escape', () => {
</div>
</div>
</template>
<div v-else class="py-2 h-[420px] flex flex-col gap-3 items-center justify-center text-gray-500">
<div
v-if="!isChildrenExcludedLoading && !childrenExcludedList?.pageInfo?.totalRows"
class="py-2 h-105 flex flex-col gap-3 items-center justify-center text-gray-500"
>
<InboxIcon class="w-16 h-16 mx-auto" />
<p>
{{ $t('msg.thereAreNoRecordsInTable') }}

3
packages/nc-gui/lang/en.json

@ -39,6 +39,7 @@
}
},
"general": {
"quit": "Quit",
"home": "Home",
"load": "Load",
"open": "Open",
@ -400,6 +401,7 @@
"addHeader": "Add Header",
"enterDefaultUrlOptional": "Enter default URL (Optional)",
"negative": "Negative",
"discard": "Discard",
"default": "Default",
"defaultNumberPercent": "Default Number (%)",
"durationFormat": "Duration Format",
@ -624,6 +626,7 @@
"deleteProject": "Delete Project",
"refreshProject": "Refresh projects",
"saveProject": "Save Project",
"saveAndQuit": "Save & Quit",
"deleteKanbanStack": "Delete stack?",
"createProjectExtended": {
"extDB": "Create By Connecting <br>To An External Database",

9
packages/nc-gui/utils/iconUtils.ts

@ -13,7 +13,6 @@ import MdiThumbUp from '~icons/mdi/thumb-up'
import MdiThumbUpOutline from '~icons/mdi/thumb-up-outline'
import MdiFlag from '~icons/mdi/flag'
import MdiFlagOutline from '~icons/mdi/flag-outline'
import MdiTable from '~icons/mdi/table'
import MsMove from '~icons/material-symbols/drive-file-move-outline'
import MSCloseRounded from '~icons/material-symbols/close-rounded'
import MdiTableLarge from '~icons/mdi/table-large'
@ -81,7 +80,9 @@ import LcSend from '~icons/lucide/send'
import NcCommentHere from '~icons/nc-icons/comment-here'
import NcAddDataSource from '~icons/nc-icons/add-data-source'
import NcDatabaseIcon from '~icons/nc-icons/database'
import Project from '~icons/nc-icons/project'
import TableIcon from '~icons/nc-icons/table'
import RecordIcon from '~icons/nc-icons/record'
// Roles
import MaterialSymbolsManageAccountsOutline from '~icons/material-symbols/manage-accounts-outline'
// account
@ -237,6 +238,7 @@ import MaterialSymbolsBlock from '~icons/material-symbols/block'
} as const */
export const iconMap = {
record: RecordIcon,
workspaceDefault: MsGroup,
search: NcSearch,
error: h('span', { class: 'material-symbols' }, 'error'),
@ -245,6 +247,7 @@ export const iconMap = {
addOutlineBox: MsAddBoxOutline,
loading: h('span', { class: 'material-symbols' }, 'autorenew'),
arrowCollapse: Up,
project: Project,
markerAlert: h('span', { class: 'material-symbols' }, 'warning'),
appStore: h('span', { class: 'material-symbols' }, 'apps'),
chevronLeft: h('span', { class: 'material-symbols' }, 'chevron_left'),
@ -322,7 +325,7 @@ export const iconMap = {
// threeDotHorizontal: h('span', { class: 'material-symbols' }, 'more_horiz'),
threeDotVertical: MdiDotsVertical,
threeDotHorizontal: MdiDotsHorizontal,
table: MdiTable,
table: TableIcon,
excel: PhExcelThin, // h('span', { class: 'material-symbols' }, 'grid_on'),
csv: PhCsvThin, // h('span', { class: 'material-symbols' }, 'grid_on'),
code: Code,

22
tests/playwright/pages/Dashboard/ExpandedForm/index.ts

@ -47,7 +47,7 @@ export class ExpandedFormPage extends BasePage {
async clickDeleteRow() {
await this.click3DotsMenu('Delete Record');
await this.rootPage.locator('.ant-btn-primary:has-text("Confirm")').click();
await this.rootPage.locator('.ant-btn-danger:has-text("Delete Record")').click();
}
async isDisabledDuplicateRow() {
@ -125,18 +125,22 @@ export class ExpandedFormPage extends BasePage {
});
}
await this.get().press('Escape');
await this.get().waitFor({ state: 'hidden' });
await this.verifyToast({ message: `updated successfully.` });
await this.rootPage.locator('[data-testid="grid-load-spinner"]').waitFor({ state: 'hidden' });
// removing focus from toast
await this.rootPage.locator('.nc-modal').click();
await this.get().press('Escape');
await this.get().waitFor({ state: 'hidden' });
}
async verify({ header, url }: { header: string; url?: string }) {
await expect(this.get().locator(`.nc-expanded-form-header`).last()).toContainText(header);
if (url) {
await expect.poll(() => this.rootPage.url()).toContain(url);
}
}
// check for the expanded form header table name
// async verify({ header, url }: { header: string; url?: string }) {
// await expect(this.get().locator(`.nc-expanded-form-header`).last()).toContainText(header);
// if (url) {
// await expect.poll(() => this.rootPage.url()).toContain(url);
// }
// }
async escape() {
await this.rootPage.keyboard.press('Escape');

29
tests/playwright/tests/db/features/expandedFormUrl.spec.ts

@ -47,11 +47,6 @@ test.describe('Expanded form URL', () => {
const url = await dashboard.rootPage.url();
await dashboard.expandedForm.escape();
await dashboard.rootPage.goto(url);
await dashboard.expandedForm.verify({
header: 'Row 0 All Test Table',
url,
});
}
async function viewTestSakila(viewType: string) {
@ -79,10 +74,6 @@ test.describe('Expanded form URL', () => {
// expand row & verify URL
await viewObj.openExpandedRow({ index: 0 });
await dashboard.expandedForm.verify({
header: 'Afghanistan',
url: 'rowId=1',
});
// // verify copied URL in clipboard
// await dashboard.expandedForm.copyUrlButton.click();
@ -92,10 +83,7 @@ test.describe('Expanded form URL', () => {
// access a new rowID using URL
await dashboard.expandedForm.escape();
await dashboard.expandedForm.gotoUsingUrlAndRowId({ rowId: '2' });
await dashboard.expandedForm.verify({
header: 'Algeria',
url: 'rowId=2',
});
await dashboard.expandedForm.escape();
// visit invalid rowID
@ -107,28 +95,19 @@ test.describe('Expanded form URL', () => {
// Nested URL
await dashboard.expandedForm.gotoUsingUrlAndRowId({ rowId: '1' });
await dashboard.expandedForm.verify({
header: 'Afghanistan',
url: 'rowId=1',
});
await dashboard.expandedForm.openChildCard({
column: 'Cities',
title: 'Kabul',
});
await dashboard.rootPage.waitForTimeout(1000);
await dashboard.expandedForm.verify({
header: 'Kabul',
url: 'rowId=1',
});
await dashboard.expandedForm.verifyCount({ count: 2 });
// close child card
await dashboard.expandedForm.close();
await dashboard.childList.close();
await dashboard.expandedForm.verify({
header: 'Afghanistan',
url: 'rowId=1',
});
await dashboard.expandedForm.close();
}

4
tests/playwright/tests/db/features/keyboardShortcuts.spec.ts

@ -130,9 +130,7 @@ test.describe('Verify shortcuts', () => {
// Space to open expanded row and Meta + Space to save
await grid.cell.click({ index: 1, columnHeader: 'Country' });
await page.keyboard.press('Space');
await dashboard.expandedForm.verify({
header: 'Algeria',
});
await dashboard.expandedForm.fillField({ columnTitle: 'Country', value: 'NewAlgeria' });
await dashboard.expandedForm.save();
await dashboard.expandedForm.escape();

Loading…
Cancel
Save