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">
.ghost,
.ghost > * {
@apply !pointer-events-none;
@apply pointer-events-none;
}
.ghost {
@apply !bg-primary-selected;
@apply bg-primary-selected;
}
</style>

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

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

Loading…
Cancel
Save