mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-31 04:38:02 +00:00
Fix todo creating (#5175)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
75cccaeb6b
commit
a2749f3cd6
@ -80,9 +80,9 @@ export async function OnWorkSlotCreate (tx: Tx, control: TriggerControl): Promis
|
|||||||
if (issue === undefined) return []
|
if (issue === undefined) return []
|
||||||
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
||||||
if (project !== undefined) {
|
if (project !== undefined) {
|
||||||
const type = (await control.queryFind(task.class.ProjectType, {})).find((it) => it._id === project.type)
|
const type = (await control.modelDb.findAll(task.class.ProjectType, { _id: project.type }))[0]
|
||||||
if (type?.classic === true) {
|
if (type?.classic) {
|
||||||
const taskType = (await control.queryFind(task.class.TaskType, {})).find((it) => it._id === issue.kind)
|
const taskType = (await control.modelDb.findAll(task.class.TaskType, { _id: issue.kind }))[0]
|
||||||
if (taskType !== undefined) {
|
if (taskType !== undefined) {
|
||||||
const statuses = await control.findAll(core.class.Status, { _id: { $in: taskType.statuses } })
|
const statuses = await control.findAll(core.class.Status, { _id: { $in: taskType.statuses } })
|
||||||
const statusMap = toIdMap(statuses)
|
const statusMap = toIdMap(statuses)
|
||||||
@ -128,10 +128,10 @@ export async function OnToDoRemove (tx: Tx, control: TriggerControl): Promise<Tx
|
|||||||
if (issue === undefined) return []
|
if (issue === undefined) return []
|
||||||
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
||||||
if (project !== undefined) {
|
if (project !== undefined) {
|
||||||
const type = (await control.queryFind(task.class.ProjectType, {})).find((it) => it._id === project.type)
|
const type = (await control.modelDb.findAll(task.class.ProjectType, { _id: project.type }))[0]
|
||||||
if (type !== undefined && type.classic) {
|
if (type !== undefined && type.classic) {
|
||||||
const factory = new TxFactory(control.txFactory.account)
|
const factory = new TxFactory(control.txFactory.account)
|
||||||
const taskType = (await control.queryFind(task.class.TaskType, {})).find((it) => it._id === issue.kind)
|
const taskType = (await control.modelDb.findAll(task.class.TaskType, { _id: issue.kind }))[0]
|
||||||
if (taskType !== undefined) {
|
if (taskType !== undefined) {
|
||||||
const statuses = await control.findAll(core.class.Status, { _id: { $in: taskType.statuses } })
|
const statuses = await control.findAll(core.class.Status, { _id: { $in: taskType.statuses } })
|
||||||
const statusMap = toIdMap(statuses)
|
const statusMap = toIdMap(statuses)
|
||||||
@ -346,9 +346,9 @@ export async function IssueToDoDone (control: TriggerControl, workslots: WorkSlo
|
|||||||
if (issue !== undefined) {
|
if (issue !== undefined) {
|
||||||
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
||||||
if (project !== undefined) {
|
if (project !== undefined) {
|
||||||
const type = (await control.queryFind(task.class.ProjectType, {})).find((it) => it._id === project.type)
|
const type = (await control.modelDb.findAll(task.class.ProjectType, { _id: project.type }))[0]
|
||||||
if (type?.classic === true) {
|
if (type?.classic) {
|
||||||
const taskType = (await control.queryFind(task.class.TaskType, {})).find((it) => it._id === issue.kind)
|
const taskType = (await control.modelDb.findAll(task.class.TaskType, { _id: issue.kind }))[0]
|
||||||
if (taskType !== undefined) {
|
if (taskType !== undefined) {
|
||||||
const index = taskType.statuses.findIndex((p) => p === issue.status)
|
const index = taskType.statuses.findIndex((p) => p === issue.status)
|
||||||
|
|
||||||
@ -416,8 +416,8 @@ async function createIssueHandler (issue: Issue, control: TriggerControl): Promi
|
|||||||
if (issue.assignee != null) {
|
if (issue.assignee != null) {
|
||||||
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
const project = (await control.findAll(task.class.Project, { _id: issue.space }))[0]
|
||||||
if (project === undefined) return []
|
if (project === undefined) return []
|
||||||
const type = (await control.queryFind(task.class.ProjectType, {})).find((it) => it._id === project.type)
|
const type = (await control.modelDb.findAll(task.class.ProjectType, { _id: project.type }))[0]
|
||||||
if (type?.classic !== true) return []
|
if (!type?.classic) return []
|
||||||
const status = (await control.findAll(core.class.Status, { _id: issue.status }))[0]
|
const status = (await control.findAll(core.class.Status, { _id: issue.status }))[0]
|
||||||
if (status === undefined) return []
|
if (status === undefined) return []
|
||||||
if (status.category === task.statusCategory.Active || status.category === task.statusCategory.ToDo) {
|
if (status.category === task.statusCategory.Active || status.category === task.statusCategory.ToDo) {
|
||||||
@ -573,8 +573,8 @@ async function updateIssueHandler (tx: TxUpdateDoc<Issue>, control: TriggerContr
|
|||||||
const res: Tx[] = []
|
const res: Tx[] = []
|
||||||
const project = (await control.findAll(task.class.Project, { _id: tx.objectSpace as Ref<Project> }))[0]
|
const project = (await control.findAll(task.class.Project, { _id: tx.objectSpace as Ref<Project> }))[0]
|
||||||
if (project === undefined) return []
|
if (project === undefined) return []
|
||||||
const type = (await control.queryFind(task.class.ProjectType, {})).find((it) => it._id === project.type)
|
const type = (await control.modelDb.findAll(task.class.ProjectType, { _id: project.type }))[0]
|
||||||
if (type?.classic !== true) return []
|
if (!type?.classic) return []
|
||||||
const newAssignee = tx.operations.assignee
|
const newAssignee = tx.operations.assignee
|
||||||
if (newAssignee != null) {
|
if (newAssignee != null) {
|
||||||
res.push(...(await changeIssueAssigneeHandler(control, newAssignee, tx.objectId)))
|
res.push(...(await changeIssueAssigneeHandler(control, newAssignee, tx.objectId)))
|
||||||
|
Loading…
Reference in New Issue
Block a user