2022-03-31 08:32:42 +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-04-08 06:27:02 +00:00
|
|
|
import contact, { Employee } from '@anticrm/contact'
|
2022-03-31 08:32:42 +00:00
|
|
|
import core, { Data, generateId, Ref, SortingOrder } from '@anticrm/core'
|
2022-04-08 03:01:44 +00:00
|
|
|
import { Asset, IntlString } from '@anticrm/platform'
|
2022-04-08 06:27:02 +00:00
|
|
|
import { getClient, UserBox } from '@anticrm/presentation'
|
2022-03-31 08:32:42 +00:00
|
|
|
import { Issue, IssuePriority, IssueStatus, Team } from '@anticrm/tracker'
|
2022-04-08 06:27:02 +00:00
|
|
|
import { StyledTextBox } from '@anticrm/text-editor'
|
2022-04-09 03:46:40 +00:00
|
|
|
import { EditBox, Button, showPopup, DatePresenter, SelectPopup } from '@anticrm/ui'
|
2022-03-31 08:32:42 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
|
|
|
import tracker from '../plugin'
|
|
|
|
import { calcRank } from '../utils'
|
2022-04-02 04:06:48 +00:00
|
|
|
import Card from './Card.svelte'
|
2022-04-08 06:27:02 +00:00
|
|
|
import StatusSelector from './StatusSelector.svelte'
|
|
|
|
import PrioritySelector from './PrioritySelector.svelte'
|
2022-03-31 08:32:42 +00:00
|
|
|
|
|
|
|
export let space: Ref<Team>
|
|
|
|
export let parent: Ref<Issue> | undefined
|
2022-04-08 03:01:44 +00:00
|
|
|
export let issueStatus = IssueStatus.Backlog
|
2022-03-31 08:32:42 +00:00
|
|
|
$: _space = space
|
|
|
|
$: _parent = parent
|
|
|
|
|
2022-04-08 06:27:02 +00:00
|
|
|
let assignee: Ref<Employee> | null = null
|
2022-03-31 08:32:42 +00:00
|
|
|
|
|
|
|
const object: Data<Issue> = {
|
|
|
|
title: '',
|
|
|
|
description: '',
|
|
|
|
assignee: null,
|
|
|
|
number: 0,
|
|
|
|
rank: '',
|
2022-04-08 03:01:44 +00:00
|
|
|
status: issueStatus,
|
2022-03-31 08:32:42 +00:00
|
|
|
priority: IssuePriority.NoPriority,
|
|
|
|
dueDate: null,
|
|
|
|
comments: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
const client = getClient()
|
|
|
|
const taskId: Ref<Issue> = generateId()
|
|
|
|
|
|
|
|
export function canClose (): boolean {
|
|
|
|
return object.title !== ''
|
|
|
|
}
|
|
|
|
|
|
|
|
async function createIssue () {
|
|
|
|
const lastOne = await client.findOne<Issue>(
|
|
|
|
tracker.class.Issue,
|
|
|
|
{ status: object.status },
|
|
|
|
{ sort: { rank: SortingOrder.Descending } }
|
|
|
|
)
|
|
|
|
const incResult = await client.updateDoc(
|
|
|
|
tracker.class.Team,
|
|
|
|
core.space.Space,
|
|
|
|
_space,
|
|
|
|
{
|
|
|
|
$inc: { sequence: 1 }
|
|
|
|
},
|
|
|
|
true
|
|
|
|
)
|
|
|
|
|
|
|
|
const value: Data<Issue> = {
|
|
|
|
title: object.title,
|
|
|
|
description: object.description,
|
|
|
|
assignee,
|
|
|
|
number: (incResult as any).object.sequence,
|
|
|
|
status: object.status,
|
|
|
|
priority: object.priority,
|
|
|
|
rank: calcRank(lastOne, undefined),
|
|
|
|
parentIssue: _parent,
|
|
|
|
comments: 0,
|
|
|
|
dueDate: object.dueDate
|
|
|
|
}
|
|
|
|
|
|
|
|
await client.createDoc(tracker.class.Issue, _space, value, taskId)
|
|
|
|
}
|
2022-04-02 04:06:48 +00:00
|
|
|
|
2022-04-08 06:27:02 +00:00
|
|
|
const moreActions: Array<{ icon: Asset; label: IntlString }> = [
|
|
|
|
{ icon: tracker.icon.DueDate, label: tracker.string.DueDate },
|
|
|
|
{ icon: tracker.icon.Parent, label: tracker.string.Parent }
|
|
|
|
]
|
2022-04-12 17:04:29 +00:00
|
|
|
|
2022-04-08 18:17:04 +00:00
|
|
|
let issueDate: number | null = null
|
2022-04-12 17:04:29 +00:00
|
|
|
|
|
|
|
const handlePriorityChanged = (newPriority: IssuePriority | undefined) => {
|
|
|
|
if (newPriority === undefined) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
object.priority = newPriority
|
|
|
|
}
|
2022-03-31 08:32:42 +00:00
|
|
|
</script>
|
|
|
|
|
2022-04-02 04:06:48 +00:00
|
|
|
<!-- canSave: object.title.length > 0 && _space != null -->
|
2022-03-31 08:32:42 +00:00
|
|
|
<Card
|
|
|
|
label={tracker.string.NewIssue}
|
|
|
|
okAction={createIssue}
|
2022-04-02 04:06:48 +00:00
|
|
|
icon={tracker.icon.Home}
|
|
|
|
canSave={true}
|
|
|
|
okLabel={tracker.string.SaveIssue}
|
2022-03-31 08:32:42 +00:00
|
|
|
spaceClass={tracker.class.Team}
|
|
|
|
spaceLabel={tracker.string.Team}
|
|
|
|
spacePlaceholder={tracker.string.SelectTeam}
|
2022-04-02 04:06:48 +00:00
|
|
|
createMore={false}
|
2022-03-31 08:32:42 +00:00
|
|
|
bind:space={_space}
|
|
|
|
on:close={() => {
|
|
|
|
dispatch('close')
|
|
|
|
}}
|
|
|
|
>
|
2022-04-02 04:06:48 +00:00
|
|
|
<EditBox
|
|
|
|
bind:value={object.title}
|
|
|
|
placeholder={tracker.string.IssueTitlePlaceholder}
|
|
|
|
maxWidth={'37.5rem'}
|
|
|
|
kind={'large-style'}
|
|
|
|
focus
|
|
|
|
/>
|
2022-04-08 06:27:02 +00:00
|
|
|
<div class="mt-4">
|
|
|
|
<StyledTextBox
|
|
|
|
alwaysEdit
|
|
|
|
showButtons={false}
|
|
|
|
bind:content={object.description}
|
|
|
|
placeholder={tracker.string.IssueDescriptionPlaceholder}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-04-02 04:06:48 +00:00
|
|
|
<div slot="pool" class="flex-row-center text-sm gap-1-5">
|
2022-04-08 06:27:02 +00:00
|
|
|
<StatusSelector bind:status={object.status} />
|
2022-04-12 17:04:29 +00:00
|
|
|
<PrioritySelector priority={object.priority} onPriorityChange={handlePriorityChanged} />
|
2022-04-08 06:27:02 +00:00
|
|
|
<UserBox
|
|
|
|
_class={contact.class.Employee}
|
2022-04-09 03:46:40 +00:00
|
|
|
label={tracker.string.Assignee}
|
|
|
|
placeholder={tracker.string.AssignTo}
|
2022-04-08 06:27:02 +00:00
|
|
|
bind:value={assignee}
|
|
|
|
allowDeselect
|
2022-04-09 03:46:40 +00:00
|
|
|
titleDeselect={tracker.string.Unassigned}
|
2022-04-08 06:27:02 +00:00
|
|
|
/>
|
2022-04-02 04:06:48 +00:00
|
|
|
<Button
|
2022-04-08 06:27:02 +00:00
|
|
|
label={tracker.string.Labels}
|
|
|
|
icon={tracker.icon.Labels}
|
|
|
|
width="min-content"
|
|
|
|
size="small"
|
|
|
|
kind="no-border"
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
label={tracker.string.Project}
|
|
|
|
icon={tracker.icon.Projects}
|
|
|
|
width="min-content"
|
|
|
|
size="small"
|
|
|
|
kind="no-border"
|
2022-03-31 08:32:42 +00:00
|
|
|
/>
|
2022-04-08 18:17:04 +00:00
|
|
|
<DatePresenter value={issueDate} editable />
|
2022-04-02 04:06:48 +00:00
|
|
|
<Button
|
2022-04-08 06:27:02 +00:00
|
|
|
icon={tracker.icon.MoreActions}
|
|
|
|
width="min-content"
|
|
|
|
size="small"
|
|
|
|
kind="transparent"
|
2022-04-02 04:06:48 +00:00
|
|
|
on:click={(ev) => {
|
2022-04-08 06:27:02 +00:00
|
|
|
showPopup(SelectPopup, { value: moreActions }, ev.currentTarget)
|
2022-04-02 04:06:48 +00:00
|
|
|
}}
|
2022-03-31 08:32:42 +00:00
|
|
|
/>
|
2022-04-02 04:06:48 +00:00
|
|
|
</div>
|
2022-03-31 08:32:42 +00:00
|
|
|
</Card>
|