UBERF-9604: Add edit permission check per row in Table (#8528) (#8818)

Signed-off-by: Anton Alexeyev <alexeyev.anton@gmail.com>
Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
Co-authored-by: utkaka <alexeyev.anton@gmail.com>
This commit is contained in:
Victor Ilyushchenko 2025-05-02 16:30:16 +03:00 committed by GitHub
parent f74a36d1ad
commit 63ecd04de7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 22 deletions

View File

@ -17,6 +17,7 @@
export let inline: boolean = false
export let shouldShowName: boolean = true
export let avatarSize: IconSize = kind === 'list-header' ? 'smaller' : 'x-small'
export let readonly = false
$: employee = value ? $employeeByIdStore.get(value) : undefined
@ -34,6 +35,7 @@
{#if onChange !== undefined}
<AssigneeBox
label={contact.string.Employee}
{readonly}
{value}
size={'medium'}
kind={'link'}

View File

@ -14,6 +14,7 @@
export let inline: boolean = false
export let shouldShowName: boolean = true
export let avatarSize: IconSize = kind === 'regular' ? 'small' : 'card'
export let readonly = false
</script>
{#if Array.isArray(value)}
@ -29,6 +30,7 @@
{accent}
{shouldShowName}
{avatarSize}
{readonly}
on:accent-color
/>
{/each}
@ -44,6 +46,7 @@
{accent}
{shouldShowName}
{avatarSize}
{readonly}
on:accent-color
/>
{/if}

View File

@ -48,6 +48,7 @@
import { LoadingProps, buildConfigLookup, buildModel, restrictionStore } from '../utils'
import IconUpDown from './icons/UpDown.svelte'
import { getResultOptions, getResultQuery } from '../viewOptions'
import { canEditSpace } from '../visibilityTester'
export let _class: Ref<Class<Doc>>
export let query: DocumentQuery<Doc>
@ -250,7 +251,7 @@
}
}
const joinProps = (attribute: AttributeModel, object: Doc, readonly: boolean) => {
const joinProps = (attribute: AttributeModel, object: Doc, readonly: boolean, editable: boolean) => {
const readonlyParams =
readonly || (attribute?.attribute?.readonly ?? false)
? {
@ -258,7 +259,10 @@
editable: false,
disabled: true
}
: {}
: {
readonly: !editable,
editable
}
if (attribute.collectionAttr) {
return { object, ...attribute.props, ...readonlyParams }
}
@ -439,26 +443,29 @@
{/if}
</td>
{/if}
{#if row < rowLimit}
{#each model as attribute, cell}
<td
class:align-left={attribute.displayProps?.align === 'left'}
class:align-center={attribute.displayProps?.align === 'center'}
class:align-right={attribute.displayProps?.align === 'right'}
>
<div class:antiTable-cells__firstCell={!cell}>
<!-- {getOnChange(object, attribute) !== undefined} -->
<svelte:component
this={attribute.presenter}
value={getValue(attribute, object)}
onChange={getOnChange(object, attribute)}
attribute={attribute.attribute}
{...joinProps(attribute, object, readonly || $restrictionStore.readonly)}
/>
</div>
</td>
{/each}
{/if}
{#await canEditSpace(object) then canEditObject}
{#if row < rowLimit}
{#each model as attribute, cell}
<td
class:align-left={attribute.displayProps?.align === 'left'}
class:align-center={attribute.displayProps?.align === 'center'}
class:align-right={attribute.displayProps?.align === 'right'}
>
<div class:antiTable-cells__firstCell={!cell}>
<!-- {getOnChange(object, attribute) !== undefined} -->
<svelte:component
this={attribute.presenter}
value={getValue(attribute, object)}
onChange={getOnChange(object, attribute)}
label={attribute.label}
attribute={attribute.attribute}
{...joinProps(attribute, object, readonly || $restrictionStore.readonly, canEditObject)}
/>
</div>
</td>
{/each}
{/if}
{/await}
</tr>
{/each}
</tbody>