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">
|
|
|
|
import contact from '@anticrm/contact'
|
2022-06-28 06:53:39 +00:00
|
|
|
import { Class, Doc, DocumentQuery, Lookup, Ref, SortingOrder, WithLookup } from '@anticrm/core'
|
2022-07-06 06:11:32 +00:00
|
|
|
import { Kanban, TypeState } from '@anticrm/kanban'
|
2022-06-16 04:24:17 +00:00
|
|
|
import notification from '@anticrm/notification'
|
2022-07-06 06:11:32 +00:00
|
|
|
import { createQuery } from '@anticrm/presentation'
|
2022-07-10 15:29:59 +00:00
|
|
|
import { Issue, IssuesGrouping, IssuesOrdering, IssueStatus, Team } from '@anticrm/tracker'
|
2022-07-10 14:22:13 +00:00
|
|
|
import { Button, Component, IconAdd, showPanel, showPopup, Loading, tooltip } from '@anticrm/ui'
|
2022-06-15 04:59:43 +00:00
|
|
|
import { focusStore, ListSelectionProvider, SelectDirection, selectionStore } from '@anticrm/view-resources'
|
|
|
|
import ActionContext from '@anticrm/view-resources/src/components/ActionContext.svelte'
|
|
|
|
import Menu from '@anticrm/view-resources/src/components/Menu.svelte'
|
|
|
|
import { onMount } from 'svelte'
|
|
|
|
import tracker from '../../plugin'
|
2022-07-06 06:11:32 +00:00
|
|
|
import {
|
|
|
|
getIssueStatusStates,
|
|
|
|
getKanbanStatuses,
|
|
|
|
getPriorityStates,
|
|
|
|
issuesGroupBySorting,
|
2022-07-10 14:22:13 +00:00
|
|
|
issuesSortOrderMap
|
2022-07-06 06:11:32 +00:00
|
|
|
} 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-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-07-07 02:21:30 +00:00
|
|
|
import tags from '@anticrm/tags'
|
2022-07-10 14:22:13 +00:00
|
|
|
import IssueStatusIcon from './IssueStatusIcon.svelte'
|
2022-06-15 04:59:43 +00:00
|
|
|
|
2022-06-23 11:09:18 +00:00
|
|
|
export let currentSpace: Ref<Team> = tracker.team.DefaultTeam
|
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> = {}
|
2022-07-10 15:29:59 +00:00
|
|
|
export let viewOptions: {
|
|
|
|
groupBy: IssuesGrouping
|
|
|
|
orderBy: IssuesOrdering
|
|
|
|
shouldShowEmptyGroups: boolean
|
|
|
|
shouldShowSubIssues: boolean
|
|
|
|
}
|
2022-06-15 04:59:43 +00:00
|
|
|
|
2022-06-23 11:09:18 +00:00
|
|
|
$: currentSpace = typeof query.space === 'string' ? query.space : tracker.team.DefaultTeam
|
2022-06-28 06:53:39 +00:00
|
|
|
$: ({ groupBy, orderBy, shouldShowEmptyGroups, shouldShowSubIssues } = viewOptions)
|
|
|
|
$: sort = { [orderBy]: issuesSortOrderMap[orderBy] }
|
|
|
|
$: rankFieldName = orderBy === IssuesOrdering.Manual ? orderBy : undefined
|
2022-06-15 04:59:43 +00:00
|
|
|
$: resultQuery = {
|
|
|
|
...(shouldShowSubIssues ? {} : { attachedTo: tracker.ids.NoParent }),
|
|
|
|
...query
|
2022-06-23 11:09:18 +00:00
|
|
|
} as any
|
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()
|
|
|
|
})
|
|
|
|
|
|
|
|
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()
|
|
|
|
showPopup(
|
|
|
|
Menu,
|
|
|
|
{ object: items, baseMenuClass },
|
|
|
|
{
|
|
|
|
getBoundingClientRect: () => DOMRect.fromRect({ width: 1, height: 1, x: ev.clientX, y: ev.clientY })
|
|
|
|
},
|
|
|
|
() => {
|
|
|
|
// selection = undefined
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2022-07-06 06:11:32 +00:00
|
|
|
const issuesQuery = createQuery()
|
|
|
|
let issueStates: TypeState[] = []
|
|
|
|
$: issuesQuery.query(
|
|
|
|
tracker.class.Issue,
|
|
|
|
resultQuery,
|
|
|
|
async (result) => {
|
|
|
|
issueStates = await getKanbanStatuses(groupBy, result)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
lookup: {
|
|
|
|
status: [tracker.class.IssueStatus, { category: tracker.class.IssueStatusCategory }],
|
|
|
|
project: tracker.class.Project,
|
|
|
|
assignee: contact.class.Employee
|
|
|
|
},
|
|
|
|
sort: issuesGroupBySorting[groupBy]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
let priorityStates: TypeState[] = []
|
|
|
|
getPriorityStates().then((states) => {
|
|
|
|
priorityStates = states
|
|
|
|
})
|
|
|
|
function getIssueStates (
|
|
|
|
groupBy: IssuesGrouping,
|
|
|
|
showEmptyGroups: boolean,
|
|
|
|
states: TypeState[],
|
|
|
|
statusStates: TypeState[],
|
|
|
|
priorityStates: TypeState[]
|
|
|
|
) {
|
2022-07-30 09:30:26 +00:00
|
|
|
if (!showEmptyGroups && 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 []
|
|
|
|
}
|
|
|
|
$: states = getIssueStates(groupBy, shouldShowEmptyGroups, 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'
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Kanban
|
|
|
|
bind:this={kanbanUI}
|
|
|
|
_class={tracker.class.Issue}
|
|
|
|
search=""
|
|
|
|
{states}
|
2022-06-28 06:53:39 +00:00
|
|
|
options={{ sort, lookup }}
|
2022-06-15 04:59:43 +00:00
|
|
|
query={resultQuery}
|
|
|
|
fieldName={groupBy}
|
2022-06-28 06:53:39 +00:00
|
|
|
{rankFieldName}
|
2022-06-15 04:59:43 +00:00
|
|
|
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>
|
|
|
|
{#if groupBy === IssuesGrouping.Status}
|
|
|
|
<div class="flex gap-1">
|
2022-06-30 03:41:46 +00:00
|
|
|
<Button
|
|
|
|
icon={IconAdd}
|
|
|
|
kind={'transparent'}
|
|
|
|
showTooltip={{ label: tracker.string.AddIssueTooltip, direction: 'left' }}
|
|
|
|
on:click={() => {
|
|
|
|
showPopup(CreateIssue, { space: currentSpace, status: state._id }, 'top')
|
|
|
|
}}
|
|
|
|
/>
|
2022-06-15 04:59:43 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</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}
|
2022-06-15 04:59:43 +00:00
|
|
|
issueId={issue._id}
|
|
|
|
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">
|
2022-06-16 04:24:17 +00:00
|
|
|
{#if issue && issueStatuses && issue.subIssues > 0}
|
|
|
|
<SubIssuesSelector {issue} {currentTeam} {issueStatuses} />
|
|
|
|
{/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-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>
|