From 41ebded8c9b9360cedf22f026e4d310465c18c86 Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Wed, 22 Jun 2022 11:58:28 +0600 Subject: [PATCH] Nested filter fixes (#2123) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- models/hr/src/index.ts | 19 ---- models/hr/src/plugin.ts | 4 +- models/view/src/plugin.ts | 3 - packages/ui/src/components/Submenu.svelte | 12 ++- plugins/hr-assets/lang/en.json | 3 +- plugins/hr-assets/lang/ru.json | 3 +- .../components/filter/FilterTypePopup.svelte | 90 +++++++++++++++---- .../src/components/filter/ObjectFilter.svelte | 48 ++-------- plugins/view-resources/src/filter.ts | 2 - plugins/view-resources/src/index.ts | 4 +- plugins/view-resources/src/plugin.ts | 4 + 11 files changed, 97 insertions(+), 95 deletions(-) diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index 0c30dca9d6..4c8bc74ec7 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -120,25 +120,6 @@ export function createModel (builder: Builder): void { hr.action.EditDepartment ) - createAction( - builder, - { - action: view.actionImpl.ShowPopup, - actionProps: { - component: hr.component.DepartmentStaff, - element: 'float' - }, - label: hr.string.ShowEmployees, - icon: contact.icon.Person, - keyBinding: ['m'], - input: 'any', - category: hr.category.HR, - target: hr.class.Department, - context: { mode: 'context', application: hr.app.HR, group: 'top' } - }, - hr.action.ShowEmployees - ) - createAction( builder, { diff --git a/models/hr/src/plugin.ts b/models/hr/src/plugin.ts index 7ef3afc093..1c952f37c1 100644 --- a/models/hr/src/plugin.ts +++ b/models/hr/src/plugin.ts @@ -23,8 +23,7 @@ import { Action, ActionCategory } from '@anticrm/view' export default mergeIds(hrId, hr, { string: { HRApplication: '' as IntlString, - Departments: '' as IntlString, - ShowEmployees: '' as IntlString + Departments: '' as IntlString }, component: { Structure: '' as AnyComponent, @@ -37,7 +36,6 @@ export default mergeIds(hrId, hr, { }, action: { EditDepartment: '' as Ref, - ShowEmployees: '' as Ref, DeleteDepartment: '' as Ref } }) diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index 1d6a8bb83c..76a9230f20 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -60,9 +60,6 @@ export default mergeIds(viewId, view, { Open: '' as ViewAction }, component: { - ObjectFilter: '' as AnyComponent, - ValueFilter: '' as AnyComponent, - TimestampFilter: '' as AnyComponent, StringEditor: '' as AnyComponent, StringEditorPopup: '' as AnyComponent, StringPresenter: '' as AnyComponent, diff --git a/packages/ui/src/components/Submenu.svelte b/packages/ui/src/components/Submenu.svelte index 5281db3b05..dd910aaecd 100644 --- a/packages/ui/src/components/Submenu.svelte +++ b/packages/ui/src/components/Submenu.svelte @@ -28,13 +28,21 @@ export let label: IntlString | undefined = undefined export let labelProps: Record = {} export let withHover: boolean = false + export let element: HTMLElement | undefined = undefined - let element: HTMLElement let optionsMod: LabelAndProps $: optionsMod = { component: options.component ?? Menu, props, element, kind: 'submenu' } -
+
{#if component} {#if typeof component === 'string'} diff --git a/plugins/hr-assets/lang/en.json b/plugins/hr-assets/lang/en.json index 2e4e0c03f1..a15cecd9e0 100644 --- a/plugins/hr-assets/lang/en.json +++ b/plugins/hr-assets/lang/en.json @@ -4,7 +4,7 @@ "ParentDepartmentLabel": "Parent department", "Structure":"Structure", "CreateDepartment": "Create department", - "CreateDepartmentLabel": "Create department", + "CreateDepartmentLabel": "Department", "DepartmentPlaceholder": "Department", "TeamLead": "Team lead", "UnAssignLead": "Unassign team lead", @@ -15,7 +15,6 @@ "MoveStaff": "Employee transfer", "MoveStaffDescr": "Do you want to transfer employee from {current} to {department}", "Departments": "Departments", - "ShowEmployees": "Show employees", "AddEmployee": "Add employee" } } \ No newline at end of file diff --git a/plugins/hr-assets/lang/ru.json b/plugins/hr-assets/lang/ru.json index d6778287b4..bd5df8993f 100644 --- a/plugins/hr-assets/lang/ru.json +++ b/plugins/hr-assets/lang/ru.json @@ -4,7 +4,7 @@ "ParentDepartmentLabel": "Родительский департамент", "Structure":"Структура", "CreateDepartment": "Создать департамент", - "CreateDepartmentLabel": "Создать департамент", + "CreateDepartmentLabel": "Департамент", "DepartmentPlaceholder": "Департамент", "TeamLead": "Менеджер", "UnAssignLead": "Отменить назначение менеджера", @@ -15,7 +15,6 @@ "MoveStaff": "Перевод сотрудника", "MoveStaffDescr": "Вы действительно хотите перевести сотрудника из {current} в {department}", "Departments": "Департаменты", - "ShowEmployees": "Просмотреть сотрудников", "AddEmployee": "Добавить сотрудника" } } \ No newline at end of file diff --git a/plugins/view-resources/src/components/filter/FilterTypePopup.svelte b/plugins/view-resources/src/components/filter/FilterTypePopup.svelte index 669cbee2a5..f6fcf2313b 100644 --- a/plugins/view-resources/src/components/filter/FilterTypePopup.svelte +++ b/plugins/view-resources/src/components/filter/FilterTypePopup.svelte @@ -13,11 +13,12 @@ // limitations under the License. -->
{#each getTypes(_class) as type, i} - - + {#if filter === undefined && type.component === view.component.ObjectFilter && hasNested(type)} + keyDown(event, i)} + on:click={(event) => { + click(type) + }} + icon={type.icon} + label={type.label} + props={getNestedProps(type)} + options={{ component: view.component.FilterTypePopup }} + withHover + /> + {:else} + + + {/if} {/each}
diff --git a/plugins/view-resources/src/components/filter/ObjectFilter.svelte b/plugins/view-resources/src/components/filter/ObjectFilter.svelte index e44d141333..3345c25ee7 100644 --- a/plugins/view-resources/src/components/filter/ObjectFilter.svelte +++ b/plugins/view-resources/src/components/filter/ObjectFilter.svelte @@ -16,16 +16,13 @@ import { Class, Doc, FindResult, getObjectValue, Ref, RefTo, SortingOrder } from '@anticrm/core' import { translate } from '@anticrm/platform' import presentation, { getClient } from '@anticrm/presentation' - import ui, { Button, CheckBox, eventToHTMLElement, Label, Loading, showPopup } from '@anticrm/ui' - import { Filter } from '@anticrm/view' - import { onMount } from 'svelte' - import { buildConfigLookup, getPresenter } from '../../utils' - import view from '../../plugin' - import { createEventDispatcher } from 'svelte' - import task from '@anticrm/task' import type { State } from '@anticrm/task' - import FilterTypePopup from './FilterTypePopup.svelte' - import { FilterQuery } from '../../filter' + import task from '@anticrm/task' + import ui, { Button, CheckBox, Label, Loading } from '@anticrm/ui' + import { Filter } from '@anticrm/view' + import { createEventDispatcher, onMount } from 'svelte' + import view from '../../plugin' + import { buildConfigLookup, getPresenter } from '../../utils' export let _class: Ref> export let filter: Filter @@ -136,42 +133,9 @@ const dispatch = createEventDispatcher() getValues(search) - - $: byCriteria = hierarchy.hasMixin(clazz, view.mixin.ClassFilters) - - function setNestedFilter (e: Filter | undefined) { - if (e === undefined) return - filter.nested = e - filter.mode = view.filter.FilterNestedMatch - filter.modes = [view.filter.FilterNestedMatch, view.filter.FilterNestedDontMatch] - filter.value = e.value - filter.onRemove = () => { - FilterQuery.remove(filter.index) - } - onChange(filter) - dispatch('close') - } - - function nestedFilter (e: MouseEvent) { - const target = eventToHTMLElement(e) - showPopup( - FilterTypePopup, - { - _class: targetClass, - target, - index: filter.index, - filter: filter.nested, - onChange: setNestedFilter - }, - target - ) - }
- {#if byCriteria} -