mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-23 14:06:00 +03:00
Add the ability to restrict adding / removing attachments (#3479)
Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@icloud.com>
This commit is contained in:
parent
a0ecb3c04f
commit
10a7b0f379
@ -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<void> {
|
||||
await client.remove(doc)
|
||||
if (canRemove) {
|
||||
await client.remove(doc)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -86,14 +92,16 @@
|
||||
<div class="fs-title">
|
||||
<Label label={attachment.string.Attachments} />
|
||||
</div>
|
||||
<div>
|
||||
<ActionIcon size={'medium'} icon={IconAdd} action={add} />
|
||||
</div>
|
||||
{#if canAdd}
|
||||
<div>
|
||||
<ActionIcon size={'medium'} icon={IconAdd} action={add} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="content">
|
||||
{#each docs as doc}
|
||||
<div class="item">
|
||||
<AttachmentPresenter value={doc} showPreview removable on:remove={() => remove(doc)} />
|
||||
<AttachmentPresenter value={doc} showPreview removable={canRemove} on:remove={() => remove(doc)} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
@ -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
|
||||
</script>
|
||||
|
||||
{#if value && value > 0}
|
||||
{@const popupProps = { objectId: object._id, attachments: value, object, canAdd, canRemove }}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<DocNavLink {object} inline noUnderline={true} shrink={0}>
|
||||
<DocNavLink {object} {disabled} inline noUnderline shrink={0}>
|
||||
{#if kind === 'list'}
|
||||
{#if compactMode}
|
||||
<div
|
||||
use:tooltip={{
|
||||
component: AttachmentPopup,
|
||||
props: { objectId: object._id, attachments: value, object }
|
||||
props: popupProps
|
||||
}}
|
||||
class="sm-tool-icon"
|
||||
>
|
||||
@ -48,7 +52,7 @@
|
||||
{size}
|
||||
showTooltip={{
|
||||
component: AttachmentPopup,
|
||||
props: { objectId: object._id, attachments: value, object }
|
||||
props: popupProps
|
||||
}}
|
||||
>
|
||||
<div slot="icon"><IconAttachment {size} /></div>
|
||||
@ -61,7 +65,7 @@
|
||||
<div
|
||||
use:tooltip={{
|
||||
component: AttachmentPopup,
|
||||
props: { objectId: object._id, attachments: value, object }
|
||||
props: popupProps
|
||||
}}
|
||||
class="sm-tool-icon"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user