mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 20:14:57 +02:00
UBERF-6001: Roles management (#4994)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
+11
-11
@@ -25,7 +25,10 @@ import {
|
||||
Space,
|
||||
Status,
|
||||
StatusCategory,
|
||||
Timestamp
|
||||
Timestamp,
|
||||
SpaceType,
|
||||
SpaceTypeDescriptor,
|
||||
TypedSpace
|
||||
} from '@hcengineering/core'
|
||||
import { NotificationType } from '@hcengineering/notification'
|
||||
import type { Asset, IntlString, Plugin, Resource } from '@hcengineering/platform'
|
||||
@@ -41,7 +44,7 @@ export interface DocWithRank extends Doc {
|
||||
rank: Rank
|
||||
}
|
||||
|
||||
export interface Project extends Space {
|
||||
export interface Project extends TypedSpace {
|
||||
type: Ref<ProjectType>
|
||||
}
|
||||
|
||||
@@ -149,15 +152,16 @@ export interface TaskTypeClass extends Class<TaskType> {
|
||||
export interface ProjectTypeClass extends Class<ProjectType> {
|
||||
projectType: Ref<ProjectType>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*
|
||||
* Define a user customized project type.
|
||||
*/
|
||||
export interface ProjectType extends Space {
|
||||
shortDescription?: string
|
||||
export interface ProjectType extends SpaceType {
|
||||
descriptor: Ref<ProjectTypeDescriptor>
|
||||
tasks: Ref<TaskType>[]
|
||||
description: string
|
||||
|
||||
// Color and extra options per project type.
|
||||
// All statuses per project has same color.
|
||||
@@ -173,14 +177,11 @@ export interface ProjectType extends Space {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ProjectTypeDescriptor extends Doc {
|
||||
name: IntlString
|
||||
description: IntlString
|
||||
icon: Asset
|
||||
editor?: AnyComponent
|
||||
export interface ProjectTypeDescriptor extends SpaceTypeDescriptor {
|
||||
allowedClassic?: boolean
|
||||
allowedTaskTypeDescriptors?: Ref<TaskTypeDescriptor>[] // if undefined we allow all possible
|
||||
baseClass: Ref<Class<Task>>
|
||||
baseClass: Ref<Class<Project>>
|
||||
editor?: AnyComponent
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,7 +293,6 @@ const task = plugin(taskId, {
|
||||
Lost: '' as Ref<StatusCategory>
|
||||
},
|
||||
component: {
|
||||
ProjectEditor: '' as AnyComponent,
|
||||
ProjectTypeSelector: '' as AnyComponent,
|
||||
CreateStatePopup: '' as AnyComponent
|
||||
},
|
||||
|
||||
@@ -168,7 +168,7 @@ export type TaskTypeWithFactory = Omit<Data<TaskType>, 'statuses' | 'parent' | '
|
||||
factory: Data<Status>[]
|
||||
} & Partial<Pick<TaskType, 'targetClass'>>
|
||||
|
||||
type ProjectData = Omit<Data<ProjectType>, 'statuses' | 'private' | 'members' | 'archived' | 'targetClass'>
|
||||
type ProjectData = Omit<Data<ProjectType>, 'statuses' | 'targetClass'>
|
||||
|
||||
async function createStates (
|
||||
client: TxOperations,
|
||||
@@ -212,16 +212,14 @@ export async function createProjectType (
|
||||
const targetProjectClassId: Ref<Class<Doc>> = generateId()
|
||||
const tmpl = await client.createDoc(
|
||||
task.class.ProjectType,
|
||||
core.space.Space,
|
||||
core.space.Model,
|
||||
{
|
||||
description: data.description,
|
||||
shortDescription: data.shortDescription,
|
||||
descriptor: data.descriptor,
|
||||
roles: 0,
|
||||
tasks: _tasks,
|
||||
name: data.name,
|
||||
private: false,
|
||||
members: [],
|
||||
archived: false,
|
||||
statuses: calculateStatuses({ tasks: _tasks, statuses: [] }, tasksData, []),
|
||||
targetClass: targetProjectClassId,
|
||||
classic: data.classic
|
||||
@@ -229,6 +227,7 @@ export async function createProjectType (
|
||||
_id
|
||||
)
|
||||
|
||||
// Mixin to hold custom fields of this project type
|
||||
await client.createDoc(
|
||||
core.class.Mixin,
|
||||
core.space.Model,
|
||||
@@ -241,6 +240,7 @@ export async function createProjectType (
|
||||
targetProjectClassId
|
||||
)
|
||||
|
||||
// TODO: not needed ???
|
||||
await client.createMixin(targetProjectClassId, core.class.Mixin, core.space.Model, task.mixin.ProjectTypeClass, {
|
||||
projectType: _id
|
||||
})
|
||||
@@ -344,7 +344,7 @@ async function createTaskTypes (
|
||||
projectType: _id
|
||||
})
|
||||
}
|
||||
await client.createDoc(task.class.TaskType, _id, tdata as Data<TaskType>, taskId)
|
||||
await client.createDoc(task.class.TaskType, core.space.Model, tdata as Data<TaskType>, taskId)
|
||||
tasksData.set(taskId, tdata as Data<TaskType>)
|
||||
_tasks.push(taskId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user