From 4e6317655a41cb316f86cea8e78c39f81ba23f40 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 16 Jun 2022 21:30:26 +0700 Subject: [PATCH] Show User box groupping (#2095) Signed-off-by: Andrey Sobolev --- models/lead/src/plugin.ts | 1 - .../src/components/ObjectPopup.svelte | 24 +++++++++++++++++++ .../src/components/UsersPopup.svelte | 17 ++++++++++++- .../src/components/CreateCustomer.svelte | 2 +- .../src/components/CreateLead.svelte | 11 ++++++++- plugins/lead-resources/src/plugin.ts | 3 ++- .../src/components/CreateCandidate.svelte | 2 +- .../src/components/CreateIssue.svelte | 14 +++++------ 8 files changed, 60 insertions(+), 14 deletions(-) diff --git a/models/lead/src/plugin.ts b/models/lead/src/plugin.ts index 519a3a33dc..e4e8f68330 100644 --- a/models/lead/src/plugin.ts +++ b/models/lead/src/plugin.ts @@ -36,7 +36,6 @@ export default mergeIds(leadId, lead, { GotoLeadApplication: '' as IntlString }, component: { - CreateFunnel: '' as AnyComponent, CreateLead: '' as AnyComponent, EditLead: '' as AnyComponent, KanbanCard: '' as AnyComponent, diff --git a/packages/presentation/src/components/ObjectPopup.svelte b/packages/presentation/src/components/ObjectPopup.svelte index 322ba31916..0f5102c525 100644 --- a/packages/presentation/src/components/ObjectPopup.svelte +++ b/packages/presentation/src/components/ObjectPopup.svelte @@ -48,6 +48,8 @@ export let searchField: string = 'name' + export let groupBy = '_class' + export let create: | { component: AnyComponent @@ -71,11 +73,19 @@ _id: { $nin: ignoreObjects } }, (result) => { + result.sort((a, b) => { + const aval: string = `${(a as any)[groupBy]}` + const bval: string = `${(b as any)[groupBy]}` + return aval.localeCompare(bval) + }) objects = result }, { ...(options ?? {}), limit: 200 } ) + $: showCategories = + objects.map((it) => (it as any)[groupBy]).filter((it, index, arr) => arr.indexOf(it) === index).length > 1 + const checkSelected = (person: Doc, objects: Doc[]): void => { if (selectedElements.has(person._id)) { selectedElements.delete(person._id) @@ -143,6 +153,9 @@ } }) } + function toAny (obj: any): any { + return obj + } @@ -162,6 +175,17 @@
+ + {#if showCategories} + {@const obj = toAny(objects[item])} + {#if item === 0 || (item > 0 && toAny(objects[item - 1])[groupBy] !== obj[groupBy])} + +
+ +
+ {/if} + {/if} +
{@const obj = objects[item]}
+ + + {@const cl = hierarchy.getClass(person._class)} +
+ + {#if cl.icon} + + {/if} + +
+
diff --git a/plugins/lead-resources/src/components/CreateCustomer.svelte b/plugins/lead-resources/src/components/CreateCustomer.svelte index 259299c339..7259856dc9 100644 --- a/plugins/lead-resources/src/components/CreateCustomer.svelte +++ b/plugins/lead-resources/src/components/CreateCustomer.svelte @@ -174,7 +174,7 @@ }} bind:createMore > - +