mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-08 21:27:45 +03:00
Fix multiattachment (#2950)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
f42d06cfce
commit
92d8e3e6df
@ -137,8 +137,8 @@
|
||||
newAttachments.add(_id)
|
||||
attachments = attachments
|
||||
saved = false
|
||||
dispatch('attached', _id)
|
||||
saveDraft()
|
||||
dispatch('attached', _id)
|
||||
} catch (err: any) {
|
||||
setPlatformStatus(unknownError(err))
|
||||
}
|
||||
@ -146,6 +146,7 @@
|
||||
|
||||
async function saveAttachment (doc: Attachment, objectId: Ref<Doc> | undefined): Promise<void> {
|
||||
if (space === undefined || objectId === undefined || _class === undefined) return
|
||||
newAttachments.delete(doc._id)
|
||||
await client.addCollection(attachment.class.Attachment, space, objectId, _class, 'attachments', doc, doc._id)
|
||||
}
|
||||
|
||||
@ -172,12 +173,13 @@
|
||||
async function removeAttachment (attachment: Attachment): Promise<void> {
|
||||
removedAttachments.add(attachment)
|
||||
attachments.delete(attachment._id)
|
||||
dispatch('detached', attachment._id)
|
||||
attachments = attachments
|
||||
saveDraft()
|
||||
dispatch('detached', attachment._id)
|
||||
}
|
||||
|
||||
async function deleteAttachment (attachment: Attachment): Promise<void> {
|
||||
removedAttachments.delete(attachment)
|
||||
if (originalAttachments.has(attachment._id)) {
|
||||
await client.removeCollection(
|
||||
attachment._class,
|
||||
@ -218,6 +220,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveNewAttachment (_id: Ref<Attachment>): Promise<void> {
|
||||
const attachment = attachments.get(_id)
|
||||
if (attachment !== undefined) {
|
||||
await saveAttachment(attachment, objectId)
|
||||
}
|
||||
}
|
||||
|
||||
export async function removeAttachmentById (_id: Ref<Attachment>): Promise<void> {
|
||||
const attachment = attachments.get(_id)
|
||||
if (attachment !== undefined) {
|
||||
await removeAttachment(attachment)
|
||||
}
|
||||
}
|
||||
|
||||
export async function createAttachments (_id: Ref<Doc> | undefined = objectId): Promise<void> {
|
||||
if (saved) {
|
||||
return
|
||||
|
@ -185,8 +185,8 @@
|
||||
_class={tracker.class.Issue}
|
||||
space={issue.space}
|
||||
alwaysEdit
|
||||
on:attached={save}
|
||||
on:detached={save}
|
||||
on:attached={(e) => descriptionBox.saveNewAttachment(e.detail)}
|
||||
on:detached={(e) => descriptionBox.removeAttachmentById(e.detail)}
|
||||
showButtons
|
||||
on:blur={save}
|
||||
on:changeContent={triggerSave}
|
||||
|
Loading…
Reference in New Issue
Block a user