Tracker: fix issue priority view for "Activity" (#1635)

Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@xored.com>
This commit is contained in:
Sergei Ogorelkov 2022-05-04 22:08:24 +07:00 committed by GitHub
parent e4e2af93dc
commit 5d84e38c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 99 additions and 51 deletions

View File

@ -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<IssuePriority> {
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<IssueStatus>
@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
})

View File

@ -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<Team>
export let baseMenuClass: Ref<Class<Doc>> | undefined = undefined
@ -161,7 +161,7 @@
{object.title}
</span>
<div class="flex gap-2 mt-2 mb-2">
<PriorityPresenter value={issue} {currentSpace} isEditable={true} />
<PriorityEditor value={issue} {currentSpace} isEditable={true} />
</div>
</div>
</svelte:fragment>

View File

@ -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<Issue>
@ -174,7 +174,7 @@
<span class="label w-24">
<Label label={tracker.string.Priority} />
</span>
<PriorityPresenter value={issue} currentSpace={currentTeam._id} shouldShowLabel />
<PriorityEditor value={issue} currentSpace={currentTeam._id} shouldShowLabel />
</div>
<div class="flex-row-center mb-4">

View File

@ -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 } },

View File

@ -0,0 +1,59 @@
<!--
// Copyright © 2022 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { Ref } from '@anticrm/core'
import { Issue, IssuePriority, Team } from '@anticrm/tracker'
import { getClient } from '@anticrm/presentation'
import { Tooltip } from '@anticrm/ui'
import tracker from '../../plugin'
import PrioritySelector from '../PrioritySelector.svelte'
export let value: Issue
export let currentSpace: Ref<Team> | undefined = undefined
export let isEditable: boolean = true
export let shouldShowLabel: boolean = false
const client = getClient()
const handlePriorityChanged = async (newPriority: IssuePriority | undefined) => {
if (!isEditable || newPriority === undefined) {
return
}
const currentIssue = await client.findOne(tracker.class.Issue, { space: currentSpace, _id: value._id })
if (currentIssue === undefined) {
return
}
await client.update(currentIssue, { priority: newPriority })
}
</script>
{#if value}
{#if isEditable}
<Tooltip direction={'bottom'} label={tracker.string.SetPriority}>
<PrioritySelector
kind={'icon'}
{isEditable}
{shouldShowLabel}
priority={value.priority}
onPriorityChange={handlePriorityChanged}
/>
</Tooltip>
{:else}
<PrioritySelector kind={'icon'} {isEditable} {shouldShowLabel} priority={value.priority} />
{/if}
{/if}

View File

@ -13,47 +13,15 @@
// limitations under the License.
-->
<script lang="ts">
import { Ref } from '@anticrm/core'
import { Issue, IssuePriority, Team } from '@anticrm/tracker'
import { getClient } from '@anticrm/presentation'
import { Tooltip } from '@anticrm/ui'
import tracker from '../../plugin'
import PrioritySelector from '../PrioritySelector.svelte'
import { IssuePriority } from '@anticrm/tracker'
import { Label } from '@anticrm/ui'
import { issuePriorities } from '../../utils'
export let value: Issue
export let currentSpace: Ref<Team> | undefined = undefined
export let isEditable: boolean = true
export let shouldShowLabel: boolean = false
const client = getClient()
const handlePriorityChanged = async (newPriority: IssuePriority | undefined) => {
if (!isEditable || newPriority === undefined) {
return
}
const currentIssue = await client.findOne(tracker.class.Issue, { space: currentSpace, _id: value._id })
if (currentIssue === undefined) {
return
}
await client.update(currentIssue, { priority: newPriority })
}
export let value: IssuePriority | undefined
</script>
{#if value}
{#if isEditable}
<Tooltip direction={'bottom'} label={tracker.string.SetPriority}>
<PrioritySelector
kind={'icon'}
{isEditable}
{shouldShowLabel}
priority={value.priority}
onPriorityChange={handlePriorityChanged}
/>
</Tooltip>
{:else}
<PrioritySelector kind={'icon'} {isEditable} {shouldShowLabel} priority={value.priority} />
{/if}
<span class="overflow-label">
<Label label={issuePriorities[value].label} />
</span>
{/if}

View File

@ -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<Resources> => ({
TitlePresenter,
ModificationDatePresenter,
PriorityPresenter,
PriorityEditor,
StatusPresenter,
StatusEditor,
AssigneePresenter,

View File

@ -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,

View File

@ -95,7 +95,7 @@ export const issuesSortOrderMap: Record<IssuesOrderByKeys, SortingOrder> = {
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 => {

View File

@ -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<Class<Document>>,
Project: '' as Ref<Class<Project>>,
IssueStatus: '' as Ref<Class<IssueStatus>>,
IssueStatusCategory: '' as Ref<Class<IssueStatusCategory>>
IssueStatusCategory: '' as Ref<Class<IssueStatusCategory>>,
TypeIssuePriority: '' as Ref<Class<Type<IssuePriority>>>
},
component: {
Tracker: '' as AnyComponent,