mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 09:51:53 +00:00
Fix mixins for calendar event (#8393)
Some checks are pending
CI / test (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / formatting (push) Blocked by required conditions
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / test (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / formatting (push) Blocked by required conditions
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
9475b55489
commit
bf66d44f71
@ -197,12 +197,36 @@ async function OnEvent (txes: Tx[], control: TriggerControl): Promise<Tx[]> {
|
||||
result.push(...(await onEventUpdate(ctx as TxUpdateDoc<Event>, control)))
|
||||
} else if (ctx._class === core.class.TxRemoveDoc) {
|
||||
result.push(...(await onRemoveEvent(ctx as TxRemoveDoc<Event>, control)))
|
||||
} else if (ctx._class === core.class.TxMixin) {
|
||||
result.push(...(await onEventMixin(ctx as TxMixin<Event, Event>, control)))
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
async function onEventMixin (ctx: TxMixin<Event, Event>, control: TriggerControl): Promise<Tx[]> {
|
||||
const ops = ctx.attributes
|
||||
const event = (await control.findAll(control.ctx, calendar.class.Event, { _id: ctx.objectId }, { limit: 1 }))[0]
|
||||
if (event === undefined) return []
|
||||
if (event.access !== 'owner') return []
|
||||
const events = await control.findAll(control.ctx, calendar.class.Event, { eventId: event.eventId })
|
||||
const res: Tx[] = []
|
||||
for (const ev of events) {
|
||||
if (ev._id === event._id) continue
|
||||
const innerTx = control.txFactory.createTxMixin(ev._id, ev._class, ev.space, ctx.mixin, { ...ops })
|
||||
const outerTx = control.txFactory.createTxCollectionCUD(
|
||||
ev.attachedToClass,
|
||||
ev.attachedTo,
|
||||
ev.space,
|
||||
ev.collection,
|
||||
innerTx
|
||||
)
|
||||
res.push(outerTx)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
async function onEventUpdate (ctx: TxUpdateDoc<Event>, control: TriggerControl): Promise<Tx[]> {
|
||||
const ops = ctx.operations
|
||||
const { visibility, ...otherOps } = ops
|
||||
|
Loading…
Reference in New Issue
Block a user