Minor hr fixes (#5972)

This commit is contained in:
Denis Bykhov 2024-07-01 20:15:58 +05:00 committed by GitHub
parent 8d6b583628
commit 91a0cae632
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 10 deletions

View File

@ -341,7 +341,7 @@ export function createModel (builder: Builder): void {
component: hr.component.CreateDepartment,
element: 'top',
fillProps: {
_id: 'space'
_id: 'parent'
}
},
label: hr.string.CreateDepartment,
@ -357,9 +357,9 @@ export function createModel (builder: Builder): void {
createAction(
builder,
{
action: view.actionImpl.Archive,
label: view.string.Archive,
icon: view.icon.Archive,
action: view.actionImpl.Delete,
label: view.string.Delete,
icon: view.icon.Delete,
input: 'any',
category: hr.category.HR,
keyBinding: ['Meta + Backspace'],
@ -369,7 +369,7 @@ export function createModel (builder: Builder): void {
},
target: hr.class.Department,
context: { mode: ['context', 'browser'], group: 'tools' },
override: [view.action.Archive, view.action.Delete]
override: [view.action.Delete]
},
hr.action.ArchiveDepartment
)

View File

@ -36,9 +36,8 @@ export function createModel (builder: Builder): void {
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverHr.trigger.OnDepartmentRemove,
txMatch: {
_class: core.class.TxCollectionCUD,
'tx.objectClass': hr.class.Department,
'tx._class': core.class.TxRemoveDoc
objectClass: hr.class.Department,
_class: core.class.TxRemoveDoc
}
})

View File

@ -16,13 +16,14 @@
import { Employee } from '@hcengineering/contact'
import { EmployeeBox } from '@hcengineering/contact-resources'
import core, { Ref } from '@hcengineering/core'
import { Department } from '@hcengineering/hr'
import { Card, getClient } from '@hcengineering/presentation'
import { Button, EditBox, FocusHandler, createFocusManager } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import hr from '../plugin'
import DepartmentEditor from './DepartmentEditor.svelte'
export let parent = hr.ids.Head
export let parent: Ref<Department> = hr.ids.Head
const dispatch = createEventDispatcher()

View File

@ -164,6 +164,11 @@ export async function OnDepartmentRemove (tx: Tx, control: TriggerControl): Prom
const department = control.removedMap.get(ctx.objectId) as Department
if (department === undefined) return []
const res: Tx[] = []
const nested = await control.findAll(hr.class.Department, { parent: department._id })
for (const dep of nested) {
res.push(control.txFactory.createTxRemoveDoc(dep._class, dep.space, dep._id))
}
const targetAccounts = await control.modelDb.findAll(contact.class.PersonAccount, {
_id: { $in: department.members }
})
@ -173,7 +178,6 @@ export async function OnDepartmentRemove (tx: Tx, control: TriggerControl): Prom
_id: { $in: employeeIds }
})
const removed = await buildHierarchy(department._id, control)
const res: Tx[] = []
employee.forEach((em) => {
res.push(control.txFactory.createTxMixin(em._id, em._class, em.space, hr.mixin.Staff, { department: undefined }))
})