mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-27 01:13:27 +03:00
commit
87ca27978a
@ -1,9 +1,9 @@
|
||||
import { Collection, DocumentUpdate, Hierarchy, MixinData, MixinUpdate, ModelDb } from '.'
|
||||
import { DocumentUpdate, Hierarchy, MixinData, MixinUpdate, ModelDb } from '.'
|
||||
import type { Account, AttachedData, AttachedDoc, Class, Data, Doc, Mixin, PropertyType, Ref, Space } from './classes'
|
||||
import { Client } from './client'
|
||||
import core from './component'
|
||||
import type { DocumentQuery, FindOptions, FindResult, TxResult, WithLookup } from './storage'
|
||||
import { Tx, TxFactory } from './tx'
|
||||
import core from './component'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -183,14 +183,4 @@ export class TxOperations implements Omit<Client, 'notify'> {
|
||||
}
|
||||
return this.removeDoc(doc._class, doc.space, doc._id)
|
||||
}
|
||||
|
||||
add<T extends Doc, P extends AttachedDoc>(parent: T, _class: Ref<Class<P>>, obj: AttachedData<P>, objId?: Ref<P>): Promise<TxResult> {
|
||||
const h = this.client.getHierarchy()
|
||||
const attrs = Array.from(h.getAllAttributes(parent._class).values())
|
||||
const collections = attrs.filter(a => h.isDerived(a.type._class, core.class.Collection) && h.isDerived(_class, (a.type as Collection<AttachedDoc>).of))
|
||||
if (collections.length !== 1) {
|
||||
throw new Error('Please use addCollection method, collection could not be detected.')
|
||||
}
|
||||
return this.addCollection<T, P>(_class, parent.space, parent._id, parent._class, collections[0].name, obj, objId)
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
)
|
||||
|
||||
function onMessage (event: CustomEvent) {
|
||||
client.add(object, chunter.class.Comment, { message: event.detail })
|
||||
client.addCollection(chunter.class.Comment, object.space, object._id, object._class, 'comments', { message: event.detail })
|
||||
}
|
||||
|
||||
let viewlets: Map<ActivityKey, TxViewlet>
|
||||
|
@ -75,7 +75,7 @@
|
||||
await client.createMixin<Contact, Customer>(customerInstance._id, customerInstance._class, customerInstance.space, lead.mixin.Customer, {})
|
||||
}
|
||||
|
||||
await client.add(customerInstance, lead.class.Lead, value, leadId)
|
||||
await client.addCollection(lead.class.Lead, _space, customer!, lead.mixin.Customer, 'leads', value, leadId)
|
||||
dispatch('close')
|
||||
}
|
||||
</script>
|
||||
|
@ -82,8 +82,9 @@
|
||||
await client.createMixin<Contact, Candidate>(candidateInstance._id, candidateInstance._class, candidateInstance.space, recruit.mixin.Candidate, {})
|
||||
}
|
||||
|
||||
await client.add(candidateInstance,
|
||||
await client.addCollection(
|
||||
recruit.class.Applicant,
|
||||
space, candidateInstance._id, recruit.mixin.Candidate, 'applications',
|
||||
{
|
||||
state: state._id,
|
||||
doneState: null,
|
||||
|
Loading…
Reference in New Issue
Block a user