diff --git a/plugins/attachment-resources/src/components/AttachmentPopup.svelte b/plugins/attachment-resources/src/components/AttachmentPopup.svelte index 968fc862d1..ead79c9ca0 100644 --- a/plugins/attachment-resources/src/components/AttachmentPopup.svelte +++ b/plugins/attachment-resources/src/components/AttachmentPopup.svelte @@ -24,6 +24,8 @@ export let attachments: number export let object: Doc + export let canAdd = true + export let canRemove = true const client = getClient() @@ -41,7 +43,9 @@ ) function add () { - inputFile.click() + if (canAdd) { + inputFile.click() + } } async function createAttachment (file: File) { @@ -68,7 +72,9 @@ let inputFile: HTMLInputElement async function remove (doc: Attachment): Promise { - await client.remove(doc) + if (canRemove) { + await client.remove(doc) + } } @@ -86,14 +92,16 @@
-
- -
+ {#if canAdd} +
+ +
+ {/if}
{#each docs as doc}
- remove(doc)} /> + remove(doc)} />
{/each}
diff --git a/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte b/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte index 2382bfca50..babb48db93 100644 --- a/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte +++ b/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte @@ -25,17 +25,21 @@ export let kind: ButtonKind = 'link' export let showCounter: boolean = true export let compactMode: boolean = false + export let disabled = false + export let canAdd = true + export let canRemove = true {#if value && value > 0} + {@const popupProps = { objectId: object._id, attachments: value, object, canAdd, canRemove }} - + {#if kind === 'list'} {#if compactMode}
@@ -48,7 +52,7 @@ {size} showTooltip={{ component: AttachmentPopup, - props: { objectId: object._id, attachments: value, object } + props: popupProps }} >
@@ -61,7 +65,7 @@