2022-05-18 04:04:54 +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-06-06 15:52:30 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
2022-05-18 04:04:54 +00:00
|
|
|
import { Employee } from '@anticrm/contact'
|
2022-06-06 15:52:30 +00:00
|
|
|
import { AttachedData, Ref } from '@anticrm/core'
|
2022-06-29 05:51:29 +00:00
|
|
|
import { getClient, EmployeeBox } from '@anticrm/presentation'
|
2022-05-18 04:04:54 +00:00
|
|
|
import { Issue } from '@anticrm/tracker'
|
2022-06-21 03:53:48 +00:00
|
|
|
import { ButtonKind, ButtonSize, TooltipAlignment } from '@anticrm/ui'
|
2022-05-18 04:04:54 +00:00
|
|
|
import tracker from '../../plugin'
|
|
|
|
|
2022-06-06 15:52:30 +00:00
|
|
|
export let value: Issue | AttachedData<Issue>
|
|
|
|
export let size: ButtonSize = 'large'
|
|
|
|
export let kind: ButtonKind = 'link'
|
|
|
|
export let tooltipAlignment: TooltipAlignment | undefined = undefined
|
2022-06-21 08:53:19 +00:00
|
|
|
export let width: string = '100%'
|
2022-05-18 04:04:54 +00:00
|
|
|
|
|
|
|
const client = getClient()
|
2022-06-06 15:52:30 +00:00
|
|
|
const dispatch = createEventDispatcher()
|
2022-05-18 04:04:54 +00:00
|
|
|
|
|
|
|
const handleAssigneeChanged = async (newAssignee: Ref<Employee> | undefined) => {
|
|
|
|
if (newAssignee === undefined || value.assignee === newAssignee) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-06-06 15:52:30 +00:00
|
|
|
dispatch('change', newAssignee)
|
|
|
|
|
|
|
|
if ('_id' in value) {
|
|
|
|
await client.update(value, { assignee: newAssignee })
|
|
|
|
}
|
2022-05-18 04:04:54 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if value}
|
2022-06-29 05:51:29 +00:00
|
|
|
<EmployeeBox
|
2022-06-21 03:53:48 +00:00
|
|
|
label={tracker.string.Assignee}
|
|
|
|
placeholder={tracker.string.Assignee}
|
|
|
|
value={value.assignee}
|
|
|
|
allowDeselect
|
|
|
|
titleDeselect={tracker.string.Unassigned}
|
|
|
|
{size}
|
|
|
|
{kind}
|
2022-06-21 08:53:19 +00:00
|
|
|
{width}
|
2022-06-21 03:53:48 +00:00
|
|
|
justify={'left'}
|
|
|
|
showTooltip={{ label: tracker.string.AssignTo, direction: tooltipAlignment }}
|
|
|
|
on:change={({ detail }) => handleAssigneeChanged(detail)}
|
|
|
|
/>
|
2022-05-18 04:04:54 +00:00
|
|
|
{/if}
|