Extend CreateEmployee dialog for extra controls (#2766)

* Extend CreateEmployee dialog for extra controls

Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>

* Provide onCreate prop instead of dispatching event

Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>

---------

Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
Denis Bunakalya 2023-03-20 12:45:19 +03:00 committed by GitHub
parent db7ed8049e
commit d8bfb1c413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,9 @@
import contact from '../plugin'
import PersonPresenter from './PersonPresenter.svelte'
export let canSave: boolean = true
export let onCreate: ((id: Ref<Employee>) => Promise<void>) | undefined = undefined
let avatarEditor: EditableAvatar
let firstName = ''
@ -66,6 +69,9 @@
provider: channel.provider
})
}
if (onCreate) {
await onCreate(id)
}
dispatch('close')
}
@ -102,7 +108,11 @@
<Card
label={contact.string.CreateEmployee}
okAction={createPerson}
canSave={firstName.trim().length > 0 && lastName.trim().length > 0 && matches.length === 0 && email.trim().length > 0}
canSave={firstName.trim().length > 0 &&
lastName.trim().length > 0 &&
matches.length === 0 &&
email.trim().length > 0 &&
canSave}
on:close={() => {
dispatch('close')
}}
@ -142,6 +152,7 @@
on:blur={changeEmail}
/>
</div>
<slot name="extraControls" />
</div>
<div class="ml-4">
<EditableAvatar avatar={object.avatar} {email} {id} size={'large'} bind:this={avatarEditor} />