2022-04-23 16:59:57 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
2022-11-01 15:46:26 +00:00
|
|
|
//
|
2022-04-23 16:59:57 +00:00
|
|
|
// 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
|
2022-11-01 15:46:26 +00:00
|
|
|
//
|
2022-04-23 16:59:57 +00:00
|
|
|
// 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.
|
2022-11-01 15:46:26 +00:00
|
|
|
//
|
2022-04-23 16:59:57 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
2022-03-31 08:32:42 +00:00
|
|
|
<script lang="ts">
|
2022-12-08 01:17:53 +00:00
|
|
|
import { Ref, Space } from '@hcengineering/core'
|
2023-06-07 12:52:04 +00:00
|
|
|
import { MultipleDraftController } from '@hcengineering/presentation'
|
2023-04-27 16:52:31 +00:00
|
|
|
import { Button, IconAdd, showPopup } from '@hcengineering/ui'
|
|
|
|
import { onDestroy } from 'svelte'
|
2022-03-31 08:32:42 +00:00
|
|
|
import tracker from '../plugin'
|
|
|
|
import CreateIssue from './CreateIssue.svelte'
|
2022-05-06 06:42:45 +00:00
|
|
|
|
|
|
|
export let currentSpace: Ref<Space> | undefined
|
|
|
|
|
2023-04-27 16:52:31 +00:00
|
|
|
let closed = true
|
2022-05-06 06:42:45 +00:00
|
|
|
|
2023-04-27 16:52:31 +00:00
|
|
|
let draftExists = false
|
|
|
|
|
|
|
|
const draftController = new MultipleDraftController(tracker.ids.IssueDraft)
|
|
|
|
onDestroy(
|
|
|
|
draftController.hasNext((res) => {
|
|
|
|
draftExists = res
|
|
|
|
})
|
|
|
|
)
|
2022-04-28 09:53:35 +00:00
|
|
|
async function newIssue (): Promise<void> {
|
2023-04-27 16:52:31 +00:00
|
|
|
closed = false
|
2023-06-07 12:52:04 +00:00
|
|
|
showPopup(CreateIssue, { space: currentSpace, shouldSaveDraft: true }, 'top', () => {
|
2023-06-06 11:13:45 +00:00
|
|
|
closed = true
|
|
|
|
})
|
2022-03-31 08:32:42 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2023-04-05 07:14:32 +00:00
|
|
|
<div class="antiNav-subheader">
|
|
|
|
<Button
|
|
|
|
icon={IconAdd}
|
2023-04-27 16:52:31 +00:00
|
|
|
label={draftExists || !closed ? tracker.string.ResumeDraft : tracker.string.NewIssue}
|
2023-04-05 07:14:32 +00:00
|
|
|
justify={'left'}
|
|
|
|
kind={'primary'}
|
|
|
|
width={'100%'}
|
|
|
|
size={'large'}
|
|
|
|
on:click={newIssue}
|
|
|
|
id="new-issue"
|
|
|
|
>
|
|
|
|
<div slot="content" class="draft-circle-container">
|
|
|
|
{#if draftExists}
|
|
|
|
<div class="draft-circle" />
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</Button>
|
2022-03-31 08:32:42 +00:00
|
|
|
</div>
|
2022-11-01 15:46:26 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.draft-circle-container {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.draft-circle {
|
|
|
|
height: 6px;
|
|
|
|
width: 6px;
|
|
|
|
background-color: var(--primary-bg-color);
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
</style>
|