mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03:00
UBERF-5083: Fix project delete (#4446)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
6d31c0f2e5
commit
f94cda3cff
@ -25,7 +25,8 @@ import core, {
|
|||||||
type Ref,
|
type Ref,
|
||||||
type RelatedDocument,
|
type RelatedDocument,
|
||||||
toIdMap,
|
toIdMap,
|
||||||
type TxOperations
|
type TxOperations,
|
||||||
|
DOMAIN_CONFIGURATION
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import { type Resources, translate } from '@hcengineering/platform'
|
import { type Resources, translate } from '@hcengineering/platform'
|
||||||
import { getClient, MessageBox, type ObjectSearchResult } from '@hcengineering/presentation'
|
import { getClient, MessageBox, type ObjectSearchResult } from '@hcengineering/presentation'
|
||||||
@ -303,35 +304,39 @@ async function deleteProject (project: Project | undefined): Promise<void> {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const d = h.findDomain(c._id)
|
const d = h.findDomain(c._id)
|
||||||
if (d !== undefined && d !== DOMAIN_MODEL) {
|
if (d !== undefined && d !== DOMAIN_MODEL && d !== DOMAIN_CONFIGURATION) {
|
||||||
while (true) {
|
try {
|
||||||
const docs = await client.findAll(c._id, { space: project._id }, { limit: 50 })
|
while (true) {
|
||||||
if (docs.length === 0) {
|
const docs = await client.findAll(c._id, { space: project._id }, { limit: 50 })
|
||||||
break
|
if (docs.length === 0) {
|
||||||
}
|
break
|
||||||
const ops = client.apply('delete')
|
}
|
||||||
for (const object of docs) {
|
const ops = client.apply('delete')
|
||||||
if (client.getHierarchy().isDerived(object._class, core.class.AttachedDoc)) {
|
for (const object of docs) {
|
||||||
const adoc = object as AttachedDoc
|
if (client.getHierarchy().isDerived(object._class, core.class.AttachedDoc)) {
|
||||||
await ops
|
const adoc = object as AttachedDoc
|
||||||
.removeCollection(
|
await ops
|
||||||
object._class,
|
.removeCollection(
|
||||||
object.space,
|
object._class,
|
||||||
adoc._id,
|
object.space,
|
||||||
adoc.attachedTo,
|
adoc._id,
|
||||||
adoc.attachedToClass,
|
adoc.attachedTo,
|
||||||
adoc.collection
|
adoc.attachedToClass,
|
||||||
)
|
adoc.collection
|
||||||
.catch((err) => {
|
)
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
await ops.removeDoc(object._class, object.space, object._id).catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
await ops.removeDoc(object._class, object.space, object._id).catch((err) => {
|
|
||||||
console.error(err)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
await ops.commit()
|
||||||
}
|
}
|
||||||
await ops.commit()
|
} catch (err: any) {
|
||||||
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user