diff --git a/packages/presentation/src/drafts.ts b/packages/presentation/src/drafts.ts index 566e8fcd02..e4d3bf27d3 100644 --- a/packages/presentation/src/drafts.ts +++ b/packages/presentation/src/drafts.ts @@ -14,7 +14,12 @@ export const draftStore = writable>(fetchMetadataLocalStorag */ export function updateDraftStore (id: string, draft: any): void { draftStore.update((drafts) => { - drafts[id] = draft + if (draft === undefined) { + drafts[id] = draft + } else { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete drafts[id] + } setMetadataLocalStorage(presentation.metadata.Draft, drafts) return drafts }) diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index 4a1ccf8e78..b87e835231 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -142,7 +142,7 @@ {#if showCommenInput}
- +
{/if} @@ -164,7 +164,7 @@ {#if showCommenInput}
- +
{/if}
diff --git a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte index 348e69ae4c..bf0836837f 100644 --- a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte +++ b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte @@ -13,7 +13,7 @@ // limitations under the License. --> @@ -142,7 +137,7 @@ {_class} space={object.space} bind:objectId={_id} - shouldUseDraft + {shouldSaveDraft} on:message={onMessage} on:update={onUpdate} /> diff --git a/plugins/tracker-resources/src/components/CreateIssue.svelte b/plugins/tracker-resources/src/components/CreateIssue.svelte index 0b02dabd4f..e1ae521e88 100644 --- a/plugins/tracker-resources/src/components/CreateIssue.svelte +++ b/plugins/tracker-resources/src/components/CreateIssue.svelte @@ -82,7 +82,6 @@ import SetParentIssueActionPopup from './SetParentIssueActionPopup.svelte' import SprintSelector from './sprints/SprintSelector.svelte' import IssueTemplateChilds from './templates/IssueTemplateChilds.svelte' - import attachment from '@hcengineering/attachment-resources/src/plugin' import IssueNotification from './issues/IssueNotification.svelte' export let space: Ref @@ -97,7 +96,7 @@ export let originalIssue: Issue | undefined export let onDraftChanged: () => void - const draft: IssueDraft | undefined = getUserDraft(tracker.class.IssueDraft) + const draft: IssueDraft | undefined = shouldSaveDraft ? getUserDraft(tracker.class.IssueDraft) : undefined let issueStatuses: WithLookup[] | undefined let labels: TagReference[] = draft?.labels || [] @@ -106,7 +105,7 @@ let currentTeam: Team | undefined function toIssue (initials: AttachedData, draft: IssueDraft | undefined): AttachedData { - if (draft == null) { + if (draft === undefined) { return { ...initials } } const { labels, subIssues, ...issue } = draft @@ -125,6 +124,7 @@ priority, dueDate: null, comments: 0, + attachments: 0, subIssues: 0, parents: [], reportedTime: 0, @@ -295,8 +295,6 @@ return } - await descriptionBox?.createAttachments() - let newDraft: Data | undefined = createDraftFromObject() const isEmpty = await isDraftEmpty(newDraft) @@ -337,6 +335,7 @@ description: '', dueDate: null, estimation: 0, + attachments: 0, labels: [], parentIssue: undefined, priority: 0, @@ -351,11 +350,9 @@ } } - const attachmentResult = await client.findOne(attachment.class.Attachment, { attachedTo: objectId }) - - if (attachmentResult) { - return false - } + // if (object.attachments && object.attachments > 0) { + // return false + // } if (draft.project && draft.project !== defaultIssue.project) { return false @@ -395,6 +392,7 @@ dueDate: object.dueDate, estimation: object.estimation, template: object.template, + attachments: object.attachments, labels, parentIssue: parentIssue?._id, team: _space, @@ -562,6 +560,7 @@ objectId = generateId() resetObject() saveDraft() + descriptionBox?.removeDraft(false) } async function showMoreActions (ev: Event) { @@ -672,6 +671,7 @@ dispatch('close') resetObject() saveDraft() + descriptionBox?.removeDraft(true) } } ) @@ -738,6 +738,7 @@ dispatch('changeContent')} + on:attach={(ev) => { + if (ev.detail.action === 'saved') { + object.attachments = ev.detail.value + } + }} /> {/key} diff --git a/plugins/tracker/src/index.ts b/plugins/tracker/src/index.ts index 3cf38f0f50..db2fce934c 100644 --- a/plugins/tracker/src/index.ts +++ b/plugins/tracker/src/index.ts @@ -222,6 +222,7 @@ export interface IssueDraft extends Doc { // Estimation in man days estimation: number parentIssue?: string + attachments?: number labels?: TagReference[] subIssues?: IssueTemplateChild[] template?: {