mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 19:58:09 +00:00
Add person selector (#2447)
Signed-off-by: Denis Maslennikov <denis.maslennikov@gmail.com>
This commit is contained in:
parent
9bb045e53a
commit
0718ca0812
@ -39,6 +39,7 @@
|
||||
export let focusIndex = -1
|
||||
export let showTooltip: LabelAndProps | undefined = undefined
|
||||
export let showNavigate = true
|
||||
export let readonly = false
|
||||
</script>
|
||||
|
||||
<UserBox
|
||||
@ -58,5 +59,6 @@
|
||||
{focusIndex}
|
||||
{showTooltip}
|
||||
{showNavigate}
|
||||
{readonly}
|
||||
on:change
|
||||
/>
|
||||
|
@ -17,6 +17,7 @@
|
||||
"Departments": "Departments",
|
||||
"ShowEmployees": "Show employees",
|
||||
"AddEmployee": "Add employee",
|
||||
"SelectEmployee": "Select employee",
|
||||
"Schedule": "Schedule",
|
||||
"RequestType": "Type",
|
||||
"CreateRequest": "Create {type}",
|
||||
|
@ -17,6 +17,7 @@
|
||||
"Departments": "Департаменты",
|
||||
"ShowEmployees": "Просмотреть сотрудников",
|
||||
"AddEmployee": "Добавить сотрудника",
|
||||
"SelectEmployee": "Выберите сотрудника",
|
||||
"Schedule": "График",
|
||||
"RequestType": "Тип",
|
||||
"CreateRequest": "Создать {type}",
|
||||
|
@ -15,10 +15,11 @@
|
||||
<script lang="ts">
|
||||
import { AttachmentStyledBox } from '@hcengineering/attachment-resources'
|
||||
import calendar from '@hcengineering/calendar'
|
||||
import { Employee } from '@hcengineering/contact'
|
||||
import core, { generateId, Ref } from '@hcengineering/core'
|
||||
import { Request, RequestType, Staff } from '@hcengineering/hr'
|
||||
import { translate } from '@hcengineering/platform'
|
||||
import { Card, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Card, createQuery, EmployeeBox, getClient } from '@hcengineering/presentation'
|
||||
import ui, { Button, DateRangePresenter, DropdownLabelsIntl, IconAttachment } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import hr from '../plugin'
|
||||
@ -26,7 +27,10 @@
|
||||
|
||||
export let staff: Staff
|
||||
export let date: Date
|
||||
export let readonly: boolean
|
||||
|
||||
let description: string = ''
|
||||
let employee: Ref<Employee> = staff._id
|
||||
|
||||
const objectId: Ref<Request> = generateId()
|
||||
let descriptionBox: AttachmentStyledBox
|
||||
@ -59,7 +63,8 @@
|
||||
if (value != null) date = value
|
||||
if (date === undefined) return
|
||||
if (type === undefined) return
|
||||
await client.addCollection(hr.class.Request, staff.department, staff._id, staff._class, 'requests', {
|
||||
if (employee === null) return
|
||||
await client.addCollection(hr.class.Request, staff.department, employee, staff._class, 'requests', {
|
||||
type: type._id,
|
||||
tzDate: toTzDate(new Date(date)),
|
||||
tzDueDate: toTzDate(new Date(dueDate)),
|
||||
@ -82,6 +87,15 @@
|
||||
dispatch('close')
|
||||
}}
|
||||
>
|
||||
<svelte:fragment slot="header">
|
||||
<EmployeeBox
|
||||
label={hr.string.SelectEmployee}
|
||||
placeholder={hr.string.SelectEmployee}
|
||||
bind:value={employee}
|
||||
{readonly}
|
||||
showNavigate={false}
|
||||
/>
|
||||
</svelte:fragment>
|
||||
<DropdownLabelsIntl
|
||||
items={types.map((p) => {
|
||||
return { id: p._id, label: p.label }
|
||||
|
@ -66,14 +66,22 @@
|
||||
}
|
||||
|
||||
function createRequest (e: MouseEvent, date: Date, staff: Staff): void {
|
||||
if (!isEditable(staff)) return
|
||||
const readonly: boolean = teamLead !== currentEmployee
|
||||
let editStaff: Staff | undefined = staff
|
||||
if (readonly) {
|
||||
editStaff = departmentStaff.find((p) => p._id === currentEmployee)
|
||||
if (!editStaff) {
|
||||
return
|
||||
}
|
||||
}
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
showPopup(
|
||||
CreateRequest,
|
||||
{
|
||||
staff,
|
||||
date
|
||||
staff: editStaff,
|
||||
date,
|
||||
readonly
|
||||
},
|
||||
eventToHTMLElement(e)
|
||||
)
|
||||
|
@ -25,6 +25,7 @@ export default mergeIds(hrId, hr, {
|
||||
CreateDepartmentLabel: '' as IntlString,
|
||||
DepartmentPlaceholder: '' as IntlString,
|
||||
TeamLead: '' as IntlString,
|
||||
SelectEmployee: '' as IntlString,
|
||||
UnAssignLead: '' as IntlString,
|
||||
MemberCount: '' as IntlString,
|
||||
AssignLead: '' as IntlString,
|
||||
|
Loading…
Reference in New Issue
Block a user