Hr search staff (#2703)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-02 11:37:30 +06:00 committed by GitHub
parent 2cbdeafdd1
commit bd6ef3aa57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 10 deletions

View File

@ -15,8 +15,8 @@
<script lang="ts">
import { CalendarMode } from '@hcengineering/calendar-resources'
import calendar from '@hcengineering/calendar-resources/src/plugin'
import { Ref } from '@hcengineering/core'
import { Department } from '@hcengineering/hr'
import { DocumentQuery, Ref } from '@hcengineering/core'
import { Department, Staff } from '@hcengineering/hr'
import { createQuery, SpaceSelector } from '@hcengineering/presentation'
import {
Button,
@ -25,16 +25,24 @@
IconForward,
Label,
deviceOptionsStore as deviceInfo,
TabList
TabList,
SearchEdit
} from '@hcengineering/ui'
import type { TabItem } from '@hcengineering/ui'
import view from '@hcengineering/view'
import hr from '../plugin'
import ScheduleMonthView from './ScheduleView.svelte'
import ScheduleView from './ScheduleView.svelte'
let department = hr.ids.Head
let currentDate: Date = new Date()
let search = ''
let resultQuery: DocumentQuery<Staff> = {}
function updateResultQuery (search: string): void {
resultQuery = search === '' ? {} : { name: { $like: '%' + search + '%' } }
}
const query = createQuery()
let descendants: Map<Ref<Department>, Department[]> = new Map<Ref<Department>, Department[]>()
@ -168,6 +176,12 @@
}}
/>
{/if}
<SearchEdit
bind:value={search}
on:change={() => {
updateResultQuery(search)
}}
/>
<SpaceSelector
_class={hr.class.Department}
label={hr.string.Department}
@ -178,4 +192,12 @@
</div>
</div>
<ScheduleMonthView {department} {descendants} departmentById={departments} {currentDate} {mode} {display} />
<ScheduleView
{department}
{descendants}
departmentById={departments}
staffQuery={resultQuery}
{currentDate}
{mode}
{display}
/>

View File

@ -15,7 +15,7 @@
<script lang="ts">
import { CalendarMode } from '@hcengineering/calendar-resources'
import { Employee, EmployeeAccount } from '@hcengineering/contact'
import { getCurrentAccount, Ref } from '@hcengineering/core'
import { DocumentQuery, getCurrentAccount, Ref } from '@hcengineering/core'
import type { Department, Request, RequestType, Staff } from '@hcengineering/hr'
import { createQuery } from '@hcengineering/presentation'
import { Label } from '@hcengineering/ui'
@ -30,6 +30,7 @@
export let currentDate: Date = new Date()
export let mode: CalendarMode
export let display: 'chart' | 'stats'
export let staffQuery: DocumentQuery<Staff> = {}
$: startDate =
mode === CalendarMode.Year
@ -45,7 +46,7 @@
const lq = createQuery()
const typeQuery = createQuery()
const staffQuery = createQuery()
const staffQ = createQuery()
const currentEmployee = (getCurrentAccount() as EmployeeAccount).employee
let staff: Staff[] = []
@ -60,9 +61,9 @@
)
})
staffQuery.query(
$: staffQ.query(
hr.mixin.Staff,
{},
staffQuery,
(res) => {
staff = res
},

View File

@ -104,6 +104,6 @@
<Scroller>
{#if head}
<DepartmentCard value={head} {descendants} {allEmployees} />
<DepartmentCard value={head} {descendants} {allEmployees} dragOver={undefined} dragPerson={undefined} />
{/if}
</Scroller>