mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-10 03:37:43 +02:00
Card notifications (#10503)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -876,8 +876,17 @@ export async function OnCardTag (ctx: TxMixin<Card, Card>[], control: TriggerCon
|
||||
return res
|
||||
}
|
||||
|
||||
export async function CardTextPresenter (doc: Doc): Promise<string> {
|
||||
const card = doc as Card
|
||||
|
||||
return card.title
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export default async () => ({
|
||||
function: {
|
||||
CardTextPresenter
|
||||
},
|
||||
trigger: {
|
||||
OnAttribute,
|
||||
OnAttributeRemove,
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hcengineering/core": "workspace:^0.7.24",
|
||||
"@hcengineering/server-notification": "workspace:^0.7.0",
|
||||
"@hcengineering/server-core": "workspace:^0.7.18",
|
||||
"@hcengineering/platform": "workspace:^0.7.19"
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import type { Metadata, Plugin, Resource } from '@hcengineering/platform'
|
||||
import { plugin } from '@hcengineering/platform'
|
||||
import type { TriggerFunc } from '@hcengineering/server-core'
|
||||
import { type Presenter } from '@hcengineering/server-notification'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@@ -29,6 +30,9 @@ export default plugin(serverCardId, {
|
||||
metadata: {
|
||||
CommunicationEnabled: '' as Metadata<boolean>
|
||||
},
|
||||
function: {
|
||||
CardTextPresenter: '' as Resource<Presenter>
|
||||
},
|
||||
trigger: {
|
||||
OnAttribute: '' as Resource<TriggerFunc>,
|
||||
OnAttributeRemove: '' as Resource<TriggerFunc>,
|
||||
|
||||
@@ -266,10 +266,13 @@ function getMatchedTypes (
|
||||
isSpace: boolean,
|
||||
field?: string
|
||||
): NotificationType[] {
|
||||
const allTypes = control.modelDb
|
||||
.findAllSync(notification.class.NotificationType, { ...(field !== undefined ? { field } : {}) })
|
||||
.filter((p) => (isSpace ? p.spaceSubscribe === true : p.spaceSubscribe !== true))
|
||||
const filtered: NotificationType[] = []
|
||||
let allTypes: NotificationType[] = control.modelDb.findAllSync(notification.class.NotificationType, {})
|
||||
allTypes = allTypes.filter(
|
||||
(p) =>
|
||||
(isSpace ? p.spaceSubscribe === true : p.spaceSubscribe !== true) &&
|
||||
(field === undefined || p.field === field || p.field === undefined)
|
||||
)
|
||||
for (const type of allTypes) {
|
||||
if (isTypeMatched(control, type, tx, isOwn)) {
|
||||
filtered.push(type)
|
||||
|
||||
Reference in New Issue
Block a user