From 0843db0e048c575506ee83f980fbfde2b91b9ae6 Mon Sep 17 00:00:00 2001 From: Anna No Date: Thu, 21 Apr 2022 17:59:07 +0700 Subject: [PATCH] Board: Add attachment action (#1474) Signed-off-by: Anna No --- packages/theme/styles/_layouts.scss | 1 + .../src/components/AddAttachment.svelte | 4 ++ plugins/board-assets/lang/en.json | 3 ++ plugins/board-assets/lang/ru.json | 3 ++ .../src/components/EditCard.svelte | 6 +-- .../components/editor/CardAttachments.svelte | 20 ++++--- .../src/components/editor/CardDetails.svelte | 8 +-- .../src/components/editor/CardLabels.svelte | 4 +- .../components/popups/AttachmentPicker.svelte | 54 +++++++++++++++++++ .../components/popups/CardLabelsEditor.svelte | 8 +-- .../components/popups/CardLabelsPicker.svelte | 8 +-- .../presenters/DatePresenter.svelte | 2 +- .../presenters/MemberPresenter.svelte | 5 +- plugins/board-resources/src/index.ts | 14 +++-- plugins/board-resources/src/plugin.ts | 3 ++ .../board-resources/src/utils/PopupUtils.ts | 3 +- 16 files changed, 113 insertions(+), 33 deletions(-) create mode 100644 plugins/board-resources/src/components/popups/AttachmentPicker.svelte diff --git a/packages/theme/styles/_layouts.scss b/packages/theme/styles/_layouts.scss index 4b8fc972f2c..2fc632919ca 100644 --- a/packages/theme/styles/_layouts.scss +++ b/packages/theme/styles/_layouts.scss @@ -420,6 +420,7 @@ p:last-child { margin-block-end: 0; } .w-9 { width: 2.25rem; } .w-14 { width: 3.5rem; } .w-16 { width: 4rem; } +.w-60 { width: 15rem; } .w-85 { width: 21.25rem; } .w-165 { width: 41.25rem; } .min-w-0 { min-width: 0; } diff --git a/plugins/attachment-resources/src/components/AddAttachment.svelte b/plugins/attachment-resources/src/components/AddAttachment.svelte index 2fe19c89be3..e1394993013 100644 --- a/plugins/attachment-resources/src/components/AddAttachment.svelte +++ b/plugins/attachment-resources/src/components/AddAttachment.svelte @@ -16,6 +16,7 @@ import { Class, Doc, Ref, Space } from '@anticrm/core' import { getClient } from '@anticrm/presentation' import { CircleButton, IconAdd } from '@anticrm/ui' + import { createEventDispatcher } from 'svelte' import { createAttachments } from '../utils' export let loading: number = 0 @@ -26,6 +27,7 @@ export let space: Ref const client = getClient() + const dispatch = createEventDispatcher() async function fileSelected() { const list = inputFile.files @@ -37,6 +39,8 @@ } finally { loading-- } + + dispatch('attached') } function openFile() { diff --git a/plugins/board-assets/lang/en.json b/plugins/board-assets/lang/en.json index 34a9d7573c0..8052d7da257 100644 --- a/plugins/board-assets/lang/en.json +++ b/plugins/board-assets/lang/en.json @@ -41,6 +41,9 @@ "Attachments": "Attachments", "AddAttachment": "Add an attachment", "DropFileToUpload": "Drop files to upload.", + "AttachFrom": "Attach from...", + "AttachmentTip": "Tip: You can drag and drop files onto cards to upload them.", + "Computer": "Computer", "CustomFields": "Custom Fields", "Automation": "Automation", "AddButton": "Add Button", diff --git a/plugins/board-assets/lang/ru.json b/plugins/board-assets/lang/ru.json index 2c54fc552e7..a32917bab4b 100644 --- a/plugins/board-assets/lang/ru.json +++ b/plugins/board-assets/lang/ru.json @@ -41,6 +41,9 @@ "Attachments": "Прикрепленное", "AddAttachment": "Прикрепить", "DropFileToUpload": "Добавьте файлы.", + "AttachFrom": "Добавить из...", + "AttachmentTip": "Совет: Вы можете перетаскивать файлы на карточки, чтобы прикрепить их.", + "Computer": "Компьютер", "CustomFields": "Дополнительно", "Automation": "Автоматизация", "AddButton": "Добавить", diff --git a/plugins/board-resources/src/components/EditCard.svelte b/plugins/board-resources/src/components/EditCard.svelte index ec13ead43f2..7f3f20a4b99 100644 --- a/plugins/board-resources/src/components/EditCard.svelte +++ b/plugins/board-resources/src/components/EditCard.svelte @@ -41,7 +41,7 @@ let object: Card | undefined let state: State | undefined - let handleMove: () => void + let handleMove: (e: Event) => void $: cardQuery.query(_class, { _id }, async (result) => { object = result[0] @@ -55,9 +55,9 @@ getCardActions(client, { _id: board.cardAction.Move }).then(async (result) => { if (result[0]?.handler) { const handler = await getResource(result[0].handler) - handleMove = () => { + handleMove = (e) => { if (object) { - handler(object, client) + handler(object, client, e) } } } diff --git a/plugins/board-resources/src/components/editor/CardAttachments.svelte b/plugins/board-resources/src/components/editor/CardAttachments.svelte index f7cdade4b7e..03e6cfded2f 100644 --- a/plugins/board-resources/src/components/editor/CardAttachments.svelte +++ b/plugins/board-resources/src/components/editor/CardAttachments.svelte @@ -15,8 +15,8 @@ --> @@ -52,11 +60,7 @@ {/each}
- - -
diff --git a/plugins/board-resources/src/components/editor/CardDetails.svelte b/plugins/board-resources/src/components/editor/CardDetails.svelte index 7ed67bb8485..516263e9b9f 100644 --- a/plugins/board-resources/src/components/editor/CardDetails.svelte +++ b/plugins/board-resources/src/components/editor/CardDetails.svelte @@ -31,8 +31,8 @@ const query = createQuery() const client = getClient() let members: Employee[] - let membersHandler: () => void - let dateHandler: () => void + let membersHandler: (e: Event) => void + let dateHandler: (e: Event) => void $: membersIds = members?.map(m => m._id) ?? [] @@ -71,9 +71,9 @@ if (action.handler) { const handler = await getResource(action.handler) if (action._id === board.cardAction.Dates) { - dateHandler = () => handler(value, client) + dateHandler = (e) => handler(value, client, e) } else if (action._id === board.cardAction.Members) { - membersHandler = () => handler(value, client) + membersHandler = (e) => handler(value, client, e) } } } diff --git a/plugins/board-resources/src/components/editor/CardLabels.svelte b/plugins/board-resources/src/components/editor/CardLabels.svelte index 2d2f7906e8e..bc50965a3f7 100644 --- a/plugins/board-resources/src/components/editor/CardLabels.svelte +++ b/plugins/board-resources/src/components/editor/CardLabels.svelte @@ -28,7 +28,7 @@ const client = getClient() let labels: CardLabel[] - let labelsHandler: () => void + let labelsHandler: (e: Event) => void let isCompact: boolean = false let isHovered: boolean = false @@ -46,7 +46,7 @@ }).then(async (result) => { if (result?.[0]?.handler) { const handler = await getResource(result[0].handler) - labelsHandler = () => handler(value, client) + labelsHandler = (e: Event) => handler(value, client, e) } }) } diff --git a/plugins/board-resources/src/components/popups/AttachmentPicker.svelte b/plugins/board-resources/src/components/popups/AttachmentPicker.svelte new file mode 100644 index 00000000000..7a37fd1843e --- /dev/null +++ b/plugins/board-resources/src/components/popups/AttachmentPicker.svelte @@ -0,0 +1,54 @@ + + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
\ No newline at end of file diff --git a/plugins/board-resources/src/components/popups/CardLabelsEditor.svelte b/plugins/board-resources/src/components/popups/CardLabelsEditor.svelte index 863ad8e2b1e..63394707759 100644 --- a/plugins/board-resources/src/components/popups/CardLabelsEditor.svelte +++ b/plugins/board-resources/src/components/popups/CardLabelsEditor.svelte @@ -82,15 +82,15 @@
-
-
+
+
-
+
-
+