Fixed attachments for subissues (#2423)

Signed-off-by: Anton Brechka <anton.brechka@xored.com>
This commit is contained in:
mrsadman99 2022-12-07 12:03:11 +07:00 committed by GitHub
parent 643811c8f0
commit c46e9605f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 10 deletions

View File

@ -35,6 +35,7 @@
export let buttonSize: IconSize = 'small'
export let maxHeight: 'max' | 'card' | 'limited' | string = 'max'
export let focusable: boolean = false
export let refContainer: HTMLElement | undefined = undefined
export function attach (): void {
inputFile.click()
@ -163,7 +164,28 @@
return Promise.all(promises).then()
}
function isAllowedPaste (evt: ClipboardEvent) {
let t: HTMLElement | null = evt.target as HTMLElement
if (!refContainer) {
return true
}
while (t != null) {
t = t.parentElement
if (t === refContainer) {
return true
}
}
return false
}
function pasteAction (evt: ClipboardEvent): void {
if (!isAllowedPaste(evt)) {
return
}
const items = evt.clipboardData?.items ?? []
for (const index in items) {
const item = items[index]

View File

@ -16,7 +16,6 @@
import { createEventDispatcher } from 'svelte'
import core, { Account, AttachedData, Doc, generateId, Ref, SortingOrder, WithLookup } from '@hcengineering/core'
import presentation, { getClient, KeyedAttribute } from '@hcengineering/presentation'
import { StyledTextArea } from '@hcengineering/text-editor'
import { IssueStatus, IssuePriority, Issue, Team, calcRank } from '@hcengineering/tracker'
import { addNotification, Button, Component, EditBox } from '@hcengineering/ui'
import tags, { TagElement, TagReference } from '@hcengineering/tags'
@ -25,6 +24,7 @@
import StatusEditor from '../StatusEditor.svelte'
import PriorityEditor from '../PriorityEditor.svelte'
import EstimationEditor from '../timereport/EstimationEditor.svelte'
import { AttachmentStyledBox } from '@hcengineering/attachment-resources'
import IssueNotification from '../IssueNotification.svelte'
import { translate } from '@hcengineering/platform'
@ -39,7 +39,9 @@
let thisRef: HTMLDivElement
let focusIssueTitle: () => void
let labels: TagReference[] = []
let descriptionBox: AttachmentStyledBox
const objectId: Ref<Issue> = generateId()
const key: KeyedAttribute = {
key: 'labels',
attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels')
@ -110,14 +112,18 @@
parents: [{ parentId: parentIssue._id, parentTitle: parentIssue.title }, ...parentIssue.parents]
}
const objectId = await client.addCollection(
await client.addCollection(
tracker.class.Issue,
space,
parentIssue._id,
parentIssue._class,
'subIssues',
value
value,
objectId
)
await descriptionBox.createAttachments()
for (const label of labels) {
await client.addCollection(label._class, label.space, objectId, tracker.class.Issue, 'labels', {
title: label.title,
@ -185,13 +191,19 @@
focus
/>
<div class="mt-4">
{#key newIssue.description}
<StyledTextArea
<AttachmentStyledBox
bind:this={descriptionBox}
{objectId}
refContainer={thisRef}
_class={tracker.class.Issue}
space={currentTeam._id}
alwaysEdit
showButtons
maxHeight={'20vh'}
bind:content={newIssue.description}
placeholder={tracker.string.IssueDescriptionPlaceholder}
showButtons={false}
on:changeSize={() => dispatch('changeContent')}
/>
{/key}
</div>
</div>
</div>