Restrict taskType descriptors (#4605)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-02-12 16:30:31 +06:00 committed by GitHub
parent 597caba6bc
commit 0fe4b6a09f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 38 additions and 24 deletions

View File

@ -504,7 +504,8 @@ export function createModel (builder: Builder): void {
name: board.string.BoardApplication,
description: board.string.ManageBoardStatuses,
icon: board.icon.Board,
baseClass: board.class.Board
baseClass: board.class.Board,
allowedTaskTypeDescriptors: [board.descriptors.Card]
},
board.descriptors.BoardType
)

View File

@ -703,7 +703,8 @@ export function createModel (builder: Builder): void {
name: lead.string.LeadApplication,
description: lead.string.ManageFunnelStatuses,
icon: lead.icon.LeadApplication,
baseClass: lead.class.Funnel
baseClass: lead.class.Funnel,
allowedTaskTypeDescriptors: [lead.descriptors.Lead]
},
lead.descriptors.FunnelType
)

View File

@ -1779,7 +1779,8 @@ export function createModel (builder: Builder): void {
description: recruit.string.ManageVacancyStatuses,
icon: recruit.icon.RecruitApplication,
editor: recruit.component.VacancyTemplateEditor,
baseClass: recruit.class.Vacancy
baseClass: recruit.class.Vacancy,
allowedTaskTypeDescriptors: [recruit.descriptors.Application]
},
recruit.descriptors.VacancyType
)

View File

@ -236,6 +236,8 @@ export class TProjectTypeDescriptor extends TDoc implements ProjectTypeDescripto
description!: IntlString
icon!: Asset
editor?: AnyComponent
allowedClassic?: boolean
allowedTaskTypeDescriptors?: Ref<TaskTypeDescriptor>[] // if undefined we allow all possible
baseClass!: Ref<Class<Task>>
}

View File

@ -673,7 +673,8 @@ export function createModel (builder: Builder): void {
description: tracker.string.ManageWorkflowStatuses,
icon: task.icon.Task,
baseClass: tracker.class.Project,
allowedClassic: true
allowedClassic: true,
allowedTaskTypeDescriptors: [tracker.descriptors.Issue]
},
tracker.descriptors.ProjectType
)

View File

@ -57,7 +57,12 @@
const taskTypeDescriptors = client
.getModel()
.findAllSync(task.class.TaskTypeDescriptor, { allowCreate: true })
.findAllSync(
task.class.TaskTypeDescriptor,
descriptor.allowedTaskTypeDescriptors
? { allowCreate: true, _id: { $in: descriptor.allowedTaskTypeDescriptors } }
: { allowCreate: true }
)
.filter((p) => hasResource(p._id as any as Resource<any>))
let { kind, name, targetClass, statusCategories, statuses, allowedAsChildOf } =
@ -176,24 +181,26 @@
</span>
<TaskTypeKindEditor bind:kind />
</div>
<div class="hulyModal-content__settingsSet-line">
<span class="label">
<Label label={task.string.Type} />
</span>
<ButtonMenu
selected={taskTypeDescriptor._id}
items={descriptorItems}
icon={taskTypeDescriptor.icon}
label={taskTypeDescriptor.name}
kind={'secondary'}
size={'large'}
on:selected={(evt) => {
if (evt.detail != null) {
const tt = taskTypeDescriptors.find((tt) => tt._id === evt.detail)
if (tt) taskTypeDescriptor = tt
}
}}
/>
</div>
{#if taskTypeDescriptors.length > 1}
<div class="hulyModal-content__settingsSet-line">
<span class="label">
<Label label={task.string.Type} />
</span>
<ButtonMenu
selected={taskTypeDescriptor._id}
items={descriptorItems}
icon={taskTypeDescriptor.icon}
label={taskTypeDescriptor.name}
kind={'secondary'}
size={'large'}
on:selected={(evt) => {
if (evt.detail != null) {
const tt = taskTypeDescriptors.find((tt) => tt._id === evt.detail)
if (tt) taskTypeDescriptor = tt
}
}}
/>
</div>
{/if}
</div>
</Modal>

View File

@ -176,6 +176,7 @@ export interface ProjectTypeDescriptor extends Doc {
icon: Asset
editor?: AnyComponent
allowedClassic?: boolean
allowedTaskTypeDescriptors?: Ref<TaskTypeDescriptor>[] // if undefined we allow all possible
baseClass: Ref<Class<Task>>
}