mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 03:14:40 +03:00
Board: Update server-plugin for task to subscribe to updates on create & update (#1925)
Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
parent
e97a6cb6f5
commit
df9115b75a
@ -4,6 +4,7 @@
|
||||
|
||||
Platform:
|
||||
|
||||
- Fix subscribe to updates on Task create / update
|
||||
- Fix popup window layouts
|
||||
- Fix table two loading spinners
|
||||
- Improve full text search performance
|
||||
|
@ -16,18 +16,11 @@
|
||||
|
||||
import type { Doc, Ref, Tx, TxCollectionCUD, TxCreateDoc, TxRemoveDoc } from '@anticrm/core'
|
||||
import type { TriggerControl } from '@anticrm/server-core'
|
||||
import { extractTx } from '@anticrm/server-core'
|
||||
import type { Attachment } from '@anticrm/attachment'
|
||||
import attachment from '@anticrm/attachment'
|
||||
import core, { TxProcessor } from '@anticrm/core'
|
||||
|
||||
const extractTx = (tx: Tx): Tx => {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
return (tx as TxCollectionCUD<Doc, Attachment>).tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
||||
|
||||
const findCreateTx = async (
|
||||
id: Ref<Attachment>,
|
||||
findAll: TriggerControl['findAll']
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import contact, { Channel } from '@anticrm/contact'
|
||||
import core, {
|
||||
AttachedDoc,
|
||||
Class,
|
||||
Doc,
|
||||
DocumentQuery,
|
||||
@ -24,28 +23,11 @@ import core, {
|
||||
Hierarchy,
|
||||
Ref,
|
||||
Tx,
|
||||
TxCollectionCUD,
|
||||
TxCreateDoc,
|
||||
TxProcessor
|
||||
} from '@anticrm/core'
|
||||
import gmail, { Message } from '@anticrm/gmail'
|
||||
import { TriggerControl } from '@anticrm/server-core'
|
||||
|
||||
const extractTx = (tx: Tx): Tx => {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
||||
create.attributes.attachedTo = ctx.objectId
|
||||
create.attributes.attachedToClass = ctx.objectClass
|
||||
create.attributes.collection = ctx.collection
|
||||
return create
|
||||
}
|
||||
return ctx.tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
||||
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -13,31 +13,15 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, { AttachedDoc, Doc, Tx, TxCollectionCUD, TxCreateDoc, TxProcessor, TxUpdateDoc } from '@anticrm/core'
|
||||
import core, { Doc, Tx, TxCreateDoc, TxProcessor, TxUpdateDoc } from '@anticrm/core'
|
||||
import inventory, { Product } from '@anticrm/inventory'
|
||||
import login from '@anticrm/login'
|
||||
import { getMetadata } from '@anticrm/platform'
|
||||
import { TriggerControl } from '@anticrm/server-core'
|
||||
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
||||
import view from '@anticrm/view'
|
||||
import workbench from '@anticrm/workbench'
|
||||
|
||||
const extractTx = (tx: Tx): Tx => {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
||||
create.attributes.attachedTo = ctx.objectId
|
||||
create.attributes.attachedToClass = ctx.objectClass
|
||||
create.attributes.collection = ctx.collection
|
||||
return create
|
||||
}
|
||||
return ctx.tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
|
@ -35,25 +35,10 @@ import core, {
|
||||
import notification, { EmailNotification, Notification, NotificationStatus } from '@anticrm/notification'
|
||||
import { getResource } from '@anticrm/platform'
|
||||
import type { TriggerControl } from '@anticrm/server-core'
|
||||
import { extractTx } from '@anticrm/server-core'
|
||||
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
||||
import view, { HTMLPresenter, TextPresenter } from '@anticrm/view'
|
||||
|
||||
const extractTx = (tx: Tx): Tx => {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
||||
create.attributes.attachedTo = ctx.objectId
|
||||
create.attributes.attachedToClass = ctx.objectClass
|
||||
create.attributes.collection = ctx.collection
|
||||
return create
|
||||
}
|
||||
return ctx.tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
|
@ -14,7 +14,6 @@
|
||||
//
|
||||
|
||||
import core, {
|
||||
AttachedDoc,
|
||||
Class,
|
||||
Doc,
|
||||
DocumentQuery,
|
||||
@ -23,31 +22,14 @@ import core, {
|
||||
Hierarchy,
|
||||
Ref,
|
||||
Tx,
|
||||
TxCollectionCUD,
|
||||
TxCreateDoc,
|
||||
TxCUD,
|
||||
TxProcessor,
|
||||
TxRemoveDoc
|
||||
} from '@anticrm/core'
|
||||
import { TriggerControl } from '@anticrm/server-core'
|
||||
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||
import tags, { TagElement, TagReference } from '@anticrm/tags'
|
||||
|
||||
const extractTx = (tx: Tx): Tx => {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
||||
create.attributes.attachedTo = ctx.objectId
|
||||
create.attributes.attachedToClass = ctx.objectClass
|
||||
create.attributes.collection = ctx.collection
|
||||
return create
|
||||
}
|
||||
return ctx.tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@
|
||||
import core, { Doc, Tx, TxCreateDoc, TxProcessor, TxUpdateDoc } from '@anticrm/core'
|
||||
import login from '@anticrm/login'
|
||||
import { getMetadata } from '@anticrm/platform'
|
||||
import { TriggerControl } from '@anticrm/server-core'
|
||||
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
||||
import task, { Issue, Task } from '@anticrm/task'
|
||||
import view from '@anticrm/view'
|
||||
@ -43,11 +43,12 @@ export function issueTextPresenter (doc: Doc): string {
|
||||
* @public
|
||||
*/
|
||||
export async function OnTaskCreate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||
if (tx._class !== core.class.TxCreateDoc) {
|
||||
const actualTx = extractTx(tx)
|
||||
if (actualTx._class !== core.class.TxCreateDoc) {
|
||||
return []
|
||||
}
|
||||
|
||||
const createTx = tx as TxCreateDoc<Task>
|
||||
const createTx = actualTx as TxCreateDoc<Task>
|
||||
|
||||
if (!control.hierarchy.isDerived(createTx.objectClass, task.class.Task)) {
|
||||
return []
|
||||
@ -89,11 +90,12 @@ export async function OnTaskCreate (tx: Tx, control: TriggerControl): Promise<Tx
|
||||
* @public
|
||||
*/
|
||||
export async function OnTaskUpdate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||
if (tx._class !== core.class.TxUpdateDoc) {
|
||||
const actualTx = extractTx(tx)
|
||||
if (actualTx._class !== core.class.TxUpdateDoc) {
|
||||
return []
|
||||
}
|
||||
|
||||
const updateTx = tx as TxUpdateDoc<Task>
|
||||
const updateTx = actualTx as TxUpdateDoc<Task>
|
||||
|
||||
if (!control.hierarchy.isDerived(updateTx.objectClass, task.class.Task)) {
|
||||
return []
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import contact, { Channel } from '@anticrm/contact'
|
||||
import core, {
|
||||
AttachedDoc,
|
||||
Class,
|
||||
Doc,
|
||||
DocumentQuery,
|
||||
@ -24,29 +23,12 @@ import core, {
|
||||
Hierarchy,
|
||||
Ref,
|
||||
Tx,
|
||||
TxCollectionCUD,
|
||||
TxCreateDoc,
|
||||
TxProcessor
|
||||
} from '@anticrm/core'
|
||||
import { TriggerControl } from '@anticrm/server-core'
|
||||
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||
import telegram, { TelegramMessage } from '@anticrm/telegram'
|
||||
|
||||
const extractTx = (tx: Tx): Tx => {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
||||
create.attributes.attachedTo = ctx.objectId
|
||||
create.attributes.attachedToClass = ctx.objectClass
|
||||
create.attributes.collection = ctx.collection
|
||||
return create
|
||||
}
|
||||
return ctx.tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
|
@ -19,4 +19,5 @@ export * from './types'
|
||||
export * from './fulltext'
|
||||
export * from './storage'
|
||||
export * from './pipeline'
|
||||
export * from './utils'
|
||||
export { default } from './plugin'
|
||||
|
@ -52,6 +52,7 @@ import { FullTextIndex } from './fulltext'
|
||||
import serverCore from './plugin'
|
||||
import { Triggers } from './triggers'
|
||||
import type { FullTextAdapter, FullTextAdapterFactory, ObjectDDParticipant } from './types'
|
||||
import { extractTx } from './utils'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -230,17 +231,8 @@ class TServerStorage implements ServerStorage {
|
||||
return doc
|
||||
}
|
||||
|
||||
extractTx (tx: Tx): Tx {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
return ctx.tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
||||
|
||||
async processRemove (ctx: MeasureContext, tx: Tx): Promise<Tx[]> {
|
||||
const actualTx = this.extractTx(tx)
|
||||
const actualTx = extractTx(tx)
|
||||
if (!this.hierarchy.isDerived(actualTx._class, core.class.TxRemoveDoc)) return []
|
||||
const rtx = actualTx as TxRemoveDoc<Doc>
|
||||
const result: Tx[] = []
|
||||
@ -316,7 +308,7 @@ class TServerStorage implements ServerStorage {
|
||||
}
|
||||
|
||||
async processMove (ctx: MeasureContext, tx: Tx): Promise<Tx[]> {
|
||||
const actualTx = this.extractTx(tx)
|
||||
const actualTx = extractTx(tx)
|
||||
if (!this.hierarchy.isDerived(actualTx._class, core.class.TxUpdateDoc)) return []
|
||||
const rtx = actualTx as TxUpdateDoc<Doc>
|
||||
if (rtx.operations.space === undefined || rtx.operations.space === rtx.objectSpace) return []
|
||||
|
20
server/core/src/utils.ts
Normal file
20
server/core/src/utils.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import core, { AttachedDoc, Doc, Tx, TxCollectionCUD, TxCreateDoc } from '@anticrm/core'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function extractTx (tx: Tx): Tx {
|
||||
if (tx._class === core.class.TxCollectionCUD) {
|
||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
||||
create.attributes.attachedTo = ctx.objectId
|
||||
create.attributes.attachedToClass = ctx.objectClass
|
||||
create.attributes.collection = ctx.collection
|
||||
return create
|
||||
}
|
||||
return ctx.tx
|
||||
}
|
||||
|
||||
return tx
|
||||
}
|
Loading…
Reference in New Issue
Block a user