2022-06-15 04:59:43 +00:00
|
|
|
<!--
|
|
|
|
// 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">
|
2022-09-21 08:08:25 +00:00
|
|
|
import contact from '@hcengineering/contact'
|
|
|
|
import { Class, Doc, DocumentQuery, Lookup, Ref, SortingOrder, WithLookup } from '@hcengineering/core'
|
|
|
|
import { Kanban, TypeState } from '@hcengineering/kanban'
|
|
|
|
import notification from '@hcengineering/notification'
|
2023-01-14 10:54:54 +00:00
|
|
|
import { getResource } from '@hcengineering/platform'
|
|
|
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
2022-09-21 08:08:25 +00:00
|
|
|
import tags from '@hcengineering/tags'
|
|
|
|
import { Issue, IssuesGrouping, IssuesOrdering, IssueStatus, Team } from '@hcengineering/tracker'
|
2022-08-05 07:48:31 +00:00
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
Component,
|
|
|
|
getEventPositionElement,
|
|
|
|
IconAdd,
|
|
|
|
Loading,
|
|
|
|
showPanel,
|
|
|
|
showPopup,
|
|
|
|
tooltip
|
2022-09-21 08:08:25 +00:00
|
|
|
} from '@hcengineering/ui'
|
2023-01-14 10:54:54 +00:00
|
|
|
import { ViewOptionModel, ViewOptions, ViewQueryOption } from '@hcengineering/view'
|
|
|
|
import {
|
|
|
|
focusStore,
|
|
|
|
ListSelectionProvider,
|
|
|
|
noCategory,
|
|
|
|
SelectDirection,
|
2023-01-18 05:14:59 +00:00
|
|
|
selectionStore
|
2023-01-14 10:54:54 +00:00
|
|
|
} from '@hcengineering/view-resources'
|
2022-09-21 08:08:25 +00:00
|
|
|
import ActionContext from '@hcengineering/view-resources/src/components/ActionContext.svelte'
|
|
|
|
import Menu from '@hcengineering/view-resources/src/components/Menu.svelte'
|
2022-06-15 04:59:43 +00:00
|
|
|
import { onMount } from 'svelte'
|
|
|
|
import tracker from '../../plugin'
|
2023-01-14 10:54:54 +00:00
|
|
|
import { getIssueStatusStates, getKanbanStatuses, getPriorityStates, issuesGroupBySorting } from '../../utils'
|
2022-06-15 04:59:43 +00:00
|
|
|
import CreateIssue from '../CreateIssue.svelte'
|
2022-06-16 04:24:17 +00:00
|
|
|
import ProjectEditor from '../projects/ProjectEditor.svelte'
|
2022-06-15 04:59:43 +00:00
|
|
|
import AssigneePresenter from './AssigneePresenter.svelte'
|
2022-06-16 04:24:17 +00:00
|
|
|
import SubIssuesSelector from './edit/SubIssuesSelector.svelte'
|
2022-06-15 04:59:43 +00:00
|
|
|
import IssuePresenter from './IssuePresenter.svelte'
|
2022-08-05 07:48:31 +00:00
|
|
|
import IssueStatusIcon from './IssueStatusIcon.svelte'
|
2022-06-27 06:04:26 +00:00
|
|
|
import ParentNamesPresenter from './ParentNamesPresenter.svelte'
|
2022-06-15 04:59:43 +00:00
|
|
|
import PriorityEditor from './PriorityEditor.svelte'
|
2022-07-04 18:14:53 +00:00
|
|
|
import StatusEditor from './StatusEditor.svelte'
|
2022-10-11 11:50:56 +00:00
|
|
|
import EstimationEditor from './timereport/EstimationEditor.svelte'
|
2022-06-15 04:59:43 +00:00
|
|
|
|
2023-01-14 10:54:54 +00:00
|
|
|
export let space: Ref<Team> | undefined = undefined
|
2022-06-15 04:59:43 +00:00
|
|
|
export let baseMenuClass: Ref<Class<Doc>> | undefined = undefined
|
2022-06-23 11:09:18 +00:00
|
|
|
export let query: DocumentQuery<Issue> = {}
|
2023-01-18 05:14:59 +00:00
|
|
|
export let viewOptionsConfig: ViewOptionModel[] | undefined
|
|
|
|
export let viewOptions: ViewOptions
|
2022-06-15 04:59:43 +00:00
|
|
|
|
2023-01-14 10:54:54 +00:00
|
|
|
$: currentSpace = space || tracker.team.DefaultTeam
|
2023-01-18 05:14:59 +00:00
|
|
|
$: groupBy = (viewOptions.groupBy ?? noCategory) as IssuesGrouping
|
|
|
|
$: orderBy = viewOptions.orderBy
|
2023-01-14 10:54:54 +00:00
|
|
|
$: sort = { [orderBy[0]]: orderBy[1] }
|
|
|
|
$: dontUpdateRank = orderBy[0] !== IssuesOrdering.Manual
|
2022-06-15 04:59:43 +00:00
|
|
|
|
2022-06-16 04:24:17 +00:00
|
|
|
const spaceQuery = createQuery()
|
|
|
|
const statusesQuery = createQuery()
|
|
|
|
|
|
|
|
let currentTeam: Team | undefined
|
|
|
|
$: spaceQuery.query(tracker.class.Team, { _id: currentSpace }, (res) => {
|
|
|
|
currentTeam = res.shift()
|
|
|
|
})
|
|
|
|
|
2023-01-14 10:54:54 +00:00
|
|
|
let resultQuery: DocumentQuery<any> = query
|
2023-01-18 05:14:59 +00:00
|
|
|
$: getResultQuery(query, viewOptionsConfig, viewOptions).then((p) => (resultQuery = p))
|
2023-01-14 10:54:54 +00:00
|
|
|
|
|
|
|
const client = getClient()
|
|
|
|
const hierarchy = client.getHierarchy()
|
|
|
|
|
|
|
|
async function getResultQuery (
|
|
|
|
query: DocumentQuery<Issue>,
|
|
|
|
viewOptions: ViewOptionModel[] | undefined,
|
|
|
|
viewOptionsStore: ViewOptions
|
|
|
|
): Promise<DocumentQuery<Issue>> {
|
|
|
|
if (viewOptions === undefined) return query
|
|
|
|
let result = hierarchy.clone(query)
|
|
|
|
for (const viewOption of viewOptions) {
|
|
|
|
if (viewOption.actionTartget !== 'query') continue
|
|
|
|
const queryOption = viewOption as ViewQueryOption
|
|
|
|
const f = await getResource(queryOption.action)
|
|
|
|
result = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, query)
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2022-06-16 04:24:17 +00:00
|
|
|
let issueStatuses: WithLookup<IssueStatus>[] | undefined
|
2022-07-06 06:11:32 +00:00
|
|
|
$: issueStatusStates = getIssueStatusStates(issueStatuses)
|
2022-06-16 04:24:17 +00:00
|
|
|
$: statusesQuery.query(
|
|
|
|
tracker.class.IssueStatus,
|
|
|
|
{ attachedTo: currentSpace },
|
|
|
|
(is) => {
|
|
|
|
issueStatuses = is
|
|
|
|
},
|
|
|
|
{
|
|
|
|
lookup: { category: tracker.class.IssueStatusCategory },
|
|
|
|
sort: { rank: SortingOrder.Ascending }
|
|
|
|
}
|
|
|
|
)
|
2022-06-15 04:59:43 +00:00
|
|
|
|
|
|
|
function toIssue (object: any): WithLookup<Issue> {
|
|
|
|
return object as WithLookup<Issue>
|
|
|
|
}
|
|
|
|
|
2022-06-28 06:53:39 +00:00
|
|
|
const lookup: Lookup<Issue> = {
|
|
|
|
assignee: contact.class.Employee,
|
|
|
|
space: tracker.class.Team,
|
|
|
|
_id: {
|
|
|
|
subIssues: tracker.class.Issue
|
2022-06-15 04:59:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let kanbanUI: Kanban
|
|
|
|
const listProvider = new ListSelectionProvider((offset: 1 | -1 | 0, of?: Doc, dir?: SelectDirection) => {
|
|
|
|
kanbanUI.select(offset, of, dir)
|
|
|
|
})
|
|
|
|
onMount(() => {
|
|
|
|
;(document.activeElement as HTMLElement)?.blur()
|
|
|
|
})
|
|
|
|
|
|
|
|
const showMenu = async (ev: MouseEvent, items: Doc[]): Promise<void> => {
|
|
|
|
ev.preventDefault()
|
2022-08-05 07:48:31 +00:00
|
|
|
showPopup(Menu, { object: items, baseMenuClass }, getEventPositionElement(ev), () => {
|
|
|
|
// selection = undefined
|
|
|
|
})
|
2022-06-15 04:59:43 +00:00
|
|
|
}
|
2022-07-06 06:11:32 +00:00
|
|
|
const issuesQuery = createQuery()
|
|
|
|
let issueStates: TypeState[] = []
|
2023-01-14 10:54:54 +00:00
|
|
|
const lookupIssue: Lookup<Issue> = {
|
|
|
|
status: [tracker.class.IssueStatus, { category: tracker.class.IssueStatusCategory }],
|
|
|
|
project: tracker.class.Project,
|
|
|
|
sprint: tracker.class.Sprint,
|
|
|
|
assignee: contact.class.Employee
|
|
|
|
}
|
2022-07-06 06:11:32 +00:00
|
|
|
$: issuesQuery.query(
|
|
|
|
tracker.class.Issue,
|
|
|
|
resultQuery,
|
|
|
|
async (result) => {
|
|
|
|
issueStates = await getKanbanStatuses(groupBy, result)
|
|
|
|
},
|
|
|
|
{
|
2023-01-14 10:54:54 +00:00
|
|
|
lookup: lookupIssue,
|
2022-07-06 06:11:32 +00:00
|
|
|
sort: issuesGroupBySorting[groupBy]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
let priorityStates: TypeState[] = []
|
|
|
|
getPriorityStates().then((states) => {
|
|
|
|
priorityStates = states
|
|
|
|
})
|
|
|
|
function getIssueStates (
|
|
|
|
groupBy: IssuesGrouping,
|
|
|
|
states: TypeState[],
|
|
|
|
statusStates: TypeState[],
|
|
|
|
priorityStates: TypeState[]
|
|
|
|
) {
|
2023-01-14 10:54:54 +00:00
|
|
|
if (states.length > 0) return states
|
2022-07-06 06:11:32 +00:00
|
|
|
if (groupBy === IssuesGrouping.Status) return statusStates
|
|
|
|
if (groupBy === IssuesGrouping.Priority) return priorityStates
|
|
|
|
return []
|
|
|
|
}
|
2023-01-14 10:54:54 +00:00
|
|
|
$: states = getIssueStates(groupBy, issueStates, issueStatusStates, priorityStates)
|
2022-07-07 02:21:30 +00:00
|
|
|
|
|
|
|
const fullFilled: { [key: string]: boolean } = {}
|
2022-07-10 14:22:13 +00:00
|
|
|
const getState = (state: any): WithLookup<IssueStatus> | undefined => {
|
|
|
|
return issueStatuses?.filter((is) => is._id === state._id)[0]
|
|
|
|
}
|
2022-06-15 04:59:43 +00:00
|
|
|
</script>
|
|
|
|
|
2022-07-06 06:11:32 +00:00
|
|
|
{#if !states?.length}
|
|
|
|
<Loading />
|
|
|
|
{:else}
|
2022-06-15 04:59:43 +00:00
|
|
|
<ActionContext
|
|
|
|
context={{
|
|
|
|
mode: 'browser'
|
|
|
|
}}
|
|
|
|
/>
|
2023-01-18 05:14:59 +00:00
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
2022-06-15 04:59:43 +00:00
|
|
|
<Kanban
|
|
|
|
bind:this={kanbanUI}
|
|
|
|
_class={tracker.class.Issue}
|
|
|
|
{states}
|
2023-01-14 10:54:54 +00:00
|
|
|
{dontUpdateRank}
|
2022-06-28 06:53:39 +00:00
|
|
|
options={{ sort, lookup }}
|
2022-06-15 04:59:43 +00:00
|
|
|
query={resultQuery}
|
|
|
|
fieldName={groupBy}
|
|
|
|
on:content={(evt) => {
|
|
|
|
listProvider.update(evt.detail)
|
|
|
|
}}
|
|
|
|
on:obj-focus={(evt) => {
|
|
|
|
listProvider.updateFocus(evt.detail)
|
|
|
|
}}
|
|
|
|
selection={listProvider.current($focusStore)}
|
|
|
|
checked={$selectionStore ?? []}
|
|
|
|
on:check={(evt) => {
|
|
|
|
listProvider.updateSelection(evt.detail.docs, evt.detail.value)
|
|
|
|
}}
|
|
|
|
on:contextmenu={(evt) => showMenu(evt.detail.evt, evt.detail.objects)}
|
|
|
|
>
|
|
|
|
<svelte:fragment slot="header" let:state let:count>
|
2022-07-10 14:22:13 +00:00
|
|
|
{@const stateWLU = getState(state)}
|
2022-06-15 04:59:43 +00:00
|
|
|
<div class="header flex-col">
|
|
|
|
<div class="flex-between label font-medium w-full h-full">
|
|
|
|
<div class="flex-row-center gap-2">
|
2022-07-10 14:22:13 +00:00
|
|
|
{#if stateWLU !== undefined}<IssueStatusIcon value={stateWLU} size={'small'} />{/if}
|
2022-06-15 04:59:43 +00:00
|
|
|
<span class="lines-limit-2 ml-2">{state.title}</span>
|
|
|
|
<span class="counter ml-2 text-md">{count}</span>
|
|
|
|
</div>
|
2023-01-14 10:54:54 +00:00
|
|
|
<div class="flex gap-1">
|
|
|
|
<Button
|
|
|
|
icon={IconAdd}
|
|
|
|
kind={'transparent'}
|
|
|
|
showTooltip={{ label: tracker.string.AddIssueTooltip, direction: 'left' }}
|
|
|
|
on:click={() => {
|
|
|
|
showPopup(CreateIssue, { space: currentSpace, [groupBy]: state._id }, 'top')
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-06-15 04:59:43 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</svelte:fragment>
|
|
|
|
<svelte:fragment slot="card" let:object>
|
|
|
|
{@const issue = toIssue(object)}
|
2022-07-07 02:21:30 +00:00
|
|
|
{@const issueId = object._id}
|
2022-06-16 04:24:17 +00:00
|
|
|
<div
|
|
|
|
class="tracker-card"
|
|
|
|
on:click={() => {
|
|
|
|
showPanel(tracker.component.EditIssue, object._id, object._class, 'content')
|
|
|
|
}}
|
|
|
|
>
|
2022-07-07 02:21:30 +00:00
|
|
|
<div class="flex-col ml-4 mr-8">
|
2022-06-27 06:04:26 +00:00
|
|
|
<div class="flex clear-mins names">
|
|
|
|
<IssuePresenter value={issue} />
|
|
|
|
<ParentNamesPresenter value={issue} />
|
|
|
|
</div>
|
2022-07-05 10:01:40 +00:00
|
|
|
<div class="flex-row-center gap-1 mt-1">
|
2022-07-04 18:14:53 +00:00
|
|
|
{#if groupBy !== 'status'}
|
2022-07-05 10:01:40 +00:00
|
|
|
<StatusEditor value={issue} kind="list" isEditable={false} />
|
2022-07-04 18:14:53 +00:00
|
|
|
{/if}
|
2022-07-05 10:01:40 +00:00
|
|
|
<span class="fs-bold caption-color lines-limit-2">
|
2022-07-04 18:14:53 +00:00
|
|
|
{object.title}
|
|
|
|
</span>
|
|
|
|
</div>
|
2022-06-15 04:59:43 +00:00
|
|
|
</div>
|
|
|
|
<div class="abs-rt-content">
|
|
|
|
<AssigneePresenter
|
2022-06-16 04:24:17 +00:00
|
|
|
value={issue.$lookup?.assignee}
|
|
|
|
defaultClass={contact.class.Employee}
|
2023-01-14 10:54:54 +00:00
|
|
|
object={issue}
|
2022-06-15 04:59:43 +00:00
|
|
|
isEditable={true}
|
|
|
|
/>
|
2022-06-16 04:24:17 +00:00
|
|
|
<div class="flex-center mt-2">
|
|
|
|
<Component is={notification.component.NotificationPresenter} props={{ value: object }} />
|
|
|
|
</div>
|
2022-06-15 04:59:43 +00:00
|
|
|
</div>
|
2022-07-07 02:21:30 +00:00
|
|
|
<div class="buttons-group xsmall-gap states-bar">
|
2023-01-14 10:54:54 +00:00
|
|
|
{#if issue && issue.subIssues > 0}
|
|
|
|
<SubIssuesSelector value={issue} {currentTeam} />
|
2022-06-16 04:24:17 +00:00
|
|
|
{/if}
|
2022-06-17 08:28:31 +00:00
|
|
|
<PriorityEditor value={issue} isEditable={true} kind={'link-bordered'} size={'inline'} justify={'center'} />
|
2022-06-16 04:24:17 +00:00
|
|
|
<ProjectEditor
|
|
|
|
value={issue}
|
|
|
|
isEditable={true}
|
|
|
|
kind={'link-bordered'}
|
|
|
|
size={'inline'}
|
|
|
|
justify={'center'}
|
|
|
|
width={''}
|
2022-07-07 02:21:30 +00:00
|
|
|
bind:onlyIcon={fullFilled[issueId]}
|
2022-06-16 04:24:17 +00:00
|
|
|
/>
|
2022-10-11 11:50:56 +00:00
|
|
|
<EstimationEditor kind={'list'} size={'small'} value={issue} />
|
2022-07-07 02:21:30 +00:00
|
|
|
<div
|
|
|
|
class="clear-mins"
|
|
|
|
use:tooltip={{
|
|
|
|
component: fullFilled[issueId] ? tags.component.LabelsPresenter : undefined,
|
|
|
|
props: { object: issue, kind: 'full' }
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Component
|
|
|
|
is={tags.component.LabelsPresenter}
|
|
|
|
props={{ object: issue, ckeckFilled: fullFilled[issueId] }}
|
|
|
|
on:change={(res) => {
|
|
|
|
if (res.detail.full) fullFilled[issueId] = true
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-06-15 04:59:43 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</svelte:fragment>
|
|
|
|
</Kanban>
|
2022-07-06 06:11:32 +00:00
|
|
|
{/if}
|
2022-06-15 04:59:43 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
2022-06-27 06:04:26 +00:00
|
|
|
.names {
|
|
|
|
font-size: 0.8125rem;
|
|
|
|
}
|
|
|
|
|
2022-06-15 04:59:43 +00:00
|
|
|
.header {
|
|
|
|
padding-bottom: 0.75rem;
|
|
|
|
border-bottom: 1px solid var(--divider-color);
|
|
|
|
|
|
|
|
.label {
|
|
|
|
color: var(--caption-color);
|
|
|
|
.counter {
|
|
|
|
color: rgba(var(--caption-color), 0.8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.tracker-card {
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
2022-07-07 02:21:30 +00:00
|
|
|
// padding: 0.5rem 1rem;
|
2022-06-15 04:59:43 +00:00
|
|
|
min-height: 6.5rem;
|
|
|
|
}
|
2022-07-07 02:21:30 +00:00
|
|
|
.states-bar {
|
|
|
|
flex-shrink: 10;
|
|
|
|
width: fit-content;
|
|
|
|
margin: 0.625rem 1rem 0;
|
|
|
|
}
|
2022-06-15 04:59:43 +00:00
|
|
|
</style>
|