mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-25 13:52:24 +02:00
EQMS-669 Add role creation utilities (#5273)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -14,11 +14,9 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import presentation, { getClient } from '@hcengineering/presentation'
|
||||
import setting from '@hcengineering/setting'
|
||||
import { createSpaceTypeRole } from '@hcengineering/setting'
|
||||
import { Modal, ModernEditbox } from '@hcengineering/ui'
|
||||
import core, { AttachedData, Attribute, PropertyType, Ref, Role, SpaceType } from '@hcengineering/core'
|
||||
import { ArrOf, TypeRef } from '@hcengineering/model'
|
||||
import { getEmbeddedLabel } from '@hcengineering/platform'
|
||||
import { AttachedData, Role, SpaceType } from '@hcengineering/core'
|
||||
|
||||
import settingRes from '../../../plugin'
|
||||
import { clearSettingsStore } from '../../../store'
|
||||
@@ -37,28 +35,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
const roleId = await client.addCollection(
|
||||
core.class.Role,
|
||||
core.space.Model,
|
||||
type._id,
|
||||
type._class,
|
||||
'roles',
|
||||
roleData
|
||||
)
|
||||
|
||||
// Create role as an attribute of space type's mixin
|
||||
await client.createDoc(
|
||||
core.class.Attribute,
|
||||
core.space.Model,
|
||||
{
|
||||
name: roleId,
|
||||
attributeOf: type.targetClass,
|
||||
type: ArrOf(TypeRef(core.class.Account)),
|
||||
label: getEmbeddedLabel(`Role: ${name}`),
|
||||
editor: setting.component.RoleAssignmentEditor
|
||||
},
|
||||
`role-${roleId}` as Ref<Attribute<PropertyType>>
|
||||
)
|
||||
await createSpaceTypeRole(client, type, roleData)
|
||||
}
|
||||
|
||||
$: canSave = roleData.name.trim() !== ''
|
||||
|
||||
Reference in New Issue
Block a user