mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Fixed attachments for subissues (#2423)
Signed-off-by: Anton Brechka <anton.brechka@xored.com>
This commit is contained in:
parent
643811c8f0
commit
c46e9605f7
@ -35,6 +35,7 @@
|
|||||||
export let buttonSize: IconSize = 'small'
|
export let buttonSize: IconSize = 'small'
|
||||||
export let maxHeight: 'max' | 'card' | 'limited' | string = 'max'
|
export let maxHeight: 'max' | 'card' | 'limited' | string = 'max'
|
||||||
export let focusable: boolean = false
|
export let focusable: boolean = false
|
||||||
|
export let refContainer: HTMLElement | undefined = undefined
|
||||||
|
|
||||||
export function attach (): void {
|
export function attach (): void {
|
||||||
inputFile.click()
|
inputFile.click()
|
||||||
@ -163,7 +164,28 @@
|
|||||||
return Promise.all(promises).then()
|
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 {
|
function pasteAction (evt: ClipboardEvent): void {
|
||||||
|
if (!isAllowedPaste(evt)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const items = evt.clipboardData?.items ?? []
|
const items = evt.clipboardData?.items ?? []
|
||||||
for (const index in items) {
|
for (const index in items) {
|
||||||
const item = items[index]
|
const item = items[index]
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import core, { Account, AttachedData, Doc, generateId, Ref, SortingOrder, WithLookup } from '@hcengineering/core'
|
import core, { Account, AttachedData, Doc, generateId, Ref, SortingOrder, WithLookup } from '@hcengineering/core'
|
||||||
import presentation, { getClient, KeyedAttribute } from '@hcengineering/presentation'
|
import presentation, { getClient, KeyedAttribute } from '@hcengineering/presentation'
|
||||||
import { StyledTextArea } from '@hcengineering/text-editor'
|
|
||||||
import { IssueStatus, IssuePriority, Issue, Team, calcRank } from '@hcengineering/tracker'
|
import { IssueStatus, IssuePriority, Issue, Team, calcRank } from '@hcengineering/tracker'
|
||||||
import { addNotification, Button, Component, EditBox } from '@hcengineering/ui'
|
import { addNotification, Button, Component, EditBox } from '@hcengineering/ui'
|
||||||
import tags, { TagElement, TagReference } from '@hcengineering/tags'
|
import tags, { TagElement, TagReference } from '@hcengineering/tags'
|
||||||
@ -25,6 +24,7 @@
|
|||||||
import StatusEditor from '../StatusEditor.svelte'
|
import StatusEditor from '../StatusEditor.svelte'
|
||||||
import PriorityEditor from '../PriorityEditor.svelte'
|
import PriorityEditor from '../PriorityEditor.svelte'
|
||||||
import EstimationEditor from '../timereport/EstimationEditor.svelte'
|
import EstimationEditor from '../timereport/EstimationEditor.svelte'
|
||||||
|
import { AttachmentStyledBox } from '@hcengineering/attachment-resources'
|
||||||
import IssueNotification from '../IssueNotification.svelte'
|
import IssueNotification from '../IssueNotification.svelte'
|
||||||
import { translate } from '@hcengineering/platform'
|
import { translate } from '@hcengineering/platform'
|
||||||
|
|
||||||
@ -39,7 +39,9 @@
|
|||||||
let thisRef: HTMLDivElement
|
let thisRef: HTMLDivElement
|
||||||
let focusIssueTitle: () => void
|
let focusIssueTitle: () => void
|
||||||
let labels: TagReference[] = []
|
let labels: TagReference[] = []
|
||||||
|
let descriptionBox: AttachmentStyledBox
|
||||||
|
|
||||||
|
const objectId: Ref<Issue> = generateId()
|
||||||
const key: KeyedAttribute = {
|
const key: KeyedAttribute = {
|
||||||
key: 'labels',
|
key: 'labels',
|
||||||
attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels')
|
attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels')
|
||||||
@ -110,14 +112,18 @@
|
|||||||
parents: [{ parentId: parentIssue._id, parentTitle: parentIssue.title }, ...parentIssue.parents]
|
parents: [{ parentId: parentIssue._id, parentTitle: parentIssue.title }, ...parentIssue.parents]
|
||||||
}
|
}
|
||||||
|
|
||||||
const objectId = await client.addCollection(
|
await client.addCollection(
|
||||||
tracker.class.Issue,
|
tracker.class.Issue,
|
||||||
space,
|
space,
|
||||||
parentIssue._id,
|
parentIssue._id,
|
||||||
parentIssue._class,
|
parentIssue._class,
|
||||||
'subIssues',
|
'subIssues',
|
||||||
value
|
value,
|
||||||
|
objectId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await descriptionBox.createAttachments()
|
||||||
|
|
||||||
for (const label of labels) {
|
for (const label of labels) {
|
||||||
await client.addCollection(label._class, label.space, objectId, tracker.class.Issue, 'labels', {
|
await client.addCollection(label._class, label.space, objectId, tracker.class.Issue, 'labels', {
|
||||||
title: label.title,
|
title: label.title,
|
||||||
@ -185,13 +191,19 @@
|
|||||||
focus
|
focus
|
||||||
/>
|
/>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
{#key newIssue.description}
|
<AttachmentStyledBox
|
||||||
<StyledTextArea
|
bind:this={descriptionBox}
|
||||||
bind:content={newIssue.description}
|
{objectId}
|
||||||
placeholder={tracker.string.IssueDescriptionPlaceholder}
|
refContainer={thisRef}
|
||||||
showButtons={false}
|
_class={tracker.class.Issue}
|
||||||
/>
|
space={currentTeam._id}
|
||||||
{/key}
|
alwaysEdit
|
||||||
|
showButtons
|
||||||
|
maxHeight={'20vh'}
|
||||||
|
bind:content={newIssue.description}
|
||||||
|
placeholder={tracker.string.IssueDescriptionPlaceholder}
|
||||||
|
on:changeSize={() => dispatch('changeContent')}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user