Improve attribute permissions presenter (#10272)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-12-04 23:07:11 +07:00
committed by Artem Savchenko
parent 8422fdf49f
commit 058368dafa
16 changed files with 83 additions and 29 deletions
+4
View File
@@ -709,6 +709,10 @@ export function createModel (builder: Builder): void {
presenter: setting.component.PermissionPresenter
})
builder.mixin(core.class.AttributePermission, core.class.Class, view.mixin.ObjectPresenter, {
presenter: setting.component.AttributePermissionPresenter
})
builder.createDoc(core.class.DomainIndexConfiguration, core.space.Model, {
domain: DOMAIN_SETTING,
disabled: [{ modifiedOn: 1 }, { modifiedBy: 1 }, { createdOn: 1 }, { space: 1 }]
@@ -14,7 +14,7 @@
-->
<script lang="ts">
import contact from '@hcengineering/contact'
import core, { Permission, Ref } from '@hcengineering/core'
import core, { AnyAttribute, AttributePermission, Permission, Ref } from '@hcengineering/core'
import { AttributeEditor, MessageBox, createQuery, getClient } from '@hcengineering/presentation'
import {
ButtonIcon,
@@ -36,6 +36,7 @@
import settingRes from '@hcengineering/setting-resources/src/plugin'
import { createEventDispatcher } from 'svelte'
import cardPlugin from '../../plugin'
import { IntlString } from '@hcengineering/platform'
export let _id: Ref<Role>
export let readonly: boolean = false
@@ -173,6 +174,19 @@
clearSettingsStore()
navigate(loc)
}
function isAttributePermission (permission: Permission): permission is AttributePermission {
return permission._class === core.class.AttributePermission
}
function getAttributePermissionLabel (permission: Permission): IntlString | undefined {
const isAttribute = isAttributePermission(permission)
if (!isAttribute) {
return undefined
}
const attr = client.getModel().findObject(permission.attribute) as AnyAttribute
return attr?.label
}
</script>
{#if role !== undefined}
@@ -223,6 +237,7 @@
{#if permissions.length > 0}
<div class="hulyTableAttr-content task">
{#each permissions as permission}
{@const extraLabel = getAttributePermissionLabel(permission)}
<div class="hulyTableAttr-content__row">
{#if permission.icon !== undefined}
<div class="hulyTableAttr-content__row-icon-wrapper">
@@ -232,13 +247,10 @@
<div class="hulyTableAttr-content__row-label font-medium-14">
<Label label={permission.label} />
{#if extraLabel}
<Label label={extraLabel} />
{/if}
</div>
{#if permission.description !== undefined}
<div class="hulyTableAttr-content__row-label grow dark font-regular-14">
<Label label={permission.description} />
</div>
{/if}
</div>
{/each}
</div>
@@ -0,0 +1,35 @@
<!--
// Copyright © 2024 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { AnyAttribute, AttributePermission } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { Label } from '@hcengineering/ui'
export let value: AttributePermission
export let inline: boolean = false
const client = getClient()
$: attr = client.getModel().findObject(value?.attribute) as AnyAttribute
</script>
{#if value}
<div class="flex-presenter" class:inline-presenter={inline}>
<Label label={value.label} />
{#if attr}
<Label label={attr.label} />
{/if}
</div>
{/if}
+2
View File
@@ -37,6 +37,7 @@ import ClassAttributesList from './components/ClassAttributesList.svelte'
import Configure from './components/Configure.svelte'
import InviteSetting from './components/InviteSetting.svelte'
import PermissionPresenter from './components/presenters/PermissionPresenter.svelte'
import AttributePermissionPresenter from './components/presenters/AttributePermissionPresenter.svelte'
import SpaceTypeDescriptorPresenter from './components/presenters/SpaceTypeDescriptorPresenter.svelte'
import Spaces from './components/Spaces.svelte'
import SpaceTypeGeneralSectionEditor from './components/spaceTypes/editor/SpaceTypeGeneralSectionEditor.svelte'
@@ -141,6 +142,7 @@ export default async (): Promise<Resources> => ({
ManageSpaceTypesTools,
ManageSpaceTypeContent,
PermissionPresenter,
AttributePermissionPresenter,
SpaceTypeDescriptorPresenter,
SpaceTypeGeneralSectionEditor,
SpaceTypePropertiesSectionEditor,
+1
View File
@@ -189,6 +189,7 @@ export default plugin(settingId, {
Terms: '' as AnyComponent,
ClassSetting: '' as AnyComponent,
PermissionPresenter: '' as AnyComponent,
AttributePermissionPresenter: '' as AnyComponent,
SpaceTypeDescriptorPresenter: '' as AnyComponent,
SpaceTypeGeneralSectionEditor: '' as AnyComponent,
SpaceTypePropertiesSectionEditor: '' as AnyComponent,
+2 -2
View File
@@ -151,7 +151,7 @@
"CopyLink": "Kopírovat odkaz",
"ValueIsSet": "Hodnota je nastavena",
"RoleLabel": "Role: {role}",
"ForbidAttributeChanges": "Zakázat změny atributů",
"AllowAttributeChanges": "Povolit změny atributů"
"ForbidAttributeChanges": "Zakázat změny: ",
"AllowAttributeChanges": "Povolit změny: "
}
}
+2 -2
View File
@@ -151,7 +151,7 @@
"CopyLink": "Link kopieren",
"ValueIsSet": "Wert ist gesetzt",
"RoleLabel": "Rolle: {role}",
"ForbidAttributeChanges": "Attributänderungen verbieten",
"AllowAttributeChanges": "Attributänderungen erlauben"
"ForbidAttributeChanges": "Änderungen verbieten: ",
"AllowAttributeChanges": "Änderungen erlauben: "
}
}
+2 -2
View File
@@ -151,7 +151,7 @@
"CopyLink": "Copy link",
"ValueIsSet": "Value is set",
"RoleLabel": "Role: {role}",
"ForbidAttributeChanges": "Forbid attribute changes",
"AllowAttributeChanges": "Allow attribute changes"
"ForbidAttributeChanges": "Forbid changes: ",
"AllowAttributeChanges": "Allow changes: "
}
}
+2 -2
View File
@@ -146,7 +146,7 @@
"CopyLink": "Copiar enlace",
"ValueIsSet": "El valor está establecido",
"RoleLabel": "Role: {role}",
"ForbidAttributeChanges": "Prohibir cambios de atributo",
"AllowAttributeChanges": "Permitir cambios de atributo"
"ForbidAttributeChanges": "Prohibir cambios: ",
"AllowAttributeChanges": "Permitir cambios: "
}
}
+2 -2
View File
@@ -146,7 +146,7 @@
"CopyLink": "Copier le lien",
"ValueIsSet": "La valeur est définie",
"RoleLabel": "Rôle : {role}",
"ForbidAttributeChanges": "Interdire les modifications d'attributs",
"AllowAttributeChanges": "Autoriser les modifications d'attributs"
"ForbidAttributeChanges": "Interdire les modifications: ",
"AllowAttributeChanges": "Autoriser les modifications: "
}
}
+2 -2
View File
@@ -146,7 +146,7 @@
"CopyLink": "Copia link",
"ValueIsSet": "Il valore è impostato",
"RoleLabel": "Ruolo: {role}",
"ForbidAttributeChanges": "Vieta modifiche attributo",
"AllowAttributeChanges": "Consenti modifiche attributo"
"ForbidAttributeChanges": "Vieta modifiche: ",
"AllowAttributeChanges": "Consenti modifiche: "
}
}
+2 -2
View File
@@ -146,7 +146,7 @@
"CopyLink": "リンクをコピー",
"ValueIsSet": "値が設定されています",
"RoleLabel": "役割: {role}",
"ForbidAttributeChanges": "属性の変更を禁止",
"AllowAttributeChanges": "属性の変更を許可"
"ForbidAttributeChanges": "属性の変更を禁止: ",
"AllowAttributeChanges": "属性の変更を許可: "
}
}
+2 -2
View File
@@ -146,7 +146,7 @@
"CopyLink": "Copiar link",
"ValueIsSet": "O valor está definido",
"RoleLabel": "Cargo: {role}",
"ForbidAttributeChanges": "Proibir alterações de atributo",
"AllowAttributeChanges": "Permitir alterações de atributo"
"ForbidAttributeChanges": "Proibir alterações: ",
"AllowAttributeChanges": "Permitir alterações: "
}
}
+2 -2
View File
@@ -148,7 +148,7 @@
"CopyLink": "Скопировать ссылку",
"ValueIsSet": "Значение установлено",
"RoleLabel": "Роль: {role}",
"ForbidAttributeChanges": "Запретить изменения атрибутов",
"AllowAttributeChanges": "Разрешить изменения атрибутов"
"ForbidAttributeChanges": "Запретить изменение: ",
"AllowAttributeChanges": "Разрешить изменение: "
}
}
+2 -2
View File
@@ -146,7 +146,7 @@
"CopyLink": "Bağlantıyı kopyala",
"ValueIsSet": "Değer ayarlandı",
"RoleLabel": "Rol: {role}",
"ForbidAttributeChanges": "Özellik değişikliklerini yasakla",
"AllowAttributeChanges": "Özellik değişikliklerine izin ver"
"ForbidAttributeChanges": "Özellik yasakla: ",
"AllowAttributeChanges": "Özellik izin ver: "
}
}
+2 -2
View File
@@ -151,7 +151,7 @@
"CopyLink": "复制链接",
"ValueIsSet": "值已设置",
"RoleLabel": "角色:{role}",
"ForbidAttributeChanges": "禁止属性更改",
"AllowAttributeChanges": "允许属性更改"
"ForbidAttributeChanges": "禁止更改属性: ",
"AllowAttributeChanges": "允许更改属性: "
}
}