Browse Source

refactor(nc-gui): updateNullBaseOrder function

pull/7528/head
Ramesh Mane 10 months ago
parent
commit
8dc7442fc4
  1. 4
      packages/nc-gui/components/dashboard/TreeView/index.vue
  2. 17
      packages/nc-gui/store/bases.ts

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

@ -283,9 +283,9 @@ watch(
<style scoped lang="scss"> <style scoped lang="scss">
.ghost, .ghost,
.ghost > * { .ghost > * {
@apply !pointer-events-none; @apply pointer-events-none;
} }
.ghost { .ghost {
@apply !bg-primary-selected; @apply bg-primary-selected;
} }
</style> </style>

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

@ -308,9 +308,11 @@ export const useBases = defineStore('basesStore', () => {
if (!isUIAllowed('baseMove')) return if (!isUIAllowed('baseMove')) return
const basesArray = Array.from(bases.value.values()) const basesArray = Array.from(bases.value.values())
const isOrderNullPresent = basesArray.some((base) => base.order === null)
if (isOrderNullPresent) { // Filter bases with null orders, update the local state and return updated bases payload
const orderUpdateBasesList = basesArray.map((base, i) => { const basesWithNullOrder = basesArray
.filter((base) => base.order === null)
.map((base, i) => {
bases.value.set(base.id!, { ...base, order: i + 1 }) bases.value.set(base.id!, { ...base, order: i + 1 })
return { return {
@ -319,9 +321,12 @@ export const useBases = defineStore('basesStore', () => {
} }
}) })
for (const orderUpdateBase of orderUpdateBasesList) { if (basesWithNullOrder.length) {
await api.base.update(orderUpdateBase.id!, { order: orderUpdateBase.order }) await Promise.all(
} basesWithNullOrder.map(async (base) => {
await api.base.update(base.id!, { order: base.order })
}),
)
} }
} }

Loading…
Cancel
Save