mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-17 18:05:42 +02:00
Add notifications for reviewed documents (#10601)
* Send notification when document reviewed Signed-off-by: Artem Savchenko <armisav@gmail.com> * Clean up Signed-off-by: Artem Savchenko <armisav@gmail.com> --------- Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -1218,6 +1218,28 @@ export function defineNotifications (builder: Builder): void {
|
||||
documents.notification.StateNotification
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
notification.class.NotificationType,
|
||||
core.space.Model,
|
||||
{
|
||||
hidden: false,
|
||||
generated: false,
|
||||
allowedForAuthor: true,
|
||||
label: documents.string.Review,
|
||||
group: documents.notification.DocumentsNotificationGroup,
|
||||
field: 'controlledState',
|
||||
txClasses: [core.class.TxUpdateDoc],
|
||||
objectClass: documents.class.ControlledDocument,
|
||||
defaultEnabled: true,
|
||||
templates: {
|
||||
textTemplate: '{sender} marked {doc} as reviewed',
|
||||
htmlTemplate: '<p>{sender} marked {doc} as reviewed</p>',
|
||||
subjectTemplate: '{doc} reviewed'
|
||||
}
|
||||
},
|
||||
documents.notification.ReviewNotification
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
notification.class.NotificationType,
|
||||
core.space.Model,
|
||||
@@ -1243,7 +1265,11 @@ export function defineNotifications (builder: Builder): void {
|
||||
builder.createDoc(notification.class.NotificationProviderDefaults, core.space.Model, {
|
||||
provider: notification.providers.InboxNotificationProvider,
|
||||
ignoredTypes: [],
|
||||
enabledTypes: [documents.notification.StateNotification, documents.notification.ContentNotification]
|
||||
enabledTypes: [
|
||||
documents.notification.StateNotification,
|
||||
documents.notification.ContentNotification,
|
||||
documents.notification.ReviewNotification
|
||||
]
|
||||
})
|
||||
|
||||
generateClassNotificationTypes(
|
||||
|
||||
@@ -72,6 +72,15 @@ export function createModel (builder: Builder): void {
|
||||
presenter: serverDocuments.function.ControlledDocumentHTMLPresenter
|
||||
})
|
||||
|
||||
builder.mixin(
|
||||
documents.notification.ReviewNotification,
|
||||
notification.class.NotificationType,
|
||||
serverNotification.mixin.TypeMatch,
|
||||
{
|
||||
func: serverDocuments.function.DocumentReviewedTypeMatch
|
||||
}
|
||||
)
|
||||
|
||||
builder.mixin(
|
||||
documents.notification.CoAuthorsNotification,
|
||||
notification.class.NotificationType,
|
||||
|
||||
@@ -336,7 +336,8 @@ export const documentsPlugin = plugin(documentsId, {
|
||||
ProductChangeControl: '' as Ref<DocumentTemplate>
|
||||
},
|
||||
notification: {
|
||||
CoAuthorsNotification: '' as Ref<NotificationType>
|
||||
CoAuthorsNotification: '' as Ref<NotificationType>,
|
||||
ReviewNotification: '' as Ref<NotificationType>
|
||||
},
|
||||
viewlet: {
|
||||
DocumentSpaceTable: '' as Ref<Viewlet>
|
||||
|
||||
@@ -448,6 +448,21 @@ async function CoAuthorsTypeMatch (
|
||||
return false
|
||||
}
|
||||
|
||||
async function DocumentReviewedTypeMatch (
|
||||
originTx: TxCUD<ControlledDocument>,
|
||||
_doc: Doc,
|
||||
_person: Ref<Person>,
|
||||
_socialIds: PersonId[],
|
||||
_type: NotificationType,
|
||||
_control: TriggerControl
|
||||
): Promise<boolean> {
|
||||
if (originTx._class !== core.class.TxUpdateDoc) return false
|
||||
|
||||
const tx = originTx as TxUpdateDoc<ControlledDocument>
|
||||
|
||||
return tx.operations.controlledState === ControlledDocumentState.Reviewed
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export default async () => ({
|
||||
trigger: {
|
||||
@@ -460,6 +475,7 @@ export default async () => ({
|
||||
function: {
|
||||
ControlledDocumentTextPresenter,
|
||||
ControlledDocumentHTMLPresenter,
|
||||
CoAuthorsTypeMatch
|
||||
CoAuthorsTypeMatch,
|
||||
DocumentReviewedTypeMatch
|
||||
}
|
||||
})
|
||||
|
||||
@@ -27,6 +27,7 @@ export default plugin(serverDocumentsId, {
|
||||
function: {
|
||||
ControlledDocumentTextPresenter: '' as Resource<Presenter>,
|
||||
ControlledDocumentHTMLPresenter: '' as Resource<Presenter>,
|
||||
CoAuthorsTypeMatch: '' as TypeMatchFunc
|
||||
CoAuthorsTypeMatch: '' as TypeMatchFunc,
|
||||
DocumentReviewedTypeMatch: '' as TypeMatchFunc
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user