From a224a154e53b3b2cf050950addab33fb2cbe41a3 Mon Sep 17 00:00:00 2001 From: Alex <41288429+Dvinyanin@users.noreply.github.com> Date: Fri, 27 May 2022 23:43:11 +0700 Subject: [PATCH] Use tags for card labels (#1888) --- models/board/package.json | 4 +- models/board/src/index.ts | 25 +---- models/board/src/migration.ts | 100 +++++++++++++++++- models/server-board/src/index.ts | 10 +- models/task/package.json | 3 +- models/task/src/index.ts | 8 +- plugins/board-resources/package.json | 3 +- .../src/components/CreateCard.svelte | 1 - .../src/components/TableView.svelte | 2 +- .../src/components/add-card/AddCard.svelte | 1 - .../src/components/editor/CardLabels.svelte | 20 ++-- .../components/popups/CardLabelsEditor.svelte | 99 +++++------------ .../components/popups/CardLabelsPicker.svelte | 92 ++++++---------- .../components/popups/CardLabelsPopup.svelte | 14 +-- .../src/components/popups/CopyCard.svelte | 6 +- .../src/components/popups/MoveCard.svelte | 2 - .../presenters/LabelPresenter.svelte | 6 +- .../board-resources/src/utils/BoardUtils.ts | 81 +++----------- .../board-resources/src/utils/CardUtils.ts | 1 - plugins/board/package.json | 3 +- plugins/board/src/index.ts | 18 +--- plugins/task/src/index.ts | 2 +- server-plugins/board-resources/src/index.ts | 45 +------- server-plugins/board/src/index.ts | 9 +- 24 files changed, 214 insertions(+), 341 deletions(-) diff --git a/models/board/package.json b/models/board/package.json index 9e5c009e9c..7f307c17ac 100644 --- a/models/board/package.json +++ b/models/board/package.json @@ -42,6 +42,8 @@ "@anticrm/task": "~0.6.0", "@anticrm/model-task": "~0.6.0", "@anticrm/workbench": "~0.6.1", - "@anticrm/model-preference": "~0.6.0" + "@anticrm/model-preference": "~0.6.0", + "@anticrm/tags": "~0.6.2", + "@anticrm/model-tags": "~0.6.0" } } diff --git a/models/board/src/index.ts b/models/board/src/index.ts index cca9e9217f..fed8b95629 100644 --- a/models/board/src/index.ts +++ b/models/board/src/index.ts @@ -14,7 +14,7 @@ // // To help typescript locate view plugin properly -import type { Board, Card, CardLabel, MenuPage, CommonBoardPreference, CardCover } from '@anticrm/board' +import type { Board, Card, MenuPage, CommonBoardPreference, CardCover } from '@anticrm/board' import type { Employee } from '@anticrm/contact' import { DOMAIN_MODEL, IndexKind, Markup, Ref, Type } from '@anticrm/core' import { @@ -33,7 +33,7 @@ import { import attachment from '@anticrm/model-attachment' import chunter from '@anticrm/model-chunter' import contact from '@anticrm/model-contact' -import core, { TAttachedDoc, TDoc, TType } from '@anticrm/model-core' +import core, { TDoc, TType } from '@anticrm/model-core' import task, { TSpaceWithStates, TTask } from '@anticrm/model-task' import view, { actionTemplates, createAction } from '@anticrm/model-view' import workbench, { Application } from '@anticrm/model-workbench' @@ -49,14 +49,6 @@ export class TBoard extends TSpaceWithStates implements Board { background!: string } -@Model(board.class.CardLabel, core.class.AttachedDoc, DOMAIN_MODEL) -@UX(board.string.Labels) -export class TCardLabel extends TAttachedDoc implements CardLabel { - title!: string - color!: number - isHidden?: boolean -} - function TypeCardCover (): Type { return { _class: board.class.CardCover, label: board.string.Cover } } @@ -90,9 +82,6 @@ export class TCard extends TTask implements Card { @Index(IndexKind.FullText) description!: Markup - @Prop(Collection(board.class.CardLabel), board.string.Labels) - labels!: Ref[] - @Prop(TypeString(), board.string.Location) @Index(IndexKind.FullText) location?: string @@ -121,7 +110,7 @@ export class TMenuPage extends TDoc implements MenuPage { } export function createModel (builder: Builder): void { - builder.createModel(TBoard, TCard, TCardLabel, TMenuPage, TCommonBoardPreference, TCardCover) + builder.createModel(TBoard, TCard, TMenuPage, TCommonBoardPreference, TCardCover) builder.createDoc(board.class.MenuPage, core.space.Model, { component: board.component.Archive, @@ -216,14 +205,6 @@ export function createModel (builder: Builder): void { presenter: board.component.CardPresenter }) - builder.mixin(board.class.CardLabel, core.class.Class, view.mixin.AttributePresenter, { - presenter: board.component.CardLabelPresenter - }) - - builder.mixin(board.class.CardLabel, core.class.Class, view.mixin.CollectionPresenter, { - presenter: board.component.CardLabelPresenter - }) - builder.mixin(board.class.Board, core.class.Class, view.mixin.AttributePresenter, { presenter: board.component.BoardPresenter }) diff --git a/models/board/src/migration.ts b/models/board/src/migration.ts index 41b1ebe30d..39c297ad06 100644 --- a/models/board/src/migration.ts +++ b/models/board/src/migration.ts @@ -13,12 +13,29 @@ // limitations under the License. // -import { Doc, Ref, Space, TxOperations } from '@anticrm/core' -import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@anticrm/model' +import { + AttachedDoc, + Class, + Doc, + DOMAIN_TX, + generateId, + Ref, + Space, + TxCollectionCUD, + TxCreateDoc, + TxCUD, + TxOperations, + TxProcessor, + TxUpdateDoc +} from '@anticrm/core' +import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@anticrm/model' import core from '@anticrm/model-core' import { createKanbanTemplate, createSequence, DOMAIN_TASK } from '@anticrm/model-task' import task, { createKanban, KanbanTemplate } from '@anticrm/task' +import { DOMAIN_TAGS } from '@anticrm/model-tags' +import tags, { TagElement, TagReference } from '@anticrm/tags' import board from './plugin' +import { Board, Card } from '@anticrm/board' async function createSpace (tx: TxOperations): Promise { const current = await tx.findOne(core.class.Space, { @@ -74,12 +91,87 @@ async function createDefaults (tx: TxOperations): Promise { await createSpace(tx) await createSequence(tx, board.class.Card) await createDefaultKanban(tx) + await createOrUpdate( + tx, + tags.class.TagCategory, + tags.space.Tags, + { + icon: tags.icon.Tags, + label: 'Other', + targetClass: board.class.Card, + tags: [], + default: true + }, + board.category.Other + ) } +interface CardLabel extends AttachedDoc { + title: string + color: number + isHidden?: boolean +} async function migrateLabels (client: MigrationClient): Promise { - const cards = await client.find(DOMAIN_TASK, { _class: board.class.Card, labels: { $exists: false, $in: [null] } }) + const objectClass = 'board:class:CardLabel' as Ref> + const txes = await client.find>(DOMAIN_TX, { objectClass }, { sort: { modifiedOn: 1 } }) + const collectionTxes = await client.find>( + DOMAIN_TX, + { 'tx.objectClass': objectClass }, + { sort: { modifiedOn: 1 } } + ) + await Promise.all([...txes, ...collectionTxes].map(({ _id }) => client.delete(DOMAIN_TX, _id))) + const removed = txes.filter(({ _class }) => _class === core.class.TxRemoveDoc).map(({ objectId }) => objectId) + const createTxes = txes.filter( + ({ _class, objectId }) => _class === core.class.TxCreateDoc && !removed.includes(objectId) + ) as unknown as TxCreateDoc[] + const cardLabels = createTxes.map((createTx) => { + const cardLabel = TxProcessor.createDoc2Doc(createTx) + const updateTxes = collectionTxes + .map(({ tx }) => tx) + .filter( + ({ _class, objectId }) => _class === core.class.TxUpdateDoc && objectId === createTx.objectId + ) as unknown as TxUpdateDoc[] + return updateTxes.reduce((label, updateTx) => TxProcessor.updateDoc2Doc(label, updateTx), cardLabel) + }) + await Promise.all( + cardLabels.map((cardLabel) => + client.create(DOMAIN_TAGS, { + _class: tags.class.TagElement, + space: tags.space.Tags, + targetClass: board.class.Card, + category: board.category.Other, + _id: cardLabel._id as unknown as Ref, + modifiedBy: cardLabel.modifiedBy, + modifiedOn: cardLabel.modifiedOn, + title: cardLabel.title, + color: cardLabel.color, + description: '' + }) + ) + ) + const cards = (await client.find(DOMAIN_TASK, { _class: board.class.Card })).filter((card) => + Array.isArray(card.labels) + ) for (const card of cards) { - await client.update(DOMAIN_TASK, { _id: card._id }, { labels: [] }) + const labelRefs = card.labels as unknown as Array> + await client.update(DOMAIN_TASK, { _id: card._id }, { labels: labelRefs.length }) + for (const labelRef of labelRefs) { + const cardLabel = cardLabels.find(({ _id }) => _id === labelRef) + if (cardLabel === undefined) continue + await client.create(DOMAIN_TAGS, { + _class: tags.class.TagReference, + attachedToClass: board.class.Card, + _id: generateId(), + attachedTo: card._id, + space: card.space, + tag: cardLabel._id as unknown as Ref, + title: cardLabel.title, + color: cardLabel.color, + modifiedBy: cardLabel.modifiedBy, + modifiedOn: cardLabel.modifiedOn, + collection: 'labels' + }) + } } } diff --git a/models/server-board/src/index.ts b/models/server-board/src/index.ts index d5b1302419..dbb6b28220 100644 --- a/models/server-board/src/index.ts +++ b/models/server-board/src/index.ts @@ -15,12 +15,4 @@ import { Builder } from '@anticrm/model' -import serverCore from '@anticrm/server-core' -import core from '@anticrm/core' -import serverBoard from '@anticrm/server-board' - -export function createModel (builder: Builder): void { - builder.createDoc(serverCore.class.Trigger, core.space.Model, { - trigger: serverBoard.trigger.OnLabelDelete - }) -} +export function createModel (builder: Builder): void {} diff --git a/models/task/package.json b/models/task/package.json index 14c5cd0e0f..6ae191dce4 100644 --- a/models/task/package.json +++ b/models/task/package.json @@ -40,6 +40,7 @@ "@anticrm/model-chunter": "~0.6.0", "@anticrm/workbench": "~0.6.1", "@anticrm/view": "~0.6.0", - "@anticrm/model-presentation": "~0.6.0" + "@anticrm/model-presentation": "~0.6.0", + "@anticrm/tags": "~0.6.2" } } diff --git a/models/task/src/index.ts b/models/task/src/index.ts index 30268d5526..5df0e205e4 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -60,6 +60,7 @@ import { WonStateTemplate } from '@anticrm/task' import { AnyComponent } from '@anticrm/ui' +import tags from '@anticrm/tags' import task from './plugin' export { createKanbanTemplate, createSequence, taskOperation } from './migration' @@ -123,6 +124,9 @@ export class TTask extends TAttachedDoc implements Task { @Prop(Collection(task.class.TodoItem), task.string.Todos) todoItems!: number + + @Prop(Collection(tags.class.TagReference, task.string.TaskLabels), task.string.TaskLabels) + labels!: number } @Model(task.class.TodoItem, core.class.AttachedDoc, DOMAIN_TASK, [task.interface.DocWithRank]) @@ -175,10 +179,6 @@ export class TIssue extends TTask implements Issue { @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments!: number - @Prop(TypeString(), task.string.TaskLabels) - @Index(IndexKind.FullText) - labels!: string - @Prop(TypeRef(contact.class.Employee), task.string.TaskAssignee) declare assignee: Ref | null } diff --git a/plugins/board-resources/package.json b/plugins/board-resources/package.json index 8902214a69..c156c991e3 100644 --- a/plugins/board-resources/package.json +++ b/plugins/board-resources/package.json @@ -54,6 +54,7 @@ "@anticrm/workbench": "~0.6.1", "svelte": "^3.47", "@anticrm/kanban": "~0.6.0", - "@anticrm/preference": "~0.6.0" + "@anticrm/preference": "~0.6.0", + "@anticrm/tags": "~0.6.2" } } diff --git a/plugins/board-resources/src/components/CreateCard.svelte b/plugins/board-resources/src/components/CreateCard.svelte index 9c95e618fb..69fdc630e3 100644 --- a/plugins/board-resources/src/components/CreateCard.svelte +++ b/plugins/board-resources/src/components/CreateCard.svelte @@ -65,7 +65,6 @@ assignee: null, description: '', members: [], - labels: [], location: '', startDate: null, dueDate: null diff --git a/plugins/board-resources/src/components/TableView.svelte b/plugins/board-resources/src/components/TableView.svelte index 67f36533e8..b95019dd43 100644 --- a/plugins/board-resources/src/components/TableView.svelte +++ b/plugins/board-resources/src/components/TableView.svelte @@ -12,7 +12,7 @@ const isArchived = { $nin: [true] } const query = createQuery() - let states: Ref[] + let states: Ref[] = [] $: query.query(task.class.State, { space, isArchived }, (result) => { states = result.map(({ _id }) => _id) }) diff --git a/plugins/board-resources/src/components/add-card/AddCard.svelte b/plugins/board-resources/src/components/add-card/AddCard.svelte index 0f7cc32ec6..52e63a9355 100644 --- a/plugins/board-resources/src/components/add-card/AddCard.svelte +++ b/plugins/board-resources/src/components/add-card/AddCard.svelte @@ -52,7 +52,6 @@ assignee: null, description: '', members: [], - labels: [], location: '', startDate: null, dueDate: null diff --git a/plugins/board-resources/src/components/editor/CardLabels.svelte b/plugins/board-resources/src/components/editor/CardLabels.svelte index c2de08ea5b..d315510b88 100644 --- a/plugins/board-resources/src/components/editor/CardLabels.svelte +++ b/plugins/board-resources/src/components/editor/CardLabels.svelte @@ -13,8 +13,9 @@ // limitations under the License. --> @@ -118,10 +76,16 @@
{#each colorGroups as colorGroup}
- {#each colorGroup as color} + {#each colorGroup as c}
- selectColor(color)}> - {#if selected.color === color} + { + color = c + }} + > + {#if c === color}
@@ -131,27 +95,12 @@ {/each}
{/each} -
-
- selectColor(hiddenColor, true)}> - {#if selected.isHidden} -
- -
- {/if} -
-
-
-
-
-
-
diff --git a/plugins/board-resources/src/components/popups/CardLabelsPicker.svelte b/plugins/board-resources/src/components/popups/CardLabelsPicker.svelte index 92e1a04b08..0ed43f20b8 100644 --- a/plugins/board-resources/src/components/popups/CardLabelsPicker.svelte +++ b/plugins/board-resources/src/components/popups/CardLabelsPicker.svelte @@ -1,7 +1,8 @@
@@ -95,17 +76,12 @@
- applySearch()} - /> +
- {#each filteredLabels as label} + {#each labels as label}
{ @@ -127,8 +103,8 @@ style:box-shadow={hovered === label._id ? `-0.4rem 0 ${numberToRGB(label.color, 0.6)}` : ''} on:click={() => toggle(label)} > - {label.title ?? ''} - {#if object?.labels?.includes(label._id)} + {label.title} + {#if cardLabelRefs.includes(label._id)}
diff --git a/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte b/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte index 183a65b0f5..e6cda8b53c 100644 --- a/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte +++ b/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte @@ -1,5 +1,6 @@ {#if editMode.isEdit} - setEditMode(false, undefined)} - /> + setEditMode(false, undefined)} /> {:else} = { state: selected.state, doneState: null, @@ -52,7 +48,7 @@ description: '', members: [], location: '', - labels: labels ?? [], + labels: value.labels, startDate: value.startDate, dueDate: value.dueDate } diff --git a/plugins/board-resources/src/components/popups/MoveCard.svelte b/plugins/board-resources/src/components/popups/MoveCard.svelte index dc63d32ec4..24f541cf95 100644 --- a/plugins/board-resources/src/components/popups/MoveCard.svelte +++ b/plugins/board-resources/src/components/popups/MoveCard.svelte @@ -10,7 +10,6 @@ import SpaceSelect from '../selectors/SpaceSelect.svelte' import StateSelect from '../selectors/StateSelect.svelte' import RankSelect from '../selectors/RankSelect.svelte' - import { createMissingLabels } from '../../utils/BoardUtils' export let value: Card @@ -28,7 +27,6 @@ const update: DocumentUpdate = {} if (selected.space !== value.space) { - update.labels = await createMissingLabels(client, value, selected.space) update.space = selected.space } diff --git a/plugins/board-resources/src/components/presenters/LabelPresenter.svelte b/plugins/board-resources/src/components/presenters/LabelPresenter.svelte index 5f79d1be27..862d8beb0c 100644 --- a/plugins/board-resources/src/components/presenters/LabelPresenter.svelte +++ b/plugins/board-resources/src/components/presenters/LabelPresenter.svelte @@ -1,8 +1,8 @@ @@ -10,7 +10,7 @@ {#if value} {#if size !== 'tiny'} -
{value.title ?? ''}
+
{value.title}
{/if}
{/if} diff --git a/plugins/board-resources/src/utils/BoardUtils.ts b/plugins/board-resources/src/utils/BoardUtils.ts index 689d6e9b52..ef3ad992e3 100644 --- a/plugins/board-resources/src/utils/BoardUtils.ts +++ b/plugins/board-resources/src/utils/BoardUtils.ts @@ -1,12 +1,12 @@ import { readable } from 'svelte/store' -import board, { Board, CardLabel, Card, CommonBoardPreference } from '@anticrm/board' -import core, { Ref, TxOperations, Space } from '@anticrm/core' +import board, { Board, Card, CommonBoardPreference } from '@anticrm/board' +import core, { Ref, TxOperations } from '@anticrm/core' import type { KanbanTemplate, TodoItem } from '@anticrm/task' import preference from '@anticrm/preference' +import tags, { TagElement } from '@anticrm/tags' import { createKanban } from '@anticrm/task' import { createQuery, getClient } from '@anticrm/presentation' import { - hexColorToNumber, FernColor, FlamingoColor, MalibuColor, @@ -34,14 +34,10 @@ export async function createBoard ( members: [] }) - await Promise.all([createBoardLabels(client, boardRef), createKanban(client, boardRef, templateId)]) + await Promise.all([createKanban(client, boardRef, templateId)]) return boardRef } -export async function getBoardLabels (client: TxOperations, boardRef: Ref): Promise { - return await client.findAll(board.class.CardLabel, { attachedTo: boardRef }) -} - export function getBoardAvailableColors (): string[] { return [ FernColor, @@ -57,71 +53,26 @@ export function getBoardAvailableColors (): string[] { ] } -export async function createBoardLabels (client: TxOperations, boardRef: Ref): Promise { - await Promise.all([ - createCardLabel(client, boardRef, hexColorToNumber(FernColor)), - createCardLabel(client, boardRef, hexColorToNumber(SeaBuckthornColor)), - createCardLabel(client, boardRef, hexColorToNumber(FlamingoColor)), - createCardLabel(client, boardRef, hexColorToNumber(MalibuColor)), - createCardLabel(client, boardRef, hexColorToNumber(MoodyBlueColor)) - ]) -} - export async function createCardLabel ( client: TxOperations, - boardRef: Ref, - color: number, - title?: string, - isHidden?: boolean + { title, color }: { title: string, color: number } ): Promise { - await client.createDoc(board.class.CardLabel, core.space.Model, { - attachedTo: boardRef, - attachedToClass: board.class.Board, - collection: 'labels', + await client.createDoc(tags.class.TagElement, tags.space.Tags, { + title, color, - title: title ?? '', - isHidden: isHidden ?? false + targetClass: board.class.Card, + description: '', + category: board.category.Other }) } -const isEqualLabel = (l1: CardLabel, l2: CardLabel): boolean => - l1.title === l2.title && l1.color === l2.color && (l1.isHidden ?? false) === (l2.isHidden ?? false) - -export async function createMissingLabels ( - client: TxOperations, - object: Card, - targetBoard: Ref -): Promise> | undefined> { - const sourceBoardLabels = await getBoardLabels(client, object.space) - const targetBoardLabels = await getBoardLabels(client, targetBoard) - - const missingLabels = sourceBoardLabels.filter((srcLabel) => { - if (!object.labels?.includes(srcLabel._id)) return false - - return targetBoardLabels.findIndex((targetLabel) => isEqualLabel(targetLabel, srcLabel)) === -1 +export async function addCardLabel (client: TxOperations, card: Card, label: TagElement): Promise { + const { title, color, _id: tag } = label + await client.addCollection(tags.class.TagReference, card.space, card._id, card._class, 'labels', { + title, + color, + tag }) - - await Promise.all( - missingLabels.map(async (l) => await createCardLabel(client, targetBoard, l.color, l.title, l.isHidden)) - ) - - const updatedTargetBoardLabels = await getBoardLabels(client, targetBoard) - - const labelsUpdate = object.labels - ?.map((srcLabelId) => { - const srcLabel = sourceBoardLabels.find((l) => l._id === srcLabelId) - - if (srcLabel === undefined) return null - - const targetLabel = updatedTargetBoardLabels.find((l) => isEqualLabel(l, srcLabel)) - - if (targetLabel === undefined) return null - - return targetLabel._id - }) - .filter((l) => l !== null) as Array> | undefined - - return labelsUpdate } export function getDateIcon (item: TodoItem): 'normal' | 'warning' | 'overdue' { diff --git a/plugins/board-resources/src/utils/CardUtils.ts b/plugins/board-resources/src/utils/CardUtils.ts index 02d5a54182..7aff8086b7 100644 --- a/plugins/board-resources/src/utils/CardUtils.ts +++ b/plugins/board-resources/src/utils/CardUtils.ts @@ -37,7 +37,6 @@ export async function createCard ( rank: calcRank(lastOne, undefined), assignee: null, description: '', - labels: [], ...attribues } diff --git a/plugins/board/package.json b/plugins/board/package.json index 0be201679e..68e0229345 100644 --- a/plugins/board/package.json +++ b/plugins/board/package.json @@ -32,6 +32,7 @@ "@anticrm/view": "~0.6.0", "@anticrm/task": "~0.6.0", "@anticrm/ui": "~0.6.0", - "@anticrm/preference": "~0.6.0" + "@anticrm/preference": "~0.6.0", + "@anticrm/tags": "~0.6.2" } } diff --git a/plugins/board/src/index.ts b/plugins/board/src/index.ts index ba54ef66d6..c765af778c 100644 --- a/plugins/board/src/index.ts +++ b/plugins/board/src/index.ts @@ -15,13 +15,14 @@ // import { Employee } from '@anticrm/contact' -import type { AttachedDoc, Class, Doc, Markup, Ref, Type } from '@anticrm/core' +import type { Class, Doc, Markup, Ref, Type } from '@anticrm/core' import type { Asset, IntlString, Plugin } from '@anticrm/platform' import { plugin } from '@anticrm/platform' import type { Preference } from '@anticrm/preference' import type { DoneState, KanbanTemplateSpace, SpaceWithStates, Task } from '@anticrm/task' import type { AnyComponent } from '@anticrm/ui' import { Action, ActionCategory } from '@anticrm/view' +import { TagCategory } from '@anticrm/tags' /** * @public @@ -40,15 +41,6 @@ export interface BoardView extends SpaceWithStates { boards: Ref[] } -/** - * @public - */ -export interface CardLabel extends AttachedDoc { - title: string - color: number - isHidden?: boolean -} - /** * @public */ @@ -68,8 +60,6 @@ export interface Card extends Task { members?: Ref[] - labels: Ref[] - location?: string cover?: CardCover | null @@ -108,13 +98,13 @@ const boards = plugin(boardId, { class: { Board: '' as Ref>, Card: '' as Ref>, - CardLabel: '' as Ref>, MenuPage: '' as Ref>, CommonBoardPreference: '' as Ref>, CardCover: '' as Ref>> }, category: { - Card: '' as Ref + Card: '' as Ref, + Other: '' as Ref }, state: { Completed: '' as Ref diff --git a/plugins/task/src/index.ts b/plugins/task/src/index.ts index b938c6650d..5e79d82f16 100644 --- a/plugins/task/src/index.ts +++ b/plugins/task/src/index.ts @@ -84,6 +84,7 @@ export interface Task extends AttachedDoc, DocWithRank { dueDate: Timestamp | null startDate: Timestamp | null todoItems?: number + labels?: number } /** @@ -116,7 +117,6 @@ export interface Issue extends Task { comments?: number attachments?: number - labels?: string } /** diff --git a/server-plugins/board-resources/src/index.ts b/server-plugins/board-resources/src/index.ts index 5819c5f260..389be6faa8 100644 --- a/server-plugins/board-resources/src/index.ts +++ b/server-plugins/board-resources/src/index.ts @@ -13,48 +13,5 @@ // limitations under the License. // -import type { Tx, TxCreateDoc, TxRemoveDoc } from '@anticrm/core' -import type { TriggerControl } from '@anticrm/server-core' -import type { Card, CardLabel } from '@anticrm/board' -import board from '@anticrm/board' -import core, { TxProcessor } from '@anticrm/core' - -/** - * @public - */ -export async function OnLabelDelete (tx: Tx, { findAll, hierarchy, txFactory }: TriggerControl): Promise { - if (tx._class !== core.class.TxRemoveDoc) { - return [] - } - - const rmTx = tx as TxRemoveDoc - if (!hierarchy.isDerived(rmTx.objectClass, board.class.CardLabel)) { - return [] - } - - const createTx = ( - await findAll( - core.class.TxCreateDoc, - { - objectId: rmTx.objectId - }, - { limit: 1 } - ) - )[0] - if (createTx === undefined) { - return [] - } - - const label = TxProcessor.createDoc2Doc(createTx as TxCreateDoc) - const cards = await findAll(board.class.Card, { space: label.attachedTo as any, labels: label._id }) - return cards.map((card) => - txFactory.createTxUpdateDoc(card._class, card.space, card._id, { $pull: { labels: label._id as any } }) - ) -} - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -export default async () => ({ - trigger: { - OnLabelDelete - } -}) +export default async () => ({}) diff --git a/server-plugins/board/src/index.ts b/server-plugins/board/src/index.ts index 82c87ced4f..2af3cb1bd3 100644 --- a/server-plugins/board/src/index.ts +++ b/server-plugins/board/src/index.ts @@ -13,9 +13,8 @@ // limitations under the License. // -import type { Resource, Plugin } from '@anticrm/platform' +import type { Plugin } from '@anticrm/platform' import { plugin } from '@anticrm/platform' -import type { TriggerFunc } from '@anticrm/server-core' /** * @public @@ -25,8 +24,4 @@ export const serverBoardId = 'server-board' as Plugin /** * @public */ -export default plugin(serverBoardId, { - trigger: { - OnLabelDelete: '' as Resource - } -}) +export default plugin(serverBoardId, {})