add/delete/edit attachments at issue (#2184)

Signed-off-by: budaeva <irina.budaeva@xored.com>
This commit is contained in:
budaeva 2022-07-01 22:31:08 +07:00 committed by GitHub
parent 69a8d16db4
commit 6b0b3a51b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 13 deletions

View File

@ -47,6 +47,13 @@
const impl = await getResource(saveAttachmentAction.action) const impl = await getResource(saveAttachmentAction.action)
await impl(attachment, evt) await impl(attachment, evt)
} }
},
{
label: attachmentPlugin.string.DeleteFile,
action: async (evt: MouseEvent) => {
const impl = await getResource(attachmentPlugin.actionImpl.DeleteAttachment)
await impl(attachment, evt)
}
} }
] ]
}, },

View File

@ -193,7 +193,7 @@
> >
<StyledTextBox bind:this={refInput} bind:content {placeholder} {alwaysEdit} {showButtons} {maxHeight} /> <StyledTextBox bind:this={refInput} bind:content {placeholder} {alwaysEdit} {showButtons} {maxHeight} />
{#if attachments.size} {#if attachments.size}
<div class="flex-row-center list scroll-divider-color"> <div class="flex-row-center list scroll-divider-color mt-1">
{#each Array.from(attachments.values()) as attachment} {#each Array.from(attachments.values()) as attachment}
<div class="item flex"> <div class="item flex">
<AttachmentPresenter <AttachmentPresenter

View File

@ -208,6 +208,19 @@ export async function DeleteAttachmentFromSaved (attach: Attachment): Promise<vo
} }
} }
export async function DeleteAttachment (attach: Attachment): Promise<void> {
const client = getClient()
await client.removeCollection(
attach._class,
attach.space,
attach._id,
attach.attachedTo,
attach.attachedToClass,
'attachments'
)
}
export default async (): Promise<Resources> => ({ export default async (): Promise<Resources> => ({
component: { component: {
AttachmentsPresenter, AttachmentsPresenter,
@ -226,6 +239,7 @@ export default async (): Promise<Resources> => ({
}, },
actionImpl: { actionImpl: {
AddAttachmentToSaved, AddAttachmentToSaved,
DeleteAttachmentFromSaved DeleteAttachmentFromSaved,
DeleteAttachment
} }
}) })

View File

@ -46,6 +46,7 @@ export default mergeIds(attachmentId, attachment, {
}, },
actionImpl: { actionImpl: {
AddAttachmentToSaved: '' as ViewAction, AddAttachmentToSaved: '' as ViewAction,
DeleteAttachmentFromSaved: '' as ViewAction DeleteAttachmentFromSaved: '' as ViewAction,
DeleteAttachment: '' as ViewAction
} }
}) })

View File

@ -13,17 +13,17 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { AttachmentDocList } from '@anticrm/attachment-resources' import { AttachmentDocList, AttachmentStyledBox } from '@anticrm/attachment-resources'
import { Class, Data, Doc, Ref, SortingOrder, WithLookup } from '@anticrm/core' import { Class, Data, Doc, Ref, SortingOrder, WithLookup } from '@anticrm/core'
import notification from '@anticrm/notification' import notification from '@anticrm/notification'
import { Panel } from '@anticrm/panel' import { Panel } from '@anticrm/panel'
import { getResource } from '@anticrm/platform' import { getResource } from '@anticrm/platform'
import presentation, { createQuery, getClient, MessageViewer } from '@anticrm/presentation' import presentation, { createQuery, getClient, MessageViewer } from '@anticrm/presentation'
import { StyledTextArea } from '@anticrm/text-editor'
import type { Issue, IssueStatus, Team } from '@anticrm/tracker' import type { Issue, IssueStatus, Team } from '@anticrm/tracker'
import { import {
Button, Button,
EditBox, EditBox,
IconAttachment,
IconDownOutline, IconDownOutline,
IconEdit, IconEdit,
IconMoreH, IconMoreH,
@ -60,6 +60,7 @@
let description = '' let description = ''
let innerWidth: number let innerWidth: number
let isEditing = false let isEditing = false
let descriptionBox: AttachmentStyledBox
const notificationClient = getResource(notification.function.GetNotificationClient).then((res) => res()) const notificationClient = getResource(notification.function.GetNotificationClient).then((res) => res())
@ -153,7 +154,7 @@
updates updates
) )
} }
await descriptionBox.createAttachments()
isEditing = false isEditing = false
} }
@ -226,14 +227,30 @@
placeholder={tracker.string.IssueTitlePlaceholder} placeholder={tracker.string.IssueTitlePlaceholder}
kind="large-style" kind="large-style"
/> />
<div class="mt-6"> <div class="flex-between mt-6">
{#key description} {#key description}
<StyledTextArea <div class="flex-grow">
<AttachmentStyledBox
bind:this={descriptionBox}
objectId={_id}
_class={tracker.class.Issue}
space={issue.space}
alwaysEdit
showButtons
maxHeight={'card'}
bind:content={description} bind:content={description}
placeholder={tracker.string.IssueDescriptionPlaceholder} placeholder={tracker.string.IssueDescriptionPlaceholder}
focus
/> />
</div>
{/key} {/key}
<div
class="tool"
on:click={() => {
descriptionBox.attach()
}}
>
<IconAttachment size={'large'} />
</div>
</div> </div>
</div> </div>
</Scroller> </Scroller>
@ -262,8 +279,8 @@
<SubIssues {issue} {issueStatuses} {currentTeam} /> <SubIssues {issue} {issueStatuses} {currentTeam} />
{/key} {/key}
</div> </div>
{/if}
<AttachmentDocList value={issue} /> <AttachmentDocList value={issue} />
{/if}
<span slot="actions-label"> <span slot="actions-label">
{#if issueId}{issueId}{/if} {#if issueId}{issueId}{/if}
@ -309,4 +326,15 @@
height: 1px; height: 1px;
background-color: var(--divider-color); background-color: var(--divider-color);
} }
.tool {
align-self: start;
width: 20px;
height: 20px;
opacity: 0.3;
cursor: pointer;
&:hover {
opacity: 1;
}
}
</style> </style>