From 5b61ae8fa41958817c407e3aa4e16a77d7d31253 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 31 May 2023 19:07:47 +0600 Subject: [PATCH] UBER-322 Company notifications (#3306) Signed-off-by: Denis Bykhov --- models/contact/package.json | 1 + models/contact/src/index.ts | 39 +++++++++++++++++++++++++++ models/contact/src/plugin.ts | 5 ++++ models/lead/src/index.ts | 51 ++++++++++++++++++++++++++++++++++++ models/lead/src/plugin.ts | 3 +++ 5 files changed, 99 insertions(+) diff --git a/models/contact/package.json b/models/contact/package.json index ea5a4006e9..e049a204fa 100644 --- a/models/contact/package.json +++ b/models/contact/package.json @@ -29,6 +29,7 @@ "@hcengineering/model-chunter": "^0.6.0", "@hcengineering/model-workbench": "^0.6.1", "@hcengineering/model-attachment": "^0.6.0", + "@hcengineering/model-notification": "^0.6.0", "@hcengineering/model-view": "^0.6.0", "@hcengineering/model-presentation": "^0.6.0", "@hcengineering/model": "^0.6.4", diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 91e3a5e64c..1e6d23f4c7 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -52,6 +52,7 @@ import core, { TAccount, TAttachedDoc, TDoc, TSpace } from '@hcengineering/model import presentation from '@hcengineering/model-presentation' import view, { ViewAction, Viewlet, createAction } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' +import { generateClassNotificationTypes } from '@hcengineering/model-notification' import notification from '@hcengineering/notification' import type { Asset, IntlString, Resource } from '@hcengineering/platform' import setting from '@hcengineering/setting' @@ -789,4 +790,42 @@ export function createModel (builder: Builder): void { builder.mixin(contact.class.Contact, core.class.Class, activity.mixin.ExtraActivityComponent, { component: contact.component.ActivityChannelMessage }) + + builder.createDoc( + notification.class.NotificationGroup, + core.space.Model, + { + label: contact.string.Organizations, + icon: contact.icon.Company, + objectClass: contact.class.Organization + }, + contact.ids.OrganizationNotificationGroup + ) + + generateClassNotificationTypes( + builder, + contact.class.Organization, + contact.ids.OrganizationNotificationGroup, + [], + ['comments', 'attachments', 'members'] + ) + + builder.createDoc( + notification.class.NotificationGroup, + core.space.Model, + { + label: contact.string.Persons, + icon: contact.icon.Person, + objectClass: contact.class.Person + }, + contact.ids.PersonNotificationGroup + ) + + generateClassNotificationTypes( + builder, + contact.class.Person, + contact.ids.PersonNotificationGroup, + [], + ['comments', 'attachments'] + ) } diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 7dd7496b07..2c7c9790ea 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -18,6 +18,7 @@ import contact from '@hcengineering/contact-resources/src/plugin' import type { Client, Doc, Ref } from '@hcengineering/core' import {} from '@hcengineering/core' import { ObjectSearchCategory, ObjectSearchFactory } from '@hcengineering/model-presentation' +import { NotificationGroup } from '@hcengineering/notification' import { IntlString, mergeIds, Resource } from '@hcengineering/platform' import { TemplateFieldFunc } from '@hcengineering/templates' import type { AnyComponent } from '@hcengineering/ui' @@ -104,6 +105,10 @@ export default mergeIds(contactId, contact, { category: { Contact: '' as Ref }, + ids: { + OrganizationNotificationGroup: '' as Ref, + PersonNotificationGroup: '' as Ref + }, action: { KickEmployee: '' as Ref, MergeEmployee: '' as Ref diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index f90855a83a..8129f35b87 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -395,6 +395,57 @@ export function createModel (builder: Builder): void { ['comments', 'state', 'doneState'] ) + builder.createDoc( + notification.class.NotificationGroup, + core.space.Model, + { + label: lead.string.Customers, + icon: lead.icon.CreateCustomer, + objectClass: lead.mixin.Customer + }, + lead.ids.CustomerNotificationGroup + ) + + generateClassNotificationTypes( + builder, + lead.mixin.Customer, + lead.ids.CustomerNotificationGroup, + [], + ['comments', 'attachments'] + ) + + builder.createDoc( + notification.class.NotificationGroup, + core.space.Model, + { + label: lead.string.Funnels, + icon: lead.icon.Funnel, + objectClass: lead.class.Funnel + }, + lead.ids.FunnelNotificationGroup + ) + + builder.createDoc( + notification.class.NotificationType, + core.space.Model, + { + hidden: false, + generated: false, + label: lead.string.LeadCreateLabel, + group: lead.ids.FunnelNotificationGroup, + field: 'space', + txClasses: [core.class.TxCreateDoc, core.class.TxUpdateDoc], + objectClass: lead.class.Funnel, + spaceSubscribe: true, + providers: { + [notification.providers.PlatformNotification]: false + } + }, + lead.ids.LeadCreateNotification + ) + + generateClassNotificationTypes(builder, lead.class.Funnel, lead.ids.FunnelNotificationGroup, [], ['comments']) + builder.createDoc( view.class.Viewlet, core.space.Model, diff --git a/models/lead/src/plugin.ts b/models/lead/src/plugin.ts index 415a631c63..e5f625b2c5 100644 --- a/models/lead/src/plugin.ts +++ b/models/lead/src/plugin.ts @@ -66,6 +66,9 @@ export default mergeIds(leadId, lead, { }, ids: { LeadNotificationGroup: '' as Ref, + CustomerNotificationGroup: '' as Ref, + FunnelNotificationGroup: '' as Ref, + LeadCreateNotification: '' as Ref, AssigneeNotification: '' as Ref } })