From 29058d8c84fa393a2d23b334c7113badf2e84e9b Mon Sep 17 00:00:00 2001 From: Anna No Date: Tue, 17 May 2022 15:36:11 +0700 Subject: [PATCH] Board: Use Standard actions (#1766) * Board: use standard actions Signed-off-by: Anna No * Board: use standard actions Signed-off-by: Anna No * fix lint issues Signed-off-by: Anna No * fix lint issues Signed-off-by: Anna No * fix merge conflicts Signed-off-by: Anna No * fix merge conflicts Signed-off-by: Anna No --- models/board/src/index.ts | 311 +++++++----------- models/board/src/plugin.ts | 7 +- models/task/src/index.ts | 18 +- models/task/src/plugin.ts | 3 +- .../src/components/CardArchive.svelte | 26 +- .../src/components/EditCard.svelte | 13 +- .../src/components/KanbanCard.svelte | 9 +- .../src/components/KanbanView.svelte | 6 +- .../src/components/editor/CardActions.svelte | 138 ++++---- .../components/editor/CardAttachments.svelte | 17 +- .../components/editor/CardChecklist.svelte | 2 +- .../src/components/editor/CardDetails.svelte | 55 ++-- .../editor/CardInlineActions.svelte | 80 ----- .../src/components/editor/CardLabels.svelte | 9 +- .../src/components/popups/AddChecklist.svelte | 10 +- .../components/popups/AttachmentPicker.svelte | 8 +- .../components/popups/CardCoverEditor.svelte | 6 +- .../components/popups/CardLabelsPopup.svelte | 6 +- .../src/components/popups/CopyCard.svelte | 30 +- .../components/popups/DateRangePicker.svelte | 18 +- .../src/components/popups/MoveCard.svelte | 30 +- .../src/components/popups/RemoveCard.svelte | 46 --- plugins/board-resources/src/index.ts | 97 +----- .../src/utils/CardActionUtils.ts | 11 +- plugins/board/src/index.ts | 87 +---- plugins/view-resources/src/actions.ts | 13 +- .../view-resources/src/components/Menu.svelte | 10 +- plugins/view-resources/src/index.ts | 2 +- 28 files changed, 367 insertions(+), 701 deletions(-) delete mode 100644 plugins/board-resources/src/components/editor/CardInlineActions.svelte delete mode 100644 plugins/board-resources/src/components/popups/RemoveCard.svelte diff --git a/models/board/src/index.ts b/models/board/src/index.ts index 8b37f52b43..520175fe52 100644 --- a/models/board/src/index.ts +++ b/models/board/src/index.ts @@ -14,9 +14,9 @@ // // To help typescript locate view plugin properly -import type { Board, Card, CardAction, CardDate, CardLabel, MenuPage, LabelsCompactMode } from '@anticrm/board' +import type { Board, Card, CardDate, CardLabel, MenuPage, LabelsCompactMode } from '@anticrm/board' import type { Employee } from '@anticrm/contact' -import { DOMAIN_MODEL, IndexKind, Markup, Ref, Timestamp, TxOperations as Client, Type } from '@anticrm/core' +import { DOMAIN_MODEL, IndexKind, Markup, Ref, Timestamp, Type } from '@anticrm/core' import { ArrOf, Builder, @@ -35,9 +35,9 @@ import chunter from '@anticrm/model-chunter' import contact from '@anticrm/model-contact' import core, { TAttachedDoc, TDoc, TObj } from '@anticrm/model-core' import task, { TSpaceWithStates, TTask } from '@anticrm/model-task' -import view from '@anticrm/model-view' +import view, { actionTemplates, createAction } from '@anticrm/model-view' import workbench from '@anticrm/model-workbench' -import { Asset, IntlString, Resource } from '@anticrm/platform' +import { IntlString } from '@anticrm/platform' import type { AnyComponent } from '@anticrm/ui' import preference, { TPreference } from '@anticrm/model-preference' import board from './plugin' @@ -115,20 +115,6 @@ export class TCard extends TTask implements Card { 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 - kind?: 'primary' | 'secondary' | 'no-border' | 'transparent' | 'dangerous' - label!: IntlString - position!: number - type!: string - handler?: Resource<(card: Card, client: Client, e?: Event) => void> - supported?: Resource<(card: Card, client: Client) => boolean> -} - @Model(board.class.MenuPage, core.class.Doc, DOMAIN_MODEL) export class TMenuPage extends TDoc implements MenuPage { component!: AnyComponent @@ -137,7 +123,7 @@ export class TMenuPage extends TDoc implements MenuPage { } export function createModel (builder: Builder): void { - builder.createModel(TBoard, TCard, TCardLabel, TCardDate, TCardAction, TMenuPage, TLabelsCompactMode) + builder.createModel(TBoard, TCard, TCardLabel, TCardDate, TMenuPage, TLabelsCompactMode) builder.createDoc(board.class.MenuPage, core.space.Model, { component: board.component.Archive, @@ -278,207 +264,156 @@ export function createModel (builder: Builder): void { ) // card actions - builder.createDoc( - board.class.CardAction, - core.space.Model, + createAction( + builder, { - icon: board.icon.Card, - isInline: false, - label: board.string.Join, - position: 10, - type: board.cardActionType.Suggested, - handler: board.cardActionHandler.Join, - supported: board.cardActionSupportedHandler.Join - }, - board.cardAction.Join - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { - icon: board.icon.Card, - isInline: true, - label: board.string.Members, - position: 20, - type: board.cardActionType.AddToCard, - handler: board.cardActionHandler.Members - }, - board.cardAction.Members - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { - icon: board.icon.Card, - isInline: true, + action: view.actionImpl.ShowPopup, + actionProps: { + component: board.component.LabelsActionPopup, + element: 'top' + }, label: board.string.Labels, - position: 30, - type: board.cardActionType.AddToCard, - handler: board.cardActionHandler.Labels - }, - board.cardAction.Labels - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { icon: board.icon.Card, - isInline: false, - label: board.string.Checklist, - position: 40, - type: board.cardActionType.AddToCard, - handler: board.cardActionHandler.Checklist + input: 'any', + category: board.category.Card, + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'top' } }, - board.cardAction.Checklist + board.action.Labels ) - builder.createDoc( - board.class.CardAction, - core.space.Model, + createAction( + builder, { - icon: board.icon.Card, - isInline: true, + action: view.actionImpl.ShowPopup, + actionProps: { + component: board.component.DatesActionPopup, + element: 'top' + }, label: board.string.Dates, - position: 50, - type: board.cardActionType.AddToCard, - handler: board.cardActionHandler.Dates - }, - board.cardAction.Dates - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { icon: board.icon.Card, - isInline: false, - label: board.string.Attachments, - position: 60, - type: board.cardActionType.AddToCard, - handler: board.cardActionHandler.Attachments + input: 'any', + category: board.category.Card, + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'top' } }, - board.cardAction.Attachments + board.action.Dates ) - builder.createDoc( - board.class.CardAction, - core.space.Model, + createAction( + builder, { - icon: board.icon.Card, - isInline: true, + action: view.actionImpl.ShowPopup, + actionProps: { + component: board.component.CoverActionPopup, + element: 'top' + }, label: board.string.Cover, - position: 70, - type: board.cardActionType.Cover, - handler: board.cardActionHandler.Cover - }, - board.cardAction.Cover - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { icon: board.icon.Card, - isInline: false, - label: board.string.CustomFields, - position: 80, - type: board.cardActionType.AddToCard, - handler: board.cardActionHandler.CustomFields + input: 'any', + category: board.category.Card, + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'top' } }, - board.cardAction.CustomFields + board.action.Cover ) - builder.createDoc( - board.class.CardAction, - core.space.Model, + createAction( + builder, { - icon: board.icon.Card, - isInline: false, - kind: 'transparent', - label: board.string.AddButton, - position: 90, - type: board.cardActionType.Automation, - handler: board.cardActionHandler.AddButton + ...actionTemplates.move, + action: view.actionImpl.ShowPopup, + actionProps: { + component: board.component.MoveActionPopup, + element: 'top' + }, + input: 'any', + category: board.category.Card, + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'tools' } }, - board.cardAction.AddButton + board.action.Move ) - builder.createDoc( - board.class.CardAction, - core.space.Model, + createAction( + builder, { - icon: board.icon.Card, - isInline: true, - label: board.string.Move, - position: 100, - type: board.cardActionType.Action, - handler: board.cardActionHandler.Move - }, - board.cardAction.Move - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { - icon: board.icon.Card, - isInline: true, + action: view.actionImpl.ShowPopup, + actionProps: { + component: board.component.CopyActionPopup, + element: 'top' + }, label: board.string.Copy, - position: 110, - type: board.cardActionType.Action, - handler: board.cardActionHandler.Copy - }, - board.cardAction.Copy - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { icon: board.icon.Card, - isInline: false, - label: board.string.MakeTemplate, - position: 120, - type: board.cardActionType.Action, - handler: board.cardActionHandler.MakeTemplate + input: 'any', + category: board.category.Card, + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'tools' } }, - board.cardAction.MakeTemplate + board.action.Copy ) - builder.createDoc( - board.class.CardAction, - core.space.Model, + + createAction( + builder, { + action: view.actionImpl.UpdateDocument, + actionProps: { + key: 'isArchived', + value: true, + ask: true, + label: task.string.Archive, + message: task.string.ArchiveConfirm + }, + query: { + isArchived: { $nin: [true] } + }, + label: board.string.Archive, icon: board.icon.Card, - isInline: true, - label: board.string.ToArchive, - position: 140, - type: board.cardActionType.Action, - handler: board.cardActionHandler.Archive, - supported: board.cardActionSupportedHandler.Archive + input: 'any', + category: board.category.Card, + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'tools' } }, - board.cardAction.Archive + board.action.Archive ) - builder.createDoc( - board.class.CardAction, - core.space.Model, + createAction( + builder, { - icon: board.icon.Card, - isInline: true, + action: view.actionImpl.UpdateDocument, + actionProps: { + key: 'isArchived', + value: false + }, + query: { + isArchived: true + }, label: board.string.SendToBoard, - position: 140, - type: board.cardActionType.Action, - handler: board.cardActionHandler.SendToBoard, - supported: board.cardActionSupportedHandler.SendToBoard - }, - board.cardAction.SendToBoard - ) - builder.createDoc( - board.class.CardAction, - core.space.Model, - { icon: board.icon.Card, - isInline: false, - kind: 'dangerous', - label: board.string.Delete, - position: 150, - type: board.cardActionType.Action, - handler: board.cardActionHandler.Delete, - supported: board.cardActionSupportedHandler.Delete + input: 'any', + category: board.category.Card, + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'tools' } }, - board.cardAction.Delete + board.action.SendToBoard ) + + createAction( + builder, + { + action: view.actionImpl.Delete, + query: { + isArchived: true + }, + label: view.string.Delete, + icon: view.icon.Delete, + keyBinding: ['Meta + Backspace', 'Ctrl + Backspace'], + category: board.category.Card, + input: 'any', + target: board.class.Card, + context: { mode: 'context', application: board.app.Board, group: 'tools' } + }, + board.action.Delete + ) + + builder.mixin(board.class.Card, core.class.Class, view.mixin.IgnoreActions, { + actions: [view.action.Delete, task.action.Move] + }) } export { boardOperation } from './migration' diff --git a/models/board/src/plugin.ts b/models/board/src/plugin.ts index 022d9b7d26..68a1fc5ef3 100644 --- a/models/board/src/plugin.ts +++ b/models/board/src/plugin.ts @@ -34,7 +34,12 @@ export default mergeIds(boardId, board, { TemplatesIcon: '' as AnyComponent, Cards: '' as AnyComponent, KanbanView: '' as AnyComponent, - TableView: '' as AnyComponent + TableView: '' as AnyComponent, + LabelsActionPopup: '' as AnyComponent, + DatesActionPopup: '' as AnyComponent, + CoverActionPopup: '' as AnyComponent, + MoveActionPopup: '' as AnyComponent, + CopyActionPopup: '' as AnyComponent }, space: { DefaultBoard: '' as Ref diff --git a/models/task/src/index.ts b/models/task/src/index.ts index 9295d2ccbd..fad5c80615 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -509,11 +509,15 @@ export function createModel (builder: Builder): void { task.completion.IssueCategory ) - createAction(builder, { - ...viewTemplates.move, - target: task.class.Task, - context: { - mode: ['context', 'browser'] - } - }) + createAction( + builder, + { + ...viewTemplates.move, + target: task.class.Task, + context: { + mode: ['context', 'browser'] + } + }, + task.action.Move + ) } diff --git a/models/task/src/plugin.ts b/models/task/src/plugin.ts index 5736a3dba2..3baa120490 100644 --- a/models/task/src/plugin.ts +++ b/models/task/src/plugin.ts @@ -27,7 +27,8 @@ export default mergeIds(taskId, task, { action: { EditStatuses: '' as Ref, ArchiveSpace: '' as Ref, - UnarchiveSpace: '' as Ref + UnarchiveSpace: '' as Ref, + Move: '' as Ref }, actionImpl: { EditStatuses: '' as ViewAction, diff --git a/plugins/board-resources/src/components/CardArchive.svelte b/plugins/board-resources/src/components/CardArchive.svelte index 5531f6e4d5..b83e9546ab 100644 --- a/plugins/board-resources/src/components/CardArchive.svelte +++ b/plugins/board-resources/src/components/CardArchive.svelte @@ -1,15 +1,18 @@ {#if archivedCards} @@ -33,16 +39,20 @@
diff --git a/plugins/board-resources/src/components/EditCard.svelte b/plugins/board-resources/src/components/EditCard.svelte index 64d080e4df..7e0752c87e 100644 --- a/plugins/board-resources/src/components/EditCard.svelte +++ b/plugins/board-resources/src/components/EditCard.svelte @@ -17,13 +17,12 @@ import type { Card } from '@anticrm/board' import { Class, Ref } from '@anticrm/core' import { Panel } from '@anticrm/panel' - import { getResource } from '@anticrm/platform' import { createQuery, getClient } from '@anticrm/presentation' import type { State, TodoItem } from '@anticrm/task' import task from '@anticrm/task' import { StyledTextBox } from '@anticrm/text-editor' import { Button, EditBox, Icon, Label } from '@anticrm/ui' - import { UpDownNavigator } from '@anticrm/view-resources' + import { invokeAction, UpDownNavigator } from '@anticrm/view-resources' import { createEventDispatcher, onMount } from 'svelte' import board from '../plugin' import { getCardActions } from '../utils/CardActionUtils' @@ -66,13 +65,13 @@ checklists = result }) - getCardActions(client, { _id: board.cardAction.Move }).then(async (result) => { - if (result[0]?.handler) { - const handler = await getResource(result[0].handler) + getCardActions(client, { _id: board.action.Move }).then(async (result) => { + if (result[0]) { handleMove = (e) => { - if (object) { - handler(object, client, e) + if (!object) { + return } + invokeAction(object, e, result[0].action, result[0].actionProps) } } }) diff --git a/plugins/board-resources/src/components/KanbanCard.svelte b/plugins/board-resources/src/components/KanbanCard.svelte index 8c19ca8fdf..db0b6d2eab 100644 --- a/plugins/board-resources/src/components/KanbanCard.svelte +++ b/plugins/board-resources/src/components/KanbanCard.svelte @@ -22,8 +22,8 @@ import notification from '@anticrm/notification' import { getClient, UserBoxList } from '@anticrm/presentation' import { Button, Component, EditBox, IconEdit, Label, numberToHexColor, showPopup } from '@anticrm/ui' + import { ContextMenu } from '@anticrm/view-resources' import board from '../plugin' - import CardInlineActions from './editor/CardInlineActions.svelte' import CardLabels from './editor/CardLabels.svelte' import DatePresenter from './presenters/DatePresenter.svelte' import { hasDate, openCardPanel, updateCard, updateCardMembers } from '../utils/CardUtils' @@ -44,12 +44,7 @@ function enterEditMode (): void { isEditMode = true - showPopup( - CardInlineActions, - { value: object }, - getElementPopupAlignment(ref, { h: 'right', v: 'top' }), - exitEditMode - ) + showPopup(ContextMenu, { object }, getElementPopupAlignment(ref, { h: 'right', v: 'top' }), exitEditMode) } function showCard () { diff --git a/plugins/board-resources/src/components/KanbanView.svelte b/plugins/board-resources/src/components/KanbanView.svelte index 15b1888acf..57f34e9f66 100644 --- a/plugins/board-resources/src/components/KanbanView.svelte +++ b/plugins/board-resources/src/components/KanbanView.svelte @@ -23,6 +23,7 @@ import { showPopup } from '@anticrm/ui' import { ActionContext, + ContextMenu, focusStore, ListSelectionProvider, SelectDirection, @@ -30,7 +31,6 @@ } from '@anticrm/view-resources' import { onMount } from 'svelte' import AddCard from './add-card/AddCard.svelte' - import CardInlineActions from './editor/CardInlineActions.svelte' import KanbanCard from './KanbanCard.svelte' import AddPanel from './AddPanel.svelte' import ListHeader from './ListHeader.svelte' @@ -94,8 +94,8 @@ } showPopup( - CardInlineActions, - { value: object }, + ContextMenu, + { object }, { getBoundingClientRect: () => DOMRect.fromRect({ width: 1, height: 1, x: ev.clientX, y: ev.clientY }) } diff --git a/plugins/board-resources/src/components/editor/CardActions.svelte b/plugins/board-resources/src/components/editor/CardActions.svelte index 446f4bb7ae..15753c8055 100644 --- a/plugins/board-resources/src/components/editor/CardActions.svelte +++ b/plugins/board-resources/src/components/editor/CardActions.svelte @@ -14,67 +14,26 @@ // limitations under the License. --> diff --git a/plugins/board-resources/src/components/editor/CardChecklist.svelte b/plugins/board-resources/src/components/editor/CardChecklist.svelte index 93ffd072fb..0776c6da8f 100644 --- a/plugins/board-resources/src/components/editor/CardChecklist.svelte +++ b/plugins/board-resources/src/components/editor/CardChecklist.svelte @@ -92,7 +92,7 @@ } function showItemMenu (item: TodoItem, e?: Event) { - showPopup(ContextMenu, { object: item }, getPopupAlignment(e)) + showPopup(ContextMenu, { object: item, baseMenuClass: board.class.Card }, getPopupAlignment(e)) } $: checklistItemsQuery.query(task.class.TodoItem, { space: value.space, attachedTo: value._id }, (result) => { diff --git a/plugins/board-resources/src/components/editor/CardDetails.svelte b/plugins/board-resources/src/components/editor/CardDetails.svelte index 930d5f978d..b2ad9ee1bf 100644 --- a/plugins/board-resources/src/components/editor/CardDetails.svelte +++ b/plugins/board-resources/src/components/editor/CardDetails.svelte @@ -16,13 +16,15 @@ import type { Card, CardDate } from '@anticrm/board' import contact, { Employee } from '@anticrm/contact' - import { getResource } from '@anticrm/platform' - import { createQuery, getClient } from '@anticrm/presentation' - import { Button, IconAdd, Label } from '@anticrm/ui' + import { Ref } from '@anticrm/core' + import { createQuery, getClient, UsersPopup } from '@anticrm/presentation' + import { Button, IconAdd, Label, showPopup } from '@anticrm/ui' + import { invokeAction } from '@anticrm/view-resources' import board from '../../plugin' import { getCardActions } from '../../utils/CardActionUtils' import { hasDate, updateCardMembers } from '../../utils/CardUtils' + import { getPopupAlignment } from '../../utils/PopupUtils' import DatePresenter from '../presenters/DatePresenter.svelte' import MemberPresenter from '../presenters/MemberPresenter.svelte' import CardLabels from './CardLabels.svelte' @@ -30,20 +32,30 @@ export let value: Card const query = createQuery() const client = getClient() - let members: Employee[] - let membersHandler: (e: Event) => void + let members: Employee[] = [] + const membersHandler = (e?: Event) => { + showPopup( + UsersPopup, + { + _class: contact.class.Employee, + multiSelect: true, + allowDeselect: true, + selectedUsers: members?.map((m) => m._id) ?? [], + placeholder: board.string.SearchMembers + }, + getPopupAlignment(e), + undefined, + (result: Array>) => { + updateCardMembers(value, client, result) + } + ) + } let dateHandler: (e: Event) => void $: membersIds = members?.map((m) => m._id) ?? [] const getMenuItems = (member: Employee) => { return [ - [ - { - title: board.string.ViewProfile, - handler: () => console.log('TODO: implement') - } - ], [ { title: board.string.RemoveFromCard, @@ -56,29 +68,20 @@ ] } - $: if (value.members && value.members.length > 0) { - query.query(contact.class.Employee, { _id: { $in: value.members } }, (result) => { - members = result - }) - } else { - members = [] - } + $: query.query(contact.class.Employee, { _id: { $in: value.members } }, (result) => { + members = result + }) function updateDate (e: CustomEvent) { client.update(value, { date: e.detail }) } getCardActions(client, { - _id: { $in: [board.cardAction.Dates, board.cardAction.Members] } + _id: { $in: [board.action.Dates] } }).then(async (result) => { for (const action of result) { - if (action.handler) { - const handler = await getResource(action.handler) - if (action._id === board.cardAction.Dates) { - dateHandler = (e) => handler(value, client, e) - } else if (action._id === board.cardAction.Members) { - membersHandler = (e) => handler(value, client, e) - } + if (action._id === board.action.Dates) { + dateHandler = (e: Event) => invokeAction(value, e, action.action, action.actionProps) } } }) diff --git a/plugins/board-resources/src/components/editor/CardInlineActions.svelte b/plugins/board-resources/src/components/editor/CardInlineActions.svelte deleted file mode 100644 index 6c42026694..0000000000 --- a/plugins/board-resources/src/components/editor/CardInlineActions.svelte +++ /dev/null @@ -1,80 +0,0 @@ - - - -{#if value && !value.isArchived} -
-
-{/if} diff --git a/plugins/board-resources/src/components/editor/CardLabels.svelte b/plugins/board-resources/src/components/editor/CardLabels.svelte index 22269dfa85..7b8bc3cec8 100644 --- a/plugins/board-resources/src/components/editor/CardLabels.svelte +++ b/plugins/board-resources/src/components/editor/CardLabels.svelte @@ -15,10 +15,10 @@ diff --git a/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte b/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte index 376f564314..183a65b0f5 100644 --- a/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte +++ b/plugins/board-resources/src/components/popups/CardLabelsPopup.svelte @@ -3,7 +3,7 @@ import CardLabelsEditor from './CardLabelsEditor.svelte' import CardLabelsPicker from './CardLabelsPicker.svelte' - export let object: Card + export let value: Card let editMode: { isEdit?: boolean @@ -19,7 +19,7 @@ {#if editMode.isEdit} setEditMode(false, undefined)} /> @@ -27,7 +27,7 @@ setEditMode(true, undefined)} onEdit={(o) => setEditMode(true, o)} /> diff --git a/plugins/board-resources/src/components/popups/CopyCard.svelte b/plugins/board-resources/src/components/popups/CopyCard.svelte index 1b542a7663..0a9142f39f 100644 --- a/plugins/board-resources/src/components/popups/CopyCard.svelte +++ b/plugins/board-resources/src/components/popups/CopyCard.svelte @@ -3,30 +3,30 @@ import { Label, Button, Status as StatusControl, TextArea } from '@anticrm/ui' import { Class, Client, Doc, Ref } from '@anticrm/core' import { getResource, OK, Resource, Status } from '@anticrm/platform' + import { getClient } from '@anticrm/presentation' import { Card } from '@anticrm/board' import view from '@anticrm/view' import board from '../../plugin' import SpaceSelect from '../selectors/SpaceSelect.svelte' import StateSelect from '../selectors/StateSelect.svelte' import RankSelect from '../selectors/RankSelect.svelte' - import type { TxOperations } from '@anticrm/core' import { generateId, AttachedData } from '@anticrm/core' import task from '@anticrm/task' import { createMissingLabels } from '../../utils/BoardUtils' - export let object: Card - export let client: TxOperations + export let value: Card + const client = getClient() const hierarchy = client.getHierarchy() const dispatch = createEventDispatcher() let inputRef: TextArea - let title = object.title + let title = value.title let status: Status = OK const selected = { - space: object.space, - state: object.state, - rank: object.rank + space: value.space, + state: value.state, + rank: value.rank } async function copyCard (): Promise { @@ -40,9 +40,9 @@ const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true) const labels = - object.space !== selected.space ? await createMissingLabels(client, object, selected.space) : object.labels + value.space !== selected.space ? await createMissingLabels(client, value, selected.space) : value.labels - const value: AttachedData = { + const copy: AttachedData = { state: selected.state, doneState: null, number: (incResult as any).object.sequence, @@ -61,7 +61,7 @@ selected.space, board.class.Board, 'cards', - value, + copy, newCardId ) dispatch('close') @@ -71,7 +71,7 @@ action: Resource<(doc: T, client: Client) => Promise> ): Promise { const impl = await getResource(action) - return await impl(object, client) + return await impl(value, client) } async function validate (doc: Doc, _class: Ref>): Promise { @@ -86,7 +86,7 @@ } } - $: validate({ ...object, ...selected }, object._class) + $: validate({ ...value, ...selected }, value._class) onMount(() => inputRef.focus()) @@ -109,20 +109,20 @@
- +
{#key selected.space} - + {/key}
{#key selected.state} @@ -82,7 +82,7 @@ label={board.string.Remove} size={'small'} on:click={() => { - client.update(object, { date: getEmptyDate() }) + client.update(value, { date: getEmptyDate() }) dispatch('close') }} /> @@ -96,7 +96,7 @@ }} />
- +
diff --git a/plugins/board-resources/src/components/popups/MoveCard.svelte b/plugins/board-resources/src/components/popups/MoveCard.svelte index aa66c206b2..dc63d32ec4 100644 --- a/plugins/board-resources/src/components/popups/MoveCard.svelte +++ b/plugins/board-resources/src/components/popups/MoveCard.svelte @@ -12,29 +12,29 @@ import RankSelect from '../selectors/RankSelect.svelte' import { createMissingLabels } from '../../utils/BoardUtils' - export let object: Card + export let value: Card const client = getClient() const hierarchy = client.getHierarchy() const dispatch = createEventDispatcher() let status: Status = OK const selected = { - space: object.space, - state: object.state, - rank: object.rank + space: value.space, + state: value.state, + rank: value.rank } async function move (): Promise { const update: DocumentUpdate = {} - if (selected.space !== object.space) { - update.labels = await createMissingLabels(client, object, selected.space) + if (selected.space !== value.space) { + update.labels = await createMissingLabels(client, value, selected.space) update.space = selected.space } - if (selected.state !== object.state) update.state = selected.state - if (selected.rank !== object.rank) update.rank = selected.rank - client.update(object, update) + if (selected.state !== value.state) update.state = selected.state + if (selected.rank !== value.rank) update.rank = selected.rank + client.update(value, update) dispatch('close') } @@ -42,7 +42,7 @@ action: Resource<(doc: T, client: Client) => Promise> ): Promise { const impl = await getResource(action) - return await impl(object, client) + return await impl(value, client) } async function validate (doc: Doc, _class: Ref>): Promise { @@ -57,7 +57,7 @@ } } - $: validate({ ...object, ...selected }, object._class) + $: validate({ ...value, ...selected }, value._class)
@@ -72,18 +72,18 @@
- +
{#key selected.space} - + {/key}
{#key selected.state} - + {/key}
@@ -98,7 +98,7 @@