replace isEditable with readonly (#2925)

Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
Ruslan Bayandinov 2023-04-10 16:59:37 +04:00 committed by GitHub
parent da22bf802d
commit cf7fdb7f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@
export let object: Doc
export let label: IntlString
export let isEditable: boolean = true
export let readonly: boolean = false
export let attr: AnyAttribute | undefined = undefined
let items: TagReference[] = []
@ -21,7 +21,7 @@
items = result
})
async function tagsHandler (evt: MouseEvent): Promise<void> {
if (!isEditable) return
if (readonly) return
showPopup(TagsEditorPopup, { object }, getEventPopupPositionElement(evt))
}
async function removeTag (tag: Ref<TagElement>): Promise<void> {
@ -34,10 +34,16 @@
<div class="flex-row-center flex-wrap">
{#each items as value}
<div class="step-container">
<TagReferencePresenter {attr} {value} {isEditable} kind={'labels'} on:remove={(res) => removeTag(res.detail)} />
<TagReferencePresenter
{attr}
{value}
isEditable={!readonly}
kind={'labels'}
on:remove={(res) => removeTag(res.detail)}
/>
</div>
{/each}
{#if isEditable}
{#if !readonly}
<div class="step-container">
<button class="tag-button" on:click|stopPropagation={tagsHandler}>
<div class="icon"><Icon icon={IconAdd} size={'full'} /></div>
@ -46,7 +52,7 @@
</div>
{/if}
</div>
{:else if isEditable}
{:else if !readonly}
<button class="tag-button" style="width: min-content" on:click|stopPropagation={tagsHandler}>
<div class="icon"><Icon icon={IconAdd} size={'full'} /></div>
<span class="overflow-label label"><Label {label} /></span>