platform/models/server-controlled-documents/src/index.ts
Denis Bykhov 8bfeba7303
Remove collection tx (#7171)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
2024-11-15 11:49:35 +07:00

70 lines
2.4 KiB
TypeScript

//
// Copyright © 2023 Hardcore Engineering Inc.
//
import { type Builder } from '@hcengineering/model'
import core from '@hcengineering/core'
import serverCore from '@hcengineering/server-core'
import { RequestStatus } from '@hcengineering/request'
import documents, { DocumentState } from '@hcengineering/controlled-documents'
import serverDocuments from '@hcengineering/server-controlled-documents'
import contact from '@hcengineering/contact'
import serverNotification from '@hcengineering/server-notification'
export { serverDocumentsId } from '@hcengineering/server-controlled-documents/src/index'
export function createModel (builder: Builder): void {
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverDocuments.trigger.OnDocDeleted,
txMatch: {
_class: core.class.TxUpdateDoc,
objectClass: documents.class.ControlledDocument,
'operations.state': DocumentState.Deleted
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverDocuments.trigger.OnDocPlannedEffectiveDateChanged,
txMatch: {
_class: core.class.TxUpdateDoc,
objectClass: documents.class.ControlledDocument
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverDocuments.trigger.OnDocApprovalRequestApproved,
txMatch: {
_class: core.class.TxUpdateDoc,
attachedToClass: documents.class.ControlledDocument,
objectClass: documents.class.DocumentApprovalRequest,
'operations.status': RequestStatus.Completed
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverDocuments.trigger.OnDocHasBecomeEffective,
txMatch: {
_class: core.class.TxUpdateDoc,
objectClass: documents.class.ControlledDocument,
'operations.state': DocumentState.Effective
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverDocuments.trigger.OnWorkspaceOwnerAdded,
txMatch: {
objectClass: contact.class.PersonAccount
}
})
builder.mixin(documents.class.DocumentMeta, core.class.Class, serverCore.mixin.SearchPresenter, {
iconConfig: {
component: documents.component.DocumentIcon
},
title: [['title']]
})
builder.mixin(documents.class.ControlledDocument, core.class.Class, serverNotification.mixin.TextPresenter, {
presenter: serverDocuments.function.ControlledDocumentTextPresenter
})
}