From f90ee0ea5dddab3f9267bd95ccdd6d486f596342 Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Wed, 29 Jun 2022 08:53:57 +0300 Subject: [PATCH] HR: update values on blur (#2161) Signed-off-by: Alexander Platov --- .../src/components/FullDescriptionBox.svelte | 64 ++----------------- .../src/components/StyledTextBox.svelte | 5 ++ packages/ui/src/components/EditBox.svelte | 3 + .../src/components/EditFunnel.svelte | 22 +++---- .../src/components/EditLead.svelte | 13 +++- .../src/components/EditVacancy.svelte | 22 +++---- .../src/components/review/EditReview.svelte | 18 ++++-- .../src/components/issues/IssuesList.svelte | 10 +-- 8 files changed, 63 insertions(+), 94 deletions(-) diff --git a/packages/text-editor/src/components/FullDescriptionBox.svelte b/packages/text-editor/src/components/FullDescriptionBox.svelte index 3a34fcea9d..072dc8255a 100644 --- a/packages/text-editor/src/components/FullDescriptionBox.svelte +++ b/packages/text-editor/src/components/FullDescriptionBox.svelte @@ -16,7 +16,7 @@
@@ -44,57 +43,6 @@ - {#if !hideButtons && !alwaysEdit} -
- {#if editMode} -
- {/if}
- {#if !editMode && (content === '' || content === '

' || content === undefined) && !alwaysEdit} -
-
- {:else} - { - dispatch('change', evt.detail) - }} - /> - {/if} + diff --git a/packages/text-editor/src/components/StyledTextBox.svelte b/packages/text-editor/src/components/StyledTextBox.svelte index 072558fb2b..3de50c6b69 100644 --- a/packages/text-editor/src/components/StyledTextBox.svelte +++ b/packages/text-editor/src/components/StyledTextBox.svelte @@ -36,16 +36,21 @@ mode = Mode.View } export function cancelEdit (): void { + rawValue = content mode = Mode.View } let rawValue: string let oldContent = '' + let modified: boolean = false $: if (oldContent !== content) { oldContent = content rawValue = content + modified = false } + $: if (!modified && rawValue !== content) modified = true + $: dispatch('change', modified) let textEditor: StyledTextEditor diff --git a/packages/ui/src/components/EditBox.svelte b/packages/ui/src/components/EditBox.svelte index ea37ca6a85..72161b6f68 100644 --- a/packages/ui/src/components/EditBox.svelte +++ b/packages/ui/src/components/EditBox.svelte @@ -127,6 +127,7 @@ on:change on:keydown on:keypress + on:blur /> {:else if format === 'number'} {:else} {/if} diff --git a/plugins/lead-resources/src/components/EditFunnel.svelte b/plugins/lead-resources/src/components/EditFunnel.svelte index 5098655f80..f2eb02572f 100644 --- a/plugins/lead-resources/src/components/EditFunnel.svelte +++ b/plugins/lead-resources/src/components/EditFunnel.svelte @@ -29,6 +29,8 @@ export let _id: Ref let object: Required + let rawName: string = '' + let rawDesc: string = '' const dispatch = createEventDispatcher() @@ -40,6 +42,8 @@ function updateObject (_id: Ref): void { query.query(lead.class.Funnel, { _id }, (result) => { object = result[0] as Required + rawName = object.name + rawDesc = object.description }) } @@ -85,13 +89,8 @@ kind={'large-style'} focus focusable - on:change={() => { - if (object.name.trim().length > 0) { - onChange('name', object.name) - } else { - // Revert previos object.name - updateObject(_id) - } + on:blur={() => { + if (rawName !== object.name) onChange('name', object.name) }} /> { - onChange('description', object.description) + on:blur={() => { + if (rawDesc !== object.description) onChange('description', object.description) }} /> { - if (result.detail !== undefined) onChange('fullDescription', result.detail) + on:save={(res) => { + onChange('fullDescription', res.detail) }} /> change('title', object.title)} + on:blur={() => { + if (rawTitle !== object.title) change('title', rawTitle) + }} /> let object: Required + let rawName: string = '' + let rawDesc: string = '' const dispatch = createEventDispatcher() @@ -40,6 +42,8 @@ function updateObject (_id: Ref): void { query.query(recruit.class.Vacancy, { _id }, (result) => { object = result[0] as Required + rawName = object.name + rawDesc = object.description }) } @@ -85,13 +89,8 @@ kind={'large-style'} focus focusable - on:change={() => { - if (object.name.trim().length > 0) { - onChange('name', object.name) - } else { - // Revert previos object.name - updateObject(_id) - } + on:blur={() => { + if (rawName !== object.name) onChange('name', object.name) }} /> { - onChange('description', object.description) + on:blur={() => { + if (rawDesc !== object.description) onChange('description', object.description) }} /> { - if (result.detail !== undefined) onChange('fullDescription', result.detail) + on:save={(res) => { + onChange('fullDescription', res.detail) }} /> { dispatch('open', { ignoreKeys: ['number', 'comments', 'title', 'description', 'verdict'], @@ -49,11 +56,13 @@ client.update(object, { title: object.title })} + on:blur={() => { + if (rawTitle !== object.title) client.update(object, { title: rawTitle }) + }} />
{ - client.update(object, { description: evt.detail }) + on:save={(res) => { + client.update(object, { description: res.detail }) }} />