mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-26 04:23:58 +03:00
Remove member when delete contact (#2673)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
dae9de4800
commit
9a96035b00
@ -27,7 +27,7 @@ import { workbenchId } from '@hcengineering/workbench'
|
|||||||
*/
|
*/
|
||||||
export async function OnContactDelete (
|
export async function OnContactDelete (
|
||||||
tx: Tx,
|
tx: Tx,
|
||||||
{ findAll, hierarchy, storageFx, removedMap }: TriggerControl
|
{ findAll, hierarchy, storageFx, removedMap, txFactory }: TriggerControl
|
||||||
): Promise<Tx[]> {
|
): Promise<Tx[]> {
|
||||||
if (tx._class !== core.class.TxRemoveDoc) {
|
if (tx._class !== core.class.TxRemoveDoc) {
|
||||||
return []
|
return []
|
||||||
@ -66,7 +66,22 @@ export async function OnContactDelete (
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return []
|
const result: Tx[] = []
|
||||||
|
|
||||||
|
const members = await findAll(contact.class.Member, { contact: removeContact._id })
|
||||||
|
for (const member of members) {
|
||||||
|
const removeTx = txFactory.createTxRemoveDoc(member._class, member.space, member._id)
|
||||||
|
const tx = txFactory.createTxCollectionCUD(
|
||||||
|
member.attachedToClass,
|
||||||
|
member.attachedTo,
|
||||||
|
member.space,
|
||||||
|
member.collection,
|
||||||
|
removeTx
|
||||||
|
)
|
||||||
|
result.push(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user