From 22652d72a37d50ce77efde01d1cc0f5f018ccab9 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Wed, 19 Jan 2022 16:05:40 +0700 Subject: [PATCH] Fix full text search control behaviour (#838) Signed-off-by: Andrey Sobolev --- packages/ui/lang/en.json | 3 +- .../ui/src/components/EditWithIcon.svelte | 6 ++- packages/ui/src/components/SearchEdit.svelte | 42 +++++++++++++++++++ packages/ui/src/index.ts | 1 + packages/ui/src/plugin.ts | 11 ++--- .../src/components/Contacts.svelte | 13 ++++-- .../src/components/Categories.svelte | 24 +++++------ .../src/components/Customers.svelte | 14 +++++-- .../src/components/Candidates.svelte | 20 +++++---- .../src/components/SpaceHeader.svelte | 31 +++++++++----- .../src/components/SpaceView.svelte | 16 +++---- 11 files changed, 126 insertions(+), 55 deletions(-) create mode 100644 packages/ui/src/components/SearchEdit.svelte diff --git a/packages/ui/lang/en.json b/packages/ui/lang/en.json index 2570573528..733827aefd 100644 --- a/packages/ui/lang/en.json +++ b/packages/ui/lang/en.json @@ -5,6 +5,7 @@ "Hours": "{hours, plural, =0 {less than an hour ago} =1 {an hour ago} other {# hours ago}}", "Days": "{days, plural, =0 {today} =1 {yesterday} other {# days ago}}", "ShowMore": "Show more", - "ShowLess": "Show less" + "ShowLess": "Show less", + "Search": "Search" } } diff --git a/packages/ui/src/components/EditWithIcon.svelte b/packages/ui/src/components/EditWithIcon.svelte index 286507a95b..d0f0805f37 100644 --- a/packages/ui/src/components/EditWithIcon.svelte +++ b/packages/ui/src/components/EditWithIcon.svelte @@ -15,6 +15,7 @@
textHTML.focus()}>
- + {#if value} -
{ textHTML.value = ''; textHTML.dispatchEvent(new Event('change')) }}> +
{ value = ''; dispatch('change', '') }}>
{/if} diff --git a/packages/ui/src/components/SearchEdit.svelte b/packages/ui/src/components/SearchEdit.svelte new file mode 100644 index 0000000000..65145030a1 --- /dev/null +++ b/packages/ui/src/components/SearchEdit.svelte @@ -0,0 +1,42 @@ + + + { + if (_search === '') { + value = '' + dispatch('change', '') + } + }} + on:input={() => { + if (_search === '') { + value = '' + dispatch('change', '') + } + }} + on:keydown={(evt) => { + if (evt.key === 'Enter') { + value = _search + dispatch('change', _search) + } + }} +/> diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index a925c511dd..df3efccda9 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -53,6 +53,7 @@ export { default as Row } from './components/Row.svelte' // export { default as CheckBoxWithLabel } from './components/CheckBoxWithLabel.svelte' // export { default as CheckBoxList } from './components/CheckBoxList.svelte.txt' export { default as EditWithIcon } from './components/EditWithIcon.svelte' +export { default as SearchEdit } from './components/SearchEdit.svelte' export { default as Loading } from './components/Loading.svelte' export { default as Spinner } from './components/Spinner.svelte' export { default as Popup } from './components/Popup.svelte' diff --git a/packages/ui/src/plugin.ts b/packages/ui/src/plugin.ts index 4d632ee4e9..a2ce649acd 100644 --- a/packages/ui/src/plugin.ts +++ b/packages/ui/src/plugin.ts @@ -1,15 +1,15 @@ // // Copyright © 2020, 2021 Anticrm Platform Contributors. // Copyright © 2021 Hardcore Engineering Inc. -// +// // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may // obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// +// // See the License for the specific language governing permissions and // limitations under the License. // @@ -29,6 +29,7 @@ export default plugin(uiId, { Hours: '' as IntlString, Days: '' as IntlString, ShowMore: '' as IntlString, - ShowLess: '' as IntlString + ShowLess: '' as IntlString, + Search: '' as IntlString } -}) \ No newline at end of file +}) diff --git a/plugins/contact-resources/src/components/Contacts.svelte b/plugins/contact-resources/src/components/Contacts.svelte index 35a2bc9f7b..da7ccd8909 100644 --- a/plugins/contact-resources/src/components/Contacts.svelte +++ b/plugins/contact-resources/src/components/Contacts.svelte @@ -15,15 +15,20 @@ -->
@@ -32,7 +36,9 @@
- { resultQuery = {} } } /> + { + updateResultQuery(search) + }}/>
diff --git a/plugins/recruit-resources/src/components/Candidates.svelte b/plugins/recruit-resources/src/components/Candidates.svelte index 000e8b35ae..6d7764d3f1 100644 --- a/plugins/recruit-resources/src/components/Candidates.svelte +++ b/plugins/recruit-resources/src/components/Candidates.svelte @@ -15,18 +15,21 @@ -->
@@ -44,7 +48,9 @@
- { resultQuery = {} } } /> + { + updateResultQuery(search) + }}/>