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

View File

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

View File

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