mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-10 17:30:51 +00:00
Add ForbidCreateFunnel permission
Signed-off-by: Anton Alexeyev <alexeyev.anton@gmail.com>
This commit is contained in:
parent
a4b3c1886e
commit
ef0b99d916
@ -32,6 +32,7 @@ import { type ViewOptionsModel } from '@hcengineering/view'
|
||||
|
||||
import lead from './plugin'
|
||||
import { defineSpaceType } from './spaceType'
|
||||
import { definePermissions } from './permissions'
|
||||
import { TCustomer, TFunnel, TLead } from './types'
|
||||
|
||||
export { leadId } from '@hcengineering/lead'
|
||||
@ -659,4 +660,5 @@ export function createModel (builder: Builder): void {
|
||||
})
|
||||
|
||||
defineSpaceType(builder)
|
||||
definePermissions(builder)
|
||||
}
|
||||
|
19
models/lead/src/permissions.ts
Normal file
19
models/lead/src/permissions.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import type { Builder } from '@hcengineering/model'
|
||||
import core from '@hcengineering/core'
|
||||
import lead from '@hcengineering/lead'
|
||||
|
||||
export function definePermissions (builder: Builder): void {
|
||||
builder.createDoc(
|
||||
core.class.Permission,
|
||||
core.space.Model,
|
||||
{
|
||||
label: lead.string.ForbidCreateFunnelPermission,
|
||||
scope: 'workspace',
|
||||
txClass: core.class.TxCreateDoc,
|
||||
objectClass: lead.class.Funnel,
|
||||
forbid: true,
|
||||
description: lead.string.ForbidCreateFunnelPermissionDescription
|
||||
},
|
||||
lead.permission.ForbidCreateFunnel
|
||||
)
|
||||
}
|
@ -267,7 +267,7 @@ export default plugin(coreId, {
|
||||
DeleteObject: '' as Ref<Permission>,
|
||||
ForbidDeleteObject: '' as Ref<Permission>,
|
||||
UpdateSpace: '' as Ref<Permission>,
|
||||
ArchiveSpace: '' as Ref<Permission>,
|
||||
ArchiveSpace: '' as Ref<Permission>
|
||||
},
|
||||
role: {
|
||||
Admin: '' as Ref<Role>
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Rozšíření pro řízení vztahů se zákazníky",
|
||||
"EditFunnel": "Upravit trychtýř",
|
||||
"FunnelMembers": "Členové",
|
||||
"RoleLabel": "Role: {role}"
|
||||
"RoleLabel": "Role: {role}",
|
||||
"ForbidCreateFunnelPermission": "Zakázat vytvoření trychtýře",
|
||||
"ForbidCreateFunnelPermissionDescription": "Zakazuje uživatelům vytvářet nové trychtýře"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Erweiterung für Customer Relationship Management",
|
||||
"EditFunnel": "Trichter bearbeiten",
|
||||
"FunnelMembers": "Mitglieder",
|
||||
"RoleLabel": "Rolle: {role}"
|
||||
"RoleLabel": "Rolle: {role}",
|
||||
"ForbidCreateFunnelPermission": "Trichtererstellung verbieten",
|
||||
"ForbidCreateFunnelPermissionDescription": "Verbietet Benutzern das Erstellen neuer Trichter"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Extension for Customer relation management",
|
||||
"EditFunnel": "Edit Funnel",
|
||||
"FunnelMembers": "Members",
|
||||
"RoleLabel": "Role: {role}"
|
||||
"RoleLabel": "Role: {role}",
|
||||
"ForbidCreateFunnelPermission": "Forbid create funnel",
|
||||
"ForbidCreateFunnelPermissionDescription": "Forbid users creating new funnels"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Extensión para la gestión de las relaciones con los Clientes",
|
||||
"EditFunnel": "Editar Embudo",
|
||||
"FunnelMembers": "Miembros",
|
||||
"RoleLabel": "Role: {role}"
|
||||
"RoleLabel": "Role: {role}",
|
||||
"ForbidCreateFunnelPermission": "Prohibir crear embudo",
|
||||
"ForbidCreateFunnelPermissionDescription": "Prohíbe a los usuarios crear nuevos embudos"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Extension pour la gestion de la relation client",
|
||||
"EditFunnel": "Modifier le pipeline",
|
||||
"FunnelMembers": "Membres",
|
||||
"RoleLabel": "Rôle : {role}"
|
||||
"RoleLabel": "Rôle : {role}",
|
||||
"ForbidCreateFunnelPermission": "Interdire la création de pipeline",
|
||||
"ForbidCreateFunnelPermissionDescription": "Interdit aux utilisateurs de créer de nouveaux pipelines"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Estensione per la gestione delle relazioni con i clienti",
|
||||
"EditFunnel": "Modifica Funnel",
|
||||
"FunnelMembers": "Membri",
|
||||
"RoleLabel": "Ruolo: {role}"
|
||||
"RoleLabel": "Ruolo: {role}",
|
||||
"ForbidCreateFunnelPermission": "Vieta creazione funnel",
|
||||
"ForbidCreateFunnelPermissionDescription": "Vieta agli utenti di creare nuovi funnel"
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "顧客関係管理のための拡張機能",
|
||||
"EditFunnel": "ファネルを編集",
|
||||
"FunnelMembers": "メンバー",
|
||||
"RoleLabel": "ロール: {role}"
|
||||
"RoleLabel": "ロール: {role}",
|
||||
"ForbidCreateFunnelPermission": "ファネルの作成禁止",
|
||||
"ForbidCreateFunnelPermissionDescription": "ユーザーが新しいファネルを作成することを禁止します"
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Extensão para gestão de relacionamento com o Cliente",
|
||||
"EditFunnel": "Editar Funil",
|
||||
"FunnelMembers": "Membros",
|
||||
"RoleLabel": "Cargo: {role}"
|
||||
"RoleLabel": "Cargo: {role}",
|
||||
"ForbidCreateFunnelPermission": "Proibir criação de funil",
|
||||
"ForbidCreateFunnelPermissionDescription": "Proíbe os utilizadores de criar novos funis"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "Расширение по работе с клиентами",
|
||||
"EditFunnel": "Редактировать воронку",
|
||||
"FunnelMembers": "Участники",
|
||||
"RoleLabel": "Роль: {role}"
|
||||
"RoleLabel": "Роль: {role}",
|
||||
"ForbidCreateFunnelPermission": "Запретить создание воронки",
|
||||
"ForbidCreateFunnelPermissionDescription": "Запрещает пользователям создавать новые воронки"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
"ConfigDescription": "用于客户关系管理的扩展",
|
||||
"EditFunnel": "编辑漏斗",
|
||||
"FunnelMembers": "成员",
|
||||
"RoleLabel": "角色:{role}"
|
||||
"RoleLabel": "角色:{role}",
|
||||
"ForbidCreateFunnelPermission": "禁止创建漏斗",
|
||||
"ForbidCreateFunnelPermissionDescription": "禁止用户创建新漏斗"
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,17 @@
|
||||
//
|
||||
|
||||
import type { Contact } from '@hcengineering/contact'
|
||||
import type { Attribute, Class, MarkupBlobRef, Doc, Markup, Ref, Status, Timestamp } from '@hcengineering/core'
|
||||
import type {
|
||||
Attribute,
|
||||
Class,
|
||||
MarkupBlobRef,
|
||||
Doc,
|
||||
Markup,
|
||||
Ref,
|
||||
Status,
|
||||
Timestamp,
|
||||
Permission
|
||||
} from '@hcengineering/core'
|
||||
import { Mixin } from '@hcengineering/core'
|
||||
import type { Asset, IntlString, Plugin } from '@hcengineering/platform'
|
||||
import { plugin } from '@hcengineering/platform'
|
||||
@ -73,7 +83,9 @@ const lead = plugin(leadId, {
|
||||
},
|
||||
string: {
|
||||
Lead: '' as IntlString,
|
||||
ConfigLabel: '' as IntlString
|
||||
ConfigLabel: '' as IntlString,
|
||||
ForbidCreateFunnelPermission: '' as IntlString,
|
||||
ForbidCreateFunnelPermissionDescription: '' as IntlString
|
||||
},
|
||||
attribute: {
|
||||
State: '' as Ref<Attribute<Status>>
|
||||
@ -96,6 +108,9 @@ const lead = plugin(leadId, {
|
||||
},
|
||||
space: {
|
||||
DefaultFunnel: '' as Ref<Funnel>
|
||||
},
|
||||
permission: {
|
||||
ForbidCreateFunnel: '' as Ref<Permission>
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
if (spaceType._class === core.class.SpaceType) {
|
||||
const additionalPermissionsQuery = createQuery()
|
||||
additionalPermissionsQuery.query(core.class.Permission, { scope: 'workspace' }, (res) => {
|
||||
spacePermissions = descriptor.availablePermissions.concat(res.map(r => r._id))
|
||||
spacePermissions = descriptor.availablePermissions.concat(res.map((r) => r._id))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,8 @@ import {
|
||||
Space,
|
||||
Status,
|
||||
Timestamp,
|
||||
Type, type Permission
|
||||
Type,
|
||||
type Permission
|
||||
} from '@hcengineering/core'
|
||||
import { Asset, IntlString, Plugin, Resource, plugin } from '@hcengineering/platform'
|
||||
import { Preference } from '@hcengineering/preference'
|
||||
|
@ -81,14 +81,19 @@ export class SpacePermissionsMiddleware extends BaseMiddleware implements Middle
|
||||
}
|
||||
|
||||
private getPermissions (): Permission[] {
|
||||
return this.context.modelDb.findAllSync(core.class.Permission, { })
|
||||
return this.context.modelDb.findAllSync(core.class.Permission, {})
|
||||
}
|
||||
|
||||
private getRoles (spaceTypeId: Ref<SpaceType>): Role[] {
|
||||
return this.context.modelDb.findAllSync(core.class.Role, { attachedTo: spaceTypeId })
|
||||
}
|
||||
|
||||
private setPermissions (spaceId: Ref<Space>, roles: Role[], assignment: RolesAssignment, permissions: Permission[]): void {
|
||||
private setPermissions (
|
||||
spaceId: Ref<Space>,
|
||||
roles: Role[],
|
||||
assignment: RolesAssignment,
|
||||
permissions: Permission[]
|
||||
): void {
|
||||
for (const role of roles) {
|
||||
const roleMembers: Ref<Account>[] = assignment[role._id] ?? []
|
||||
|
||||
@ -98,7 +103,7 @@ export class SpacePermissionsMiddleware extends BaseMiddleware implements Middle
|
||||
}
|
||||
|
||||
for (const permission of role.permissions) {
|
||||
const p = permissions.find(p => p._id === permission)
|
||||
const p = permissions.find((p) => p._id === permission)
|
||||
if (p === undefined) continue
|
||||
this.permissionsBySpace[spaceId][member].add(p)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user