2022-04-08 06:27:02 +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 { IssueStatus } from '@anticrm/tracker'
|
2022-04-19 09:38:31 +00:00
|
|
|
import { Button, Icon, Label, showPopup, SelectPopup, eventToHTMLElement } from '@anticrm/ui'
|
2022-04-08 06:27:02 +00:00
|
|
|
import { issueStatuses } from '../utils'
|
|
|
|
import tracker from '../plugin'
|
|
|
|
|
|
|
|
export let status: IssueStatus
|
2022-04-12 17:41:32 +00:00
|
|
|
export let kind: 'button' | 'icon' = 'button'
|
|
|
|
export let shouldShowLabel: boolean = true
|
|
|
|
export let onStatusChange: ((newStatus: IssueStatus | undefined) => void) | undefined = undefined
|
2022-04-20 06:06:05 +00:00
|
|
|
export let isEditable: boolean = true
|
2022-04-08 06:27:02 +00:00
|
|
|
|
|
|
|
const statusesInfo = [
|
|
|
|
IssueStatus.Backlog,
|
|
|
|
IssueStatus.Todo,
|
|
|
|
IssueStatus.InProgress,
|
|
|
|
IssueStatus.Done,
|
|
|
|
IssueStatus.Canceled
|
|
|
|
].map((s) => ({ id: s, ...issueStatuses[s] }))
|
|
|
|
|
2022-04-19 09:38:31 +00:00
|
|
|
const handleStatusEditorOpened = (event: MouseEvent) => {
|
2022-04-20 06:06:05 +00:00
|
|
|
if (!isEditable) {
|
|
|
|
return
|
|
|
|
}
|
2022-04-08 06:27:02 +00:00
|
|
|
showPopup(
|
|
|
|
SelectPopup,
|
|
|
|
{ value: statusesInfo, placeholder: tracker.string.SetStatus, searchable: true },
|
2022-04-19 09:38:31 +00:00
|
|
|
eventToHTMLElement(event),
|
2022-04-12 17:41:32 +00:00
|
|
|
onStatusChange
|
2022-04-08 06:27:02 +00:00
|
|
|
)
|
2022-04-12 17:41:32 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if kind === 'button'}
|
|
|
|
<Button
|
|
|
|
label={shouldShowLabel ? issueStatuses[status].label : undefined}
|
|
|
|
icon={issueStatuses[status].icon}
|
|
|
|
width="min-content"
|
|
|
|
size="small"
|
|
|
|
kind="no-border"
|
|
|
|
on:click={handleStatusEditorOpened}
|
|
|
|
/>
|
|
|
|
{:else if kind === 'icon'}
|
2022-04-20 06:06:05 +00:00
|
|
|
<div class={isEditable ? 'flex-presenter' : 'presenter'} on:click={handleStatusEditorOpened}>
|
2022-04-14 06:07:07 +00:00
|
|
|
<div class="statusIcon">
|
2022-04-12 17:41:32 +00:00
|
|
|
<Icon icon={issueStatuses[status].icon} size={'small'} />
|
|
|
|
</div>
|
|
|
|
{#if shouldShowLabel}
|
2022-04-20 06:06:05 +00:00
|
|
|
<div class="label nowrap ml-2">
|
2022-04-12 17:41:32 +00:00
|
|
|
<Label label={issueStatuses[status].label} />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
{/if}
|
2022-04-14 06:07:07 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
2022-04-20 06:06:05 +00:00
|
|
|
.presenter {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-wrap: nowrap;
|
|
|
|
}
|
|
|
|
|
2022-04-14 06:07:07 +00:00
|
|
|
.statusIcon {
|
|
|
|
width: 1rem;
|
|
|
|
height: 1rem;
|
|
|
|
}
|
|
|
|
</style>
|