From 5d84e38c79d6c0b37b4ccaa3acd89577f3287d8a Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Wed, 4 May 2022 22:08:24 +0700 Subject: [PATCH] Tracker: fix issue priority view for "Activity" (#1635) Signed-off-by: Sergei Ogorelkov --- models/tracker/src/index.ts | 25 ++++++-- .../src/components/issues/Board.svelte | 4 +- .../src/components/issues/EditIssue.svelte | 4 +- .../src/components/issues/Issues.svelte | 2 +- .../components/issues/PriorityEditor.svelte | 59 +++++++++++++++++++ .../issues/PriorityPresenter.svelte | 46 +++------------ plugins/tracker-resources/src/index.ts | 2 + plugins/tracker-resources/src/plugin.ts | 1 + plugins/tracker-resources/src/utils.ts | 2 +- plugins/tracker/src/index.ts | 5 +- 10 files changed, 99 insertions(+), 51 deletions(-) create mode 100644 plugins/tracker-resources/src/components/issues/PriorityEditor.svelte diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index afd690a502..8659aa81c5 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -15,7 +15,7 @@ import type { Employee } from '@anticrm/contact' import contact from '@anticrm/contact' -import { Domain, DOMAIN_MODEL, IndexKind, Markup, Ref, Timestamp } from '@anticrm/core' +import { Domain, DOMAIN_MODEL, IndexKind, Markup, Ref, Timestamp, Type } from '@anticrm/core' import { ArrOf, Builder, @@ -33,7 +33,7 @@ import { } from '@anticrm/model' import attachment from '@anticrm/model-attachment' import chunter from '@anticrm/model-chunter' -import core, { DOMAIN_SPACE, TAttachedDoc, TDoc, TSpace } from '@anticrm/model-core' +import core, { DOMAIN_SPACE, TAttachedDoc, TDoc, TSpace, TType } from '@anticrm/model-core' import { createAction } from '@anticrm/model-view' import workbench, { createNavigateAction } from '@anticrm/model-workbench' import { Asset, IntlString } from '@anticrm/platform' @@ -84,6 +84,19 @@ export class TIssueStatusCategory extends TDoc implements IssueStatusCategory { order!: number } +/** + * @public + */ +export function TypeIssuePriority (): Type { + return { _class: tracker.class.TypeIssuePriority, label: 'TypeIssuePriority' as IntlString } +} + +/** + * @public + */ +@Model(tracker.class.TypeIssuePriority, core.class.Type, DOMAIN_MODEL) +export class TTypeIssuePriority extends TType {} + /** * @public */ @@ -126,7 +139,7 @@ export class TIssue extends TDoc implements Issue { @Prop(TypeRef(tracker.class.IssueStatus), tracker.string.Status) status!: Ref - @Prop(TypeNumber(), tracker.string.Priority) + @Prop(TypeIssuePriority(), tracker.string.Priority) priority!: IssuePriority @Prop(TypeNumber(), tracker.string.Number) @@ -227,7 +240,7 @@ export class TProject extends TDoc implements Project { } export function createModel (builder: Builder): void { - builder.createModel(TTeam, TProject, TIssue, TIssueStatus, TIssueStatusCategory) + builder.createModel(TTeam, TProject, TIssue, TIssueStatus, TIssueStatusCategory, TTypeIssuePriority) builder.createDoc( tracker.class.IssueStatusCategory, @@ -300,6 +313,10 @@ export function createModel (builder: Builder): void { const boardId = 'board' const projectsId = 'projects' + builder.mixin(tracker.class.TypeIssuePriority, core.class.Class, view.mixin.AttributePresenter, { + presenter: tracker.component.PriorityPresenter + }) + builder.mixin(tracker.class.IssueStatus, core.class.Class, view.mixin.AttributePresenter, { presenter: tracker.component.StatusPresenter }) diff --git a/plugins/tracker-resources/src/components/issues/Board.svelte b/plugins/tracker-resources/src/components/issues/Board.svelte index c62d0f8e71..ed23a91373 100644 --- a/plugins/tracker-resources/src/components/issues/Board.svelte +++ b/plugins/tracker-resources/src/components/issues/Board.svelte @@ -27,7 +27,7 @@ import CreateIssue from '../CreateIssue.svelte' import AssigneePresenter from './AssigneePresenter.svelte' import IssuePresenter from './IssuePresenter.svelte' - import PriorityPresenter from './PriorityPresenter.svelte' + import PriorityEditor from './PriorityEditor.svelte' export let currentSpace: Ref export let baseMenuClass: Ref> | undefined = undefined @@ -161,7 +161,7 @@ {object.title}
- +
diff --git a/plugins/tracker-resources/src/components/issues/EditIssue.svelte b/plugins/tracker-resources/src/components/issues/EditIssue.svelte index 8cdba917b4..51924c0ef4 100644 --- a/plugins/tracker-resources/src/components/issues/EditIssue.svelte +++ b/plugins/tracker-resources/src/components/issues/EditIssue.svelte @@ -24,7 +24,7 @@ import { createEventDispatcher, onMount } from 'svelte' import tracker from '../../plugin' import IssuePresenter from './IssuePresenter.svelte' - import PriorityPresenter from './PriorityPresenter.svelte' + import PriorityEditor from './PriorityEditor.svelte' import StatusEditor from './StatusEditor.svelte' export let _id: Ref @@ -174,7 +174,7 @@ - +
diff --git a/plugins/tracker-resources/src/components/issues/Issues.svelte b/plugins/tracker-resources/src/components/issues/Issues.svelte index 1fddb35500..6c0e4c79e3 100644 --- a/plugins/tracker-resources/src/components/issues/Issues.svelte +++ b/plugins/tracker-resources/src/components/issues/Issues.svelte @@ -349,7 +349,7 @@ {employees} categories={displayedCategories} itemsConfig={[ - { key: '', presenter: tracker.component.PriorityPresenter, props: { currentSpace } }, + { key: '', presenter: tracker.component.PriorityEditor, props: { currentSpace } }, { key: '', presenter: tracker.component.IssuePresenter, props: { currentTeam } }, { key: '', presenter: tracker.component.StatusEditor, props: { currentSpace, statuses } }, { key: '', presenter: tracker.component.TitlePresenter, props: { shouldUseMargin: true } }, diff --git a/plugins/tracker-resources/src/components/issues/PriorityEditor.svelte b/plugins/tracker-resources/src/components/issues/PriorityEditor.svelte new file mode 100644 index 0000000000..c419d12fc2 --- /dev/null +++ b/plugins/tracker-resources/src/components/issues/PriorityEditor.svelte @@ -0,0 +1,59 @@ + + + +{#if value} + {#if isEditable} + + + + {:else} + + {/if} +{/if} diff --git a/plugins/tracker-resources/src/components/issues/PriorityPresenter.svelte b/plugins/tracker-resources/src/components/issues/PriorityPresenter.svelte index c419d12fc2..e0fe358de1 100644 --- a/plugins/tracker-resources/src/components/issues/PriorityPresenter.svelte +++ b/plugins/tracker-resources/src/components/issues/PriorityPresenter.svelte @@ -13,47 +13,15 @@ // limitations under the License. --> {#if value} - {#if isEditable} - - - - {:else} - - {/if} + + {/if} diff --git a/plugins/tracker-resources/src/index.ts b/plugins/tracker-resources/src/index.ts index 9d97c894de..b547a40cbb 100644 --- a/plugins/tracker-resources/src/index.ts +++ b/plugins/tracker-resources/src/index.ts @@ -29,6 +29,7 @@ import Views from './components/views/Views.svelte' import IssuePresenter from './components/issues/IssuePresenter.svelte' import TitlePresenter from './components/issues/TitlePresenter.svelte' import PriorityPresenter from './components/issues/PriorityPresenter.svelte' +import PriorityEditor from './components/issues/PriorityEditor.svelte' import StatusPresenter from './components/issues/StatusPresenter.svelte' import StatusEditor from './components/issues/StatusEditor.svelte' import DueDatePresenter from './components/issues/DueDatePresenter.svelte' @@ -55,6 +56,7 @@ export default async (): Promise => ({ TitlePresenter, ModificationDatePresenter, PriorityPresenter, + PriorityEditor, StatusPresenter, StatusEditor, AssigneePresenter, diff --git a/plugins/tracker-resources/src/plugin.ts b/plugins/tracker-resources/src/plugin.ts index f229b6244e..3ad4e29b6b 100644 --- a/plugins/tracker-resources/src/plugin.ts +++ b/plugins/tracker-resources/src/plugin.ts @@ -136,6 +136,7 @@ export default mergeIds(trackerId, tracker, { TitlePresenter: '' as AnyComponent, ModificationDatePresenter: '' as AnyComponent, PriorityPresenter: '' as AnyComponent, + PriorityEditor: '' as AnyComponent, StatusPresenter: '' as AnyComponent, StatusEditor: '' as AnyComponent, AssigneePresenter: '' as AnyComponent, diff --git a/plugins/tracker-resources/src/utils.ts b/plugins/tracker-resources/src/utils.ts index 7b8bea6a34..0fa52306e9 100644 --- a/plugins/tracker-resources/src/utils.ts +++ b/plugins/tracker-resources/src/utils.ts @@ -95,7 +95,7 @@ export const issuesSortOrderMap: Record = { export const issuesGroupEditorMap: Record<'status' | 'priority', AnyComponent | undefined> = { status: tracker.component.StatusEditor, - priority: tracker.component.PriorityPresenter + priority: tracker.component.PriorityEditor } export const getIssuesModificationDatePeriodTime = (period: IssuesDateModificationPeriod | null): number => { diff --git a/plugins/tracker/src/index.ts b/plugins/tracker/src/index.ts index 5a444ebfdc..c930efcc40 100644 --- a/plugins/tracker/src/index.ts +++ b/plugins/tracker/src/index.ts @@ -14,7 +14,7 @@ // import { Employee } from '@anticrm/contact' -import type { AttachedDoc, Class, Doc, Markup, Ref, Space, Timestamp } from '@anticrm/core' +import type { AttachedDoc, Class, Doc, Markup, Ref, Space, Timestamp, Type } from '@anticrm/core' import type { Asset, IntlString, Plugin } from '@anticrm/platform' import { plugin } from '@anticrm/platform' import { AnyComponent } from '@anticrm/ui' @@ -181,7 +181,8 @@ export default plugin(trackerId, { Document: '' as Ref>, Project: '' as Ref>, IssueStatus: '' as Ref>, - IssueStatusCategory: '' as Ref> + IssueStatusCategory: '' as Ref>, + TypeIssuePriority: '' as Ref>> }, component: { Tracker: '' as AnyComponent,