From c190b1c079f9f76b129371de5f25c3cf7ee58146 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Sat, 2 Nov 2024 08:23:08 +0500 Subject: [PATCH] Workslot fixes (#7084) --- models/server-time/src/index.ts | 15 +++++++- .../src/components/WorkSlotElement.svelte | 12 ++++--- server-plugins/recruit-resources/src/index.ts | 30 +++++++--------- server-plugins/time-resources/src/index.ts | 34 ++++++++++++++++++- server-plugins/time/src/index.ts | 3 +- server-plugins/view-resources/src/index.ts | 5 ++- 6 files changed, 71 insertions(+), 28 deletions(-) diff --git a/models/server-time/src/index.ts b/models/server-time/src/index.ts index 59b0cb3cb0..152eacf9f0 100644 --- a/models/server-time/src/index.ts +++ b/models/server-time/src/index.ts @@ -21,7 +21,7 @@ import { type Resource } from '@hcengineering/platform' import serverCore, { type TriggerControl } from '@hcengineering/server-core' import tracker from '@hcengineering/tracker' import serverTime, { type ToDoFactory, type OnToDo } from '@hcengineering/server-time' -import { type ToDo, type WorkSlot } from '@hcengineering/time' +import time, { type ToDo, type WorkSlot } from '@hcengineering/time' @Mixin(serverTime.mixin.ToDoFactory, core.class.Class) export class TToDoFactory extends TClass implements ToDoFactory { @@ -45,6 +45,7 @@ export function createModel (builder: Builder): void { trigger: serverTime.trigger.OnToDoUpdate, txMatch: { _class: core.class.TxCollectionCUD, + 'tx.objectClass': time.class.ToDo, 'tx._class': core.class.TxUpdateDoc } }) @@ -53,6 +54,7 @@ export function createModel (builder: Builder): void { trigger: serverTime.trigger.OnToDoRemove, txMatch: { _class: core.class.TxCollectionCUD, + 'tx.objectClass': time.class.ToDo, 'tx._class': core.class.TxRemoveDoc } }) @@ -61,6 +63,7 @@ export function createModel (builder: Builder): void { trigger: serverTime.trigger.OnToDoCreate, txMatch: { _class: core.class.TxCollectionCUD, + 'tx.objectClass': time.class.ToDo, 'tx._class': core.class.TxCreateDoc }, isAsync: true @@ -70,10 +73,20 @@ export function createModel (builder: Builder): void { trigger: serverTime.trigger.OnWorkSlotCreate, txMatch: { _class: core.class.TxCollectionCUD, + 'tx.objectClass': time.class.WorkSlot, 'tx._class': core.class.TxCreateDoc } }) + builder.createDoc(serverCore.class.Trigger, core.space.Model, { + trigger: serverTime.trigger.OnWorkSlotUpdate, + txMatch: { + _class: core.class.TxCollectionCUD, + 'tx.objectClass': time.class.WorkSlot, + 'tx._class': core.class.TxUpdateDoc + } + }) + builder.mixin(tracker.class.Issue, core.class.Class, serverTime.mixin.ToDoFactory, { factory: serverTime.function.IssueToDoFactory }) diff --git a/plugins/time-resources/src/components/WorkSlotElement.svelte b/plugins/time-resources/src/components/WorkSlotElement.svelte index 3218caa72e..975adcde1a 100644 --- a/plugins/time-resources/src/components/WorkSlotElement.svelte +++ b/plugins/time-resources/src/components/WorkSlotElement.svelte @@ -16,8 +16,8 @@ import { createQuery } from '@hcengineering/presentation' import { Label } from '@hcengineering/ui' import { ToDo, WorkSlot } from '@hcengineering/time' - import time from '../plugin' import ToDoPresenter from './ToDoPresenter.svelte' + import calendar from '@hcengineering/calendar' export let event: WorkSlot export let oneRow: boolean = false @@ -26,13 +26,15 @@ let todo: ToDo const query = createQuery() - $: query.query(event.attachedToClass, { _id: event.attachedTo }, (res) => { - todo = res[0] - }) + $: !hideDetails + ? query.query(event.attachedToClass, { _id: event.attachedTo }, (res) => { + todo = res[0] + }) + : query.unsubscribe() {#if hideDetails} -