Browse Source

Merge pull request #9142 from nocodb/nc-fix/sub-group

fix: Sub-group loading issue
pull/9134/head
Pranav C 4 months ago committed by GitHub
parent
commit
0e51cd9086
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      packages/nc-gui/components/smartsheet/grid/GroupBy.vue
  2. 1
      packages/nc-gui/components/workspace/CollaboratorsList.vue
  3. 17
      packages/nocodb/src/db/BaseModelSqlv2.ts
  4. 10
      packages/nocodb/src/services/meta-diffs.service.ts

22
packages/nc-gui/components/smartsheet/grid/GroupBy.vue

@ -133,10 +133,16 @@ const activeGroups = computed<string[]>(() => {
const oldActiveGroups = ref<string[]>([]) const oldActiveGroups = ref<string[]>([])
const findAndLoadSubGroup = (key: any) => { const findAndLoadSubGroup = async (key: any) => {
key = Array.isArray(key) ? key : [key] key = Array.isArray(key) ? key : [key]
if (key.length > 0 && vGroup.value.children) { if (key.length > 0 && vGroup.value.children) {
if (!oldActiveGroups.value.includes(key[key.length - 1])) { if (!oldActiveGroups.value.includes(key[key.length - 1])) {
// wait until children loads since it may be still loading in background
// todo: implement a better way to handle this
await until(() => vGroup.value.children?.length > 0).toBeTruthy({
timeout: 10000,
})
const k = key[key.length - 1].replace('group-panel-', '') const k = key[key.length - 1].replace('group-panel-', '')
const grp = vGroup.value.children.find((g) => `${g.key}` === k) const grp = vGroup.value.children.find((g) => `${g.key}` === k)
if (grp) { if (grp) {
@ -278,13 +284,13 @@ const shouldRenderCell = (column) =>
UITypes.LastModifiedBy, UITypes.LastModifiedBy,
].includes(column?.uidt) ].includes(column?.uidt)
const expandGroup = (key: string) => { const expandGroup = async (key: string) => {
if (Array.isArray(_activeGroupKeys.value)) { if (Array.isArray(_activeGroupKeys.value)) {
_activeGroupKeys.value.push(`group-panel-${key}`) _activeGroupKeys.value.push(`group-panel-${key}`)
} else { } else {
_activeGroupKeys.value = [`group-panel-${key}`] _activeGroupKeys.value = [`group-panel-${key}`]
} }
findAndLoadSubGroup(`group-panel-${key}`) await findAndLoadSubGroup(`group-panel-${key}`)
} }
const collapseGroup = (key: string) => { const collapseGroup = (key: string) => {
@ -299,13 +305,15 @@ const collapseAllGroup = () => {
_activeGroupKeys.value = [] _activeGroupKeys.value = []
} }
const expandAllGroup = () => { const expandAllGroup = async () => {
_activeGroupKeys.value = vGroup.value.children?.map((g) => `group-panel-${g.key}`) ?? [] _activeGroupKeys.value = vGroup.value.children?.map((g) => `group-panel-${g.key}`) ?? []
if (vGroup.value.children) { if (vGroup.value.children) {
vGroup.value.children.forEach((g) => { await Promise.all(
findAndLoadSubGroup(`group-panel-${g.key}`) vGroup.value.children.map((g) => {
}) return findAndLoadSubGroup(`group-panel-${g.key}`)
}),
)
} }
} }

1
packages/nc-gui/components/workspace/CollaboratorsList.vue

@ -1,4 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
/* eslint-disable @typescript-eslint/consistent-type-imports */
import { OrderedWorkspaceRoles, WorkspaceUserRoles } from 'nocodb-sdk' import { OrderedWorkspaceRoles, WorkspaceUserRoles } from 'nocodb-sdk'
const props = defineProps<{ const props = defineProps<{

17
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -1011,10 +1011,7 @@ class BaseModelSqlv2 {
) )
.from(count.as(getAlias())); .from(count.as(getAlias()));
selectors.push( selectors.push(
this.dbDriver.raw(`(??) as "??"`, [ this.dbDriver.raw(`(??) as ??`, [subQuery, `${f.alias}`]),
subQuery,
this.dbDriver.raw(f.alias),
]),
); );
break; break;
case 'mysql2': case 'mysql2':
@ -1391,10 +1388,7 @@ class BaseModelSqlv2 {
) )
.from(tQb.as(getAlias())); .from(tQb.as(getAlias()));
selectors.push( selectors.push(
this.dbDriver.raw(`(??) as "??"`, [ this.dbDriver.raw(`(??) as ??`, [subQuery, `${f.alias}`]),
subQuery,
this.dbDriver.raw(f.alias),
]),
); );
break; break;
case 'mysql2': case 'mysql2':
@ -1597,12 +1591,7 @@ class BaseModelSqlv2 {
tQb.select(jsonBuildObject); tQb.select(jsonBuildObject);
selectors.push( selectors.push(this.dbDriver.raw(`(??) as ??`, [tQb, `${f.alias}`]));
this.dbDriver.raw(`(??) as ??`, [
tQb,
this.dbDriver.raw(`"${f.alias}"`),
]),
);
} }
qb.select(...selectors); qb.select(...selectors);

10
packages/nocodb/src/services/meta-diffs.service.ts

@ -448,7 +448,10 @@ export class MetaDiffsService {
} }
for (const relation of relationList) { for (const relation of relationList) {
if (!relation?.found?.[RelationTypes.BELONGS_TO] && !relation?.found?.[RelationTypes.ONE_TO_ONE]) { if (
!relation?.found?.[RelationTypes.BELONGS_TO] &&
!relation?.found?.[RelationTypes.ONE_TO_ONE]
) {
changes changes
.find((t) => t.table_name === relation.tn) .find((t) => t.table_name === relation.tn)
?.detectedChanges.push({ ?.detectedChanges.push({
@ -462,7 +465,10 @@ export class MetaDiffsService {
cstn: relation.cstn, cstn: relation.cstn,
}); });
} }
if (!relation?.found?.[RelationTypes.HAS_MANY] && !relation?.found?.[RelationTypes.ONE_TO_ONE]) { if (
!relation?.found?.[RelationTypes.HAS_MANY] &&
!relation?.found?.[RelationTypes.ONE_TO_ONE]
) {
changes changes
.find((t) => t.table_name === relation.rtn) .find((t) => t.table_name === relation.rtn)
?.detectedChanges.push({ ?.detectedChanges.push({

Loading…
Cancel
Save