Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion models/controlled-documents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions models/server-controlled-documents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion plugins/controlled-documents/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
18 changes: 17 additions & 1 deletion server-plugins/controlled-documents-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -460,6 +475,7 @@ export default async () => ({
function: {
ControlledDocumentTextPresenter,
ControlledDocumentHTMLPresenter,
CoAuthorsTypeMatch
CoAuthorsTypeMatch,
DocumentReviewedTypeMatch
}
})
3 changes: 2 additions & 1 deletion server-plugins/controlled-documents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Loading