From ec6bf3a1eb54fbf39df9986f06ce0c17ec03da30 Mon Sep 17 00:00:00 2001 From: Anna No Date: Sat, 9 Apr 2022 01:07:21 +0700 Subject: [PATCH] Board: Update board card model (#1329) Signed-off-by: Anna No --- models/board/src/index.ts | 25 ++++++++++----- models/board/src/plugin.ts | 2 +- plugins/board-assets/lang/en.json | 1 + plugins/board-assets/lang/ru.json | 1 + .../src/components/editor/CardActions.svelte | 32 +++++++++++-------- plugins/board-resources/src/plugin.ts | 3 +- plugins/board/package.json | 3 +- plugins/board/src/index.ts | 27 +++++++++++++--- plugins/task/src/index.ts | 1 + 9 files changed, 66 insertions(+), 29 deletions(-) diff --git a/models/board/src/index.ts b/models/board/src/index.ts index b92509ffe8..e88bf40183 100644 --- a/models/board/src/index.ts +++ b/models/board/src/index.ts @@ -15,10 +15,10 @@ // // To help typescript locate view plugin properly -import type { Board, Card, CardAction } from '@anticrm/board' +import type { Board, Card, CardAction, CardDate, CardLabel } from '@anticrm/board' import type { Employee } from '@anticrm/contact' -import { Client, Doc, DOMAIN_MODEL, FindOptions, IndexKind, Ref } from '@anticrm/core' -import { Builder, Collection, Index, Model, Prop, TypeMarkup, TypeRef, TypeString, UX } from '@anticrm/model' +import { TxOperations as Client, Doc, DOMAIN_MODEL, FindOptions, IndexKind, Ref } from '@anticrm/core' +import { Builder, Collection, Index, Model, Prop, TypeBoolean, TypeMarkup, TypeRef, TypeString, UX } from '@anticrm/model' import attachment from '@anticrm/model-attachment' import chunter from '@anticrm/model-chunter' import contact from '@anticrm/model-contact' @@ -27,7 +27,7 @@ import task, { TSpaceWithStates, TTask } from '@anticrm/model-task' import view from '@anticrm/model-view' import workbench from '@anticrm/model-workbench' import { Asset, IntlString, Resource } from '@anticrm/platform' -import type {} from '@anticrm/view' +import type { AnyComponent } from '@anticrm/ui' import board from './plugin' @Model(board.class.Board, task.class.SpaceWithStates) @@ -44,13 +44,21 @@ export class TCard extends TTask implements Card { @Index(IndexKind.FullText) title!: string + @Prop(TypeBoolean(), board.string.IsArchived) + isArchived?: boolean + + date?: CardDate + @Prop(TypeMarkup(), board.string.Description) @Index(IndexKind.FullText) description!: string + @Prop(Collection(board.class.CardLabel), board.string.Labels) + labels?: Ref[] + @Prop(TypeString(), board.string.Location) @Index(IndexKind.FullText) - location!: string + location?: string @Prop(Collection(chunter.class.Comment), chunter.string.Comments) comments?: number @@ -62,15 +70,16 @@ export class TCard extends TTask implements Card { declare assignee: Ref | null @Prop(Collection(contact.class.Employee), board.string.Members) - members!: Ref[] + members?: Ref[] } @Model(board.class.CardAction, core.class.Doc, DOMAIN_MODEL) export class TCardAction extends TDoc implements CardAction { + component?: AnyComponent hint?: IntlString icon!: Asset isInline?: boolean - isTransparent?: boolean + kind?: 'primary' | 'secondary' | 'no-border' | 'transparent' | 'dangerous' label!: IntlString position!: number type!: string @@ -287,7 +296,7 @@ export function createModel (builder: Builder): void { { icon: board.icon.Card, isInline: false, - isTransparent: true, + kind: 'transparent', label: board.string.AddButton, position: 70, type: board.cardActionType.Automation, diff --git a/models/board/src/plugin.ts b/models/board/src/plugin.ts index 8e99acbbf0..7133c0e461 100644 --- a/models/board/src/plugin.ts +++ b/models/board/src/plugin.ts @@ -16,7 +16,7 @@ import { boardId, Card, CardAction } from '@anticrm/board' import board from '@anticrm/board-resources/src/plugin' -import type { Client, Ref, Space } from '@anticrm/core' +import type { TxOperations as Client, Ref, Space } from '@anticrm/core' import { mergeIds, Resource } from '@anticrm/platform' import { KanbanTemplate, Sequence } from '@anticrm/task' import type { AnyComponent } from '@anticrm/ui' diff --git a/plugins/board-assets/lang/en.json b/plugins/board-assets/lang/en.json index e585a81e39..1d1888fb28 100644 --- a/plugins/board-assets/lang/en.json +++ b/plugins/board-assets/lang/en.json @@ -23,6 +23,7 @@ "DescriptionPlaceholder": "Add a more detailed description...", "Location": "Location", "Members": "Members", + "IsArchived": "Archived", "BoardCreateLabel": "Board", "Settings": "Settings", "InList": "in list", diff --git a/plugins/board-assets/lang/ru.json b/plugins/board-assets/lang/ru.json index 0283ddd8a1..e5e5019be7 100644 --- a/plugins/board-assets/lang/ru.json +++ b/plugins/board-assets/lang/ru.json @@ -23,6 +23,7 @@ "DescriptionPlaceholder": "Добавьте более подробное описание...", "Location": "Location", "Members": "Участники", + "IsArchived": "Архивировано", "BoardCreateLabel": "Board", "Settings": "Настройки", "InList": "в списке", diff --git a/plugins/board-resources/src/components/editor/CardActions.svelte b/plugins/board-resources/src/components/editor/CardActions.svelte index fd47b21cfc..401f8ed26b 100644 --- a/plugins/board-resources/src/components/editor/CardActions.svelte +++ b/plugins/board-resources/src/components/editor/CardActions.svelte @@ -18,7 +18,7 @@ import type { Card, CardAction } from '@anticrm/board' import { IntlString, getResource } from '@anticrm/platform' import { getClient } from '@anticrm/presentation' - import { Button, Label } from '@anticrm/ui' + import { Button, Component, Label } from '@anticrm/ui' import plugin from '../../plugin' import { cardActionSorter, getCardActions } from '../../utils/CardActionUtils' @@ -74,18 +74,24 @@
{/if} diff --git a/plugins/board-resources/src/plugin.ts b/plugins/board-resources/src/plugin.ts index 7c1fcaed37..7e47a84754 100644 --- a/plugins/board-resources/src/plugin.ts +++ b/plugins/board-resources/src/plugin.ts @@ -15,7 +15,7 @@ import board, { boardId } from '@anticrm/board' import { IntlString, mergeIds } from '@anticrm/platform' -import { AnyComponent } from '@anticrm/ui' +import type { AnyComponent } from '@anticrm/ui' export default mergeIds(boardId, board, { string: { @@ -44,6 +44,7 @@ export default mergeIds(boardId, board, { DescriptionPlaceholder: '' as IntlString, Location: '' as IntlString, Members: '' as IntlString, + IsArchived: '' as IntlString, BoardCreateLabel: '' as IntlString, Settings: '' as IntlString, InList: '' as IntlString, diff --git a/plugins/board/package.json b/plugins/board/package.json index f29f7812a8..05ca316aaa 100644 --- a/plugins/board/package.json +++ b/plugins/board/package.json @@ -30,6 +30,7 @@ "@anticrm/core": "~0.6.16", "@anticrm/platform": "~0.6.5", "@anticrm/view": "~0.6.0", - "@anticrm/task": "~0.6.0" + "@anticrm/task": "~0.6.0", + "@anticrm/ui": "~0.6.0" } } diff --git a/plugins/board/src/index.ts b/plugins/board/src/index.ts index 4918362861..44cfa3301e 100644 --- a/plugins/board/src/index.ts +++ b/plugins/board/src/index.ts @@ -15,10 +15,11 @@ // import { Employee } from '@anticrm/contact' -import type { AttachedDoc, Class, Client, Doc, Markup, Ref } from '@anticrm/core' +import type { AttachedDoc, Class, TxOperations as Client, Doc, Markup, Ref, Timestamp } from '@anticrm/core' import type { Asset, IntlString, Plugin, Resource } from '@anticrm/platform' import { plugin } from '@anticrm/platform' import type { KanbanTemplateSpace, SpaceWithStates, Task } from '@anticrm/task' +import type { AnyComponent } from '@anticrm/ui' /** * @public @@ -47,17 +48,31 @@ export interface CardLabel extends AttachedDoc { color: number } +/** + * @public + */ +export interface CardDate { + dueDate?: Timestamp + isChecked?: boolean + startDate?: Timestamp +} + /** * @public */ export interface Card extends Task { title: string + date?: CardDate description: Markup - members: Ref[] + isArchived?: boolean - location: string + members?: Ref[] + + labels?: Ref[] + + location?: string coverColor?: number coverImage?: string @@ -69,10 +84,11 @@ export interface Card extends Task { * @public */ export interface CardAction extends Doc { + component?: AnyComponent hint?: IntlString icon: Asset isInline?: boolean - isTransparent?: boolean + kind?: 'primary' | 'secondary' | 'no-border' | 'transparent' | 'dangerous' label: IntlString position: number type: string @@ -102,7 +118,8 @@ const boards = plugin(boardId, { class: { Board: '' as Ref>, Card: '' as Ref>, - CardAction: '' as Ref> + CardAction: '' as Ref>, + CardLabel: '' as Ref> }, icon: { Board: '' as Asset, diff --git a/plugins/task/src/index.ts b/plugins/task/src/index.ts index 055725703b..746b0e9ec9 100644 --- a/plugins/task/src/index.ts +++ b/plugins/task/src/index.ts @@ -46,6 +46,7 @@ export interface DocWithRank extends Doc { export interface State extends DocWithRank { title: string color: number + isArchived?: boolean } /**