From a3fe1833130d1672e54858db0633b70d6e7c4cd0 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 20 Sep 2023 10:20:11 +0530 Subject: [PATCH 01/14] fix: reset pagination on search --- .../nc-gui/components/virtual-cell/components/ListChildItems.vue | 1 + packages/nc-gui/components/virtual-cell/components/ListItems.vue | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue b/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue index 766df7082d..fba37cf179 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue @@ -152,6 +152,7 @@ watch(expandedFormDlg, () => { @focus="isFocused = true" @blur="isFocused = false" @keydown.capture.stop + @change="childrenListPagination.page = 1" > diff --git a/packages/nc-gui/components/virtual-cell/components/ListItems.vue b/packages/nc-gui/components/virtual-cell/components/ListItems.vue index d4a828e3ca..501753dc85 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListItems.vue @@ -176,6 +176,7 @@ watch(expandedFormDlg, () => { @focus="isFocused = true" @blur="isFocused = false" @keydown.capture.stop + @change="childrenExcludedListPagination.page = 1" > From ead92b2a494513aa94b51896ae316611fd5b0c60 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 20 Sep 2023 12:31:09 +0530 Subject: [PATCH 02/14] fix: update style --- packages/nc-gui/assets/nc-icons/link.svg | 4 ++ packages/nc-gui/assets/style.scss | 6 +- packages/nc-gui/components.d.ts | 1 + .../virtual-cell/components/Header.vue | 6 +- .../components/ListChildItems.vue | 64 +++++++++++-------- .../virtual-cell/components/ListItem.vue | 41 ++++++------ .../virtual-cell/components/ListItems.vue | 63 ++++++++++-------- packages/nc-gui/composables/useLTARStore.ts | 28 ++++++-- 8 files changed, 130 insertions(+), 83 deletions(-) create mode 100644 packages/nc-gui/assets/nc-icons/link.svg diff --git a/packages/nc-gui/assets/nc-icons/link.svg b/packages/nc-gui/assets/nc-icons/link.svg new file mode 100644 index 0000000000..1207f4b97f --- /dev/null +++ b/packages/nc-gui/assets/nc-icons/link.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/nc-gui/assets/style.scss b/packages/nc-gui/assets/style.scss index 1986dd926c..5dee33bf42 100644 --- a/packages/nc-gui/assets/style.scss +++ b/packages/nc-gui/assets/style.scss @@ -33,7 +33,7 @@ } .anticon-check-circle { - @apply !relative top-[-1px] left-0; + @apply !relative top-[-1px] left-0; } html, @@ -580,10 +580,6 @@ input[type='number'] { @apply !block; } -.ant-card-body { - @apply !p-2; -} - .ant-pagination .ant-pagination-item-link-icon { @apply !block !py-1.5; } diff --git a/packages/nc-gui/components.d.ts b/packages/nc-gui/components.d.ts index 208fef4e85..6c96a14054 100644 --- a/packages/nc-gui/components.d.ts +++ b/packages/nc-gui/components.d.ts @@ -158,6 +158,7 @@ declare module '@vue/runtime-core' { MdiWhatsapp: typeof import('~icons/mdi/whatsapp')['default'] MiCircleWarning: typeof import('~icons/mi/circle-warning')['default'] NcIconsInbox: typeof import('~icons/nc-icons/inbox')['default'] + PhLink: typeof import('~icons/ph/link')['default'] PhMagnifyingGlassBold: typeof import('~icons/ph/magnifying-glass-bold')['default'] PhTriangleFill: typeof import('~icons/ph/triangle-fill')['default'] RiExternalLinkLine: typeof import('~icons/ri/external-link-line')['default'] diff --git a/packages/nc-gui/components/virtual-cell/components/Header.vue b/packages/nc-gui/components/virtual-cell/components/Header.vue index da78143a2c..a3f79d4bd6 100644 --- a/packages/nc-gui/components/virtual-cell/components/Header.vue +++ b/packages/nc-gui/components/virtual-cell/components/Header.vue @@ -49,9 +49,9 @@ const relationMeta = computed(() => { - + diff --git a/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue b/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue index fba37cf179..764b22c5f7 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue @@ -12,6 +12,7 @@ import { computed, inject, isPrimary, + onKeyStroke, ref, useLTARStoreOrThrow, useSmartsheetRowStoreOrThrow, @@ -41,6 +42,7 @@ const { unlink, isChildrenListLoading, isChildrenListLinked, + isChildrenLoading, relatedTableMeta, row, link, @@ -112,7 +114,13 @@ watch( ) watch(expandedFormDlg, () => { - loadChildrenList() + if (!expandedFormDlg.value) { + loadChildrenList() + } +}) + +onKeyStroke('Escape', () => { + vModel.value = false }) @@ -131,6 +139,7 @@ watch(expandedFormDlg, () => { :relation="relation" :linked-records="childrenListCount" :table-title="meta?.title" + :show-header="true" :related-table-title="relatedTableMeta?.title" :display-value="row.row[displayValueProp]" /> @@ -167,28 +176,33 @@ watch(expandedFormDlg, () => { }" class="overflow-scroll nc-scrollbar-md cursor-pointer pr-1" > - + + @@ -220,10 +234,10 @@ watch(expandedFormDlg, () => {
-
+
{{ childrenListCount || 0 }} records {{ childrenListCount !== 0 ? 'are' : '' }} linked
-
+
{{ state?.[colTitle]?.length || 0 }} records {{ state?.[colTitle]?.length !== 0 ? 'are' : '' }} linked
diff --git a/packages/nc-gui/components/virtual-cell/components/ListItem.vue b/packages/nc-gui/components/virtual-cell/components/ListItem.vue index 5472dea5e1..2be57791d4 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListItem.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListItem.vue @@ -2,6 +2,7 @@ import { isVirtualCol } from 'nocodb-sdk' import { IsFormInj, isImage, useAttachment } from '#imports' import MaximizeIcon from '~icons/nc-icons/maximize' +import LinkIcon from '~icons/nc-icons/link' const { row, fields, relatedTableDisplayValueProp, isLoading, isLinked, attachment } = defineProps<{ row: any @@ -46,42 +47,40 @@ const attachments: Attachment[] = computed(() => { -
- +
+ -
+
-
+
- {{ row[relatedTableDisplayValueProp] }} - + {{ row[relatedTableDisplayValueProp] }} +
+ + Linked +
0 && !isPublic && !isForm" class="flex flex-row gap-4 w-10/12"> +
{ v-if="!isForm && !isPublic" type="text" size="lg" - class="!px-2 nc-expand-item !group-hover:block !hidden !absolute right-1 bottom-1" + class="!px-2 nc-expand-item !group-hover:block !hidden !border-1 !shadow-sm !border-gray-200 !bg-white !absolute right-3 bottom-3" @click.stop="$emit('expand', row)" > diff --git a/packages/nc-gui/components/virtual-cell/components/ListItems.vue b/packages/nc-gui/components/virtual-cell/components/ListItems.vue index 501753dc85..4807e5c8e4 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListItems.vue @@ -9,6 +9,7 @@ import { SaveRowInj, computed, inject, + onKeyStroke, ref, useLTARStoreOrThrow, useSmartsheetRowStoreOrThrow, @@ -30,6 +31,7 @@ const { isChildrenExcludedListLinked, isChildrenExcludedListLoading, displayValueProp, + isChildrenExcludedLoading, childrenListCount, loadChildrenExcludedList, loadChildrenList, @@ -138,7 +140,13 @@ const relation = computed(() => { }) watch(expandedFormDlg, () => { - loadChildrenExcludedList(rowState.value) + if (!expandedFormDlg.value) { + loadChildrenExcludedList(rowState.value) + } +}) + +onKeyStroke('Escape', () => { + vModel.value = false }) @@ -203,29 +211,34 @@ watch(expandedFormDlg, () => { @@ -242,7 +255,7 @@ watch(expandedFormDlg, () => {
-
+
{{ relation === 'bt' ? (row.row[relatedTableMeta?.title] ? '1' : 0) : childrenListCount ?? 'No' }} records {{ childrenListCount !== 0 ? 'are' : '' }} linked
diff --git a/packages/nc-gui/composables/useLTARStore.ts b/packages/nc-gui/composables/useLTARStore.ts index 360e1f3016..05101d740c 100644 --- a/packages/nc-gui/composables/useLTARStore.ts +++ b/packages/nc-gui/composables/useLTARStore.ts @@ -64,12 +64,16 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( size: 10, }) + const isChildrenLoading = ref(false) + const isChildrenListLoading = ref>([]) const isChildrenListLinked = ref>([]) const isChildrenExcludedListLoading = ref>([]) + const isChildrenExcludedLoading = ref(false) + const isChildrenExcludedListLinked = ref>([]) const newRowState = reactive({ @@ -127,6 +131,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( const loadChildrenExcludedList = async (activeState?: any) => { if (activeState) newRowState.state = activeState try { + isChildrenExcludedLoading.value = true if (isPublic.value) { const router = useRouter() @@ -212,11 +217,16 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( } } catch (e: any) { message.error(`${t('msg.error.failedToLoadList')}: ${await extractSdkResponseErrorMsg(e)}`) + } finally { + setTimeout(() => { + isChildrenExcludedLoading.value = false + }, 600) } } const loadChildrenList = async () => { try { + isChildrenLoading.value = true if (colOptions.value.type === 'bt') return if (!rowId.value || !column.value) return if (isPublic.value) { @@ -262,6 +272,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( } } catch (e: any) { message.error(`${t('msg.error.failedToLoadChildrenList')}: ${await extractSdkResponseErrorMsg(e)}`) + } finally { + setTimeout(() => { + isChildrenLoading.value = false + }, 600) } } @@ -357,8 +371,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( } catch (e: any) { message.error(`${t('msg.error.unlinkFailed')}: ${await extractSdkResponseErrorMsg(e)}`) } finally { - isChildrenExcludedListLoading.value[index] = false - isChildrenListLoading.value[index] = false + setTimeout(() => { + isChildrenExcludedListLoading.value[index] = false + isChildrenListLoading.value[index] = false + }, 600) } reloadData?.(false) @@ -422,8 +438,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( } catch (e: any) { message.error(`Linking failed: ${await extractSdkResponseErrorMsg(e)}`) } finally { - isChildrenExcludedListLoading.value[index] = false - isChildrenListLoading.value[index] = false + setTimeout(() => { + isChildrenExcludedListLoading.value[index] = false + isChildrenListLoading.value[index] = false + }, 600) } reloadData?.(false) @@ -466,6 +484,8 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState( isChildrenListLoading, isChildrenExcludedListLoading, row, + isChildrenLoading, + isChildrenExcludedLoading, deleteRelatedRow, getRelatedTableRowId, } From 003bbcff0ec3d6acfc2838c50873368069f0758c Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 20 Sep 2023 12:38:09 +0530 Subject: [PATCH 03/14] fix: loading state for link --- .../nc-gui/components/virtual-cell/components/ListItem.vue | 2 +- packages/nc-gui/composables/useLTARStore.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/virtual-cell/components/ListItem.vue b/packages/nc-gui/components/virtual-cell/components/ListItem.vue index 2be57791d4..dfe8cfbb40 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListItem.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListItem.vue @@ -72,7 +72,7 @@ const attachments: Attachment[] = computed(() => {
{{ row[relatedTableDisplayValueProp] }} -
+
- + {{ showHeader ? 'Linked Records' : '' }}
From 0b9b36561455661527b630e8c595e30717e5cc90 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 20 Sep 2023 21:39:50 +0530 Subject: [PATCH 05/14] feat: child item preloader --- packages/nc-gui/components.d.ts | 1 + .../components/ListChildItems.vue | 33 +++++++++++++++++-- .../virtual-cell/components/ListItem.vue | 2 +- .../virtual-cell/components/ListItems.vue | 31 +++++++++++++++-- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/components.d.ts b/packages/nc-gui/components.d.ts index 6c96a14054..0e78a9c6a6 100644 --- a/packages/nc-gui/components.d.ts +++ b/packages/nc-gui/components.d.ts @@ -120,6 +120,7 @@ declare module '@vue/runtime-core' { MdiChatProcessingOutline: typeof import('~icons/mdi/chat-processing-outline')['default'] MdiCheck: typeof import('~icons/mdi/check')['default'] MdiChevronDown: typeof import('~icons/mdi/chevron-down')['default'] + MdiChevronLeft: typeof import('~icons/mdi/chevron-left')['default'] MdiChevronRight: typeof import('~icons/mdi/chevron-right')['default'] MdiCircleMedium: typeof import('~icons/mdi/circle-medium')['default'] MdiClose: typeof import('~icons/mdi/close')['default'] diff --git a/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue b/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue index 764b22c5f7..194fe8180f 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListChildItems.vue @@ -177,7 +177,34 @@ onKeyStroke('Escape', () => { class="overflow-scroll nc-scrollbar-md cursor-pointer pr-1" >