Browse Source

fix: PR review changes #2240

pull/7528/head
Ramesh Mane 10 months ago
parent
commit
7acb5a46d0
  1. 4
      packages/nc-gui/store/bases.ts
  2. 7
      packages/nocodb/src/models/Base.ts
  3. 20
      packages/nocodb/src/models/BaseUser.ts

4
packages/nc-gui/store/bases.ts

@ -309,7 +309,7 @@ export const useBases = defineStore('basesStore', () => {
const basesArray = Array.from(bases.value.values()) const basesArray = Array.from(bases.value.values())
let baseOrderSet = new Set() const baseOrderSet = new Set()
let hasNullOrDuplicates = false let hasNullOrDuplicates = false
// Check if basesArray contains null or duplicate order // Check if basesArray contains null or duplicate order
@ -324,7 +324,7 @@ export const useBases = defineStore('basesStore', () => {
if (!hasNullOrDuplicates) return if (!hasNullOrDuplicates) return
// update the local state and return updated bases payload // update the local state and return updated bases payload
let updatedBasesOrder = basesArray.map((base, i) => { const updatedBasesOrder = basesArray.map((base, i) => {
bases.value.set(base.id!, { ...base, order: i + 1 }) bases.value.set(base.id!, { ...base, order: i + 1 })
return { return {

7
packages/nocodb/src/models/Base.ts

@ -123,7 +123,7 @@ export default class Base implements BaseType {
await NocoCache.setList(CacheScope.PROJECT, [], baseList); await NocoCache.setList(CacheScope.PROJECT, [], baseList);
} }
baseList = baseList const castedProjectList = baseList
.filter( .filter(
(p) => p.deleted === 0 || p.deleted === false || p.deleted === null, (p) => p.deleted === 0 || p.deleted === false || p.deleted === null,
) )
@ -131,9 +131,8 @@ export default class Base implements BaseType {
(a, b) => (a, b) =>
(a.order != null ? a.order : Infinity) - (a.order != null ? a.order : Infinity) -
(b.order != null ? b.order : Infinity), (b.order != null ? b.order : Infinity),
); )
.map((m) => this.castType(m));
const castedProjectList = baseList.map((m) => this.castType(m));
await Promise.all(castedProjectList.map((base) => base.getSources(ncMeta))); await Promise.all(castedProjectList.map((base) => base.getSources(ncMeta)));

20
packages/nocodb/src/models/BaseUser.ts

@ -352,13 +352,8 @@ export default class BaseUser {
qb.whereNot(`${MetaTable.PROJECT}.deleted`, true); qb.whereNot(`${MetaTable.PROJECT}.deleted`, true);
const baseList = await qb; const baseList = await qb;
if (baseList?.length) {
// parse meta
for (const base of baseList) {
base.meta = parseMetaProp(base);
}
}
if (baseList && baseList?.length) {
const castedProjectList = baseList const castedProjectList = baseList
.filter((p) => !params?.type || p.type === params.type) .filter((p) => !params?.type || p.type === params.type)
.sort( .sort(
@ -366,11 +361,18 @@ export default class BaseUser {
(a.order != null ? a.order : Infinity) - (a.order != null ? a.order : Infinity) -
(b.order != null ? b.order : Infinity), (b.order != null ? b.order : Infinity),
) )
.map((m) => Base.castType(m)); .map((m) => {
m.meta = parseMetaProp(m);
await Promise.all(castedProjectList.map((base) => base.getSources(ncMeta))); return Base.castType(m);
});
await Promise.all(
castedProjectList.map((base) => base.getSources(ncMeta)),
);
return castedProjectList; return castedProjectList;
} else {
return [];
}
} }
static async updateOrInsert( static async updateOrInsert(

Loading…
Cancel
Save