diff --git a/models/core/src/tx.ts b/models/core/src/tx.ts index 67cb95d663..218b1b8118 100644 --- a/models/core/src/tx.ts +++ b/models/core/src/tx.ts @@ -101,6 +101,9 @@ export class TTxApplyIf extends TTx implements TxApplyIf { // All matches should be false for all documents. notMatch!: DocumentClassQuery[] txes!: TxCUD[] + + notify!: boolean + extraNotify!: Ref>[] } @Model(core.class.TxWorkspaceEvent, core.class.Doc) diff --git a/models/recruit/src/migration.ts b/models/recruit/src/migration.ts index 20ebfc6eea..8fe9425bfa 100644 --- a/models/recruit/src/migration.ts +++ b/models/recruit/src/migration.ts @@ -55,6 +55,28 @@ export const recruitOperation: MigrateOperation = { } }) } + }, + { + state: 'wrong-categories', + func: async (client): Promise => { + const ops = new TxOperations(client, core.account.System) + while (true) { + const docs = await ops.findAll( + tags.class.TagElement, + { + targetClass: recruit.mixin.Candidate, + category: { $in: [tracker.category.Other, 'document:category:Other' as Ref] } + }, + { limit: 1000 } + ) + for (const d of docs) { + await ops.update(d, { category: recruit.category.Other }) + } + if (docs.length === 0) { + break + } + } + } } ]) } diff --git a/models/server-tracker/src/index.ts b/models/server-tracker/src/index.ts index c4c80b72bc..ce7464fa2c 100644 --- a/models/server-tracker/src/index.ts +++ b/models/server-tracker/src/index.ts @@ -43,8 +43,8 @@ export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverTracker.trigger.OnComponentRemove, txMatch: { - _class: core.class.TxCollectionCUD, - 'tx._class': core.class.TxCreateDoc + _class: core.class.TxRemoveDoc, + objectClass: tracker.class.Component } }) diff --git a/packages/core/src/operations.ts b/packages/core/src/operations.ts index 56fbc4223f..1f4a33ca66 100644 --- a/packages/core/src/operations.ts +++ b/packages/core/src/operations.ts @@ -441,10 +441,18 @@ export class ApplyOperations extends TxOperations { return this } - async commit (): Promise { + async commit (notify: boolean = true, extraNotify: Ref>[] = []): Promise { if (this.txes.length > 0) { return await ((await this.ops.tx( - this.ops.txFactory.createTxApplyIf(core.space.Tx, this.scope, this.matches, this.notMatches, this.txes) + this.ops.txFactory.createTxApplyIf( + core.space.Tx, + this.scope, + this.matches, + this.notMatches, + this.txes, + notify, + extraNotify + ) )) as Promise) } return true diff --git a/packages/core/src/tx.ts b/packages/core/src/tx.ts index 540bcfb00f..9905fce3f8 100644 --- a/packages/core/src/tx.ts +++ b/packages/core/src/tx.ts @@ -51,16 +51,17 @@ export enum WorkspaceEvent { Upgrade, IndexingUpdate, SecurityChange, - MaintenanceNotification + MaintenanceNotification, + BulkUpdate } /** * Event to be send by server during model upgrade procedure. * @public */ -export interface TxWorkspaceEvent extends Tx { +export interface TxWorkspaceEvent extends Tx { event: WorkspaceEvent - params: any + params: T } /** @@ -70,6 +71,13 @@ export interface IndexingUpdateEvent { _class: Ref>[] } +/** + * @public + */ +export interface BulkUpdateEvent { + _class: Ref>[] +} + /** * @public */ @@ -125,6 +133,11 @@ export interface TxApplyIf extends Tx { // If all matched execute following transactions. txes: TxCUD[] + + notify?: boolean // If false will not send notifications. + + // If passed, will send WorkspaceEvent.BulkUpdate event with list of classes to update + extraNotify?: Ref>[] } /** @@ -591,6 +604,8 @@ export class TxFactory { match: DocumentClassQuery[], notMatch: DocumentClassQuery[], txes: TxCUD[], + notify: boolean = true, + extraNotify: Ref>[] = [], modifiedOn?: Timestamp, modifiedBy?: Ref ): TxApplyIf { @@ -604,7 +619,9 @@ export class TxFactory { scope, match, notMatch, - txes + txes, + notify, + extraNotify } } } diff --git a/packages/presentation/src/components/DocPopup.svelte b/packages/presentation/src/components/DocPopup.svelte index f97926fcd5..312bf8f1f1 100644 --- a/packages/presentation/src/components/DocPopup.svelte +++ b/packages/presentation/src/components/DocPopup.svelte @@ -24,6 +24,7 @@ IconCheck, IconSearch, ListView, + Spinner, createFocusManager, deviceOptionsStore, resizeObserver, @@ -59,6 +60,7 @@ export let disallowDeselect: Ref[] | undefined = undefined export let created: Doc[] = [] export let embedded: boolean = false + export let loading = false let search: string = '' @@ -185,7 +187,7 @@ icon={IconAdd} showTooltip={{ label: create.label }} on:click={onCreate} - disabled={readonly} + disabled={readonly || loading} /> {/if} @@ -210,20 +212,24 @@ {@const isDeselectDisabled = selectedElements.has(obj._id) && forbiddenDeselectItemIds.has(obj._id)}