From 07cc690d23045fec637e7a2e08884da3e967ab5d Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Mon, 7 Aug 2023 20:17:31 +0600 Subject: [PATCH] UBER-691 (#3564) Signed-off-by: Denis Bykhov --- .../src/components/Events.svelte | 52 +-------- .../src/components/Contacts.svelte | 19 +++- .../src/components/Members.svelte | 9 +- .../src/components/Documents.svelte | 12 +- .../src/components/DepartmentStaff.svelte | 9 +- .../components/schedule/MonthTableView.svelte | 11 +- .../src/components/MyLeads.svelte | 19 +++- .../src/components/Applications.svelte | 4 +- .../src/components/Organizations.svelte | 15 ++- .../src/components/Vacancies.svelte | 15 ++- .../src/components/VacancyApplications.svelte | 4 +- .../src/components/AssignedTasks.svelte | 15 ++- .../components/ComponentBrowser.svelte | 23 +--- .../src/components/issues/IssuesView.svelte | 10 +- .../components/issues/edit/SubIssues.svelte | 4 +- .../related/RelatedIssuesSection.svelte | 4 +- .../milestones/MilestoneBrowser.svelte | 5 +- .../templates/IssueTemplatesView.svelte | 7 +- .../src/components/SpaceHeader.svelte | 35 +----- .../src/components/ViewletSelector.svelte | 104 ++++++++++++++++++ .../components/ViewletSettingButton.svelte | 77 +------------ .../components/ViewletsSettingButton.svelte | 97 ++++++++++++++++ plugins/view-resources/src/index.ts | 3 + plugins/view-resources/src/viewOptions.ts | 8 ++ .../src/components/SpaceHeader.svelte | 28 +---- .../src/components/SpecialView.svelte | 63 +++-------- 26 files changed, 346 insertions(+), 306 deletions(-) create mode 100644 plugins/view-resources/src/components/ViewletSelector.svelte create mode 100644 plugins/view-resources/src/components/ViewletsSettingButton.svelte diff --git a/plugins/calendar-resources/src/components/Events.svelte b/plugins/calendar-resources/src/components/Events.svelte index 26d04cfa7f..e5ab5da7ab 100644 --- a/plugins/calendar-resources/src/components/Events.svelte +++ b/plugins/calendar-resources/src/components/Events.svelte @@ -16,10 +16,9 @@ import { Event } from '@hcengineering/calendar' import { Class, DocumentQuery, Ref, Space, WithLookup } from '@hcengineering/core' import { Asset, IntlString } from '@hcengineering/platform' - import { createQuery } from '@hcengineering/presentation' - import { AnyComponent, Button, Component, Label, Loading, showPopup, TabList, IconAdd } from '@hcengineering/ui' - import view, { Viewlet, ViewletPreference } from '@hcengineering/view' - import { getViewOptions, setActiveViewletId, viewOptionStore } from '@hcengineering/view-resources' + import { AnyComponent, Button, Component, IconAdd, Label, Loading, showPopup } from '@hcengineering/ui' + import { Viewlet, ViewletPreference } from '@hcengineering/view' + import { ViewletSelector, getViewOptions, viewOptionStore } from '@hcengineering/view-resources' import calendar from '../plugin' // import { deviceOptionsStore as deviceInfo } from '@hcengineering/ui' @@ -33,23 +32,10 @@ export let createComponent: AnyComponent | undefined = calendar.component.CreateEvent export let createLabel: IntlString | undefined = calendar.string.CreateEvent - const viewletQuery = createQuery() const search = '' let resultQuery: DocumentQuery = {} let viewlets: WithLookup[] = [] - viewletQuery.query( - view.class.Viewlet, - { attachTo: _class }, - (res) => { - viewlets = res - if (viewlet === undefined || res.findIndex((p) => p._id === viewlet?._id) === -1) { - viewlet = res[0] - setActiveViewletId(viewlet._id) - } - }, - { lookup: { descriptor: view.class.ViewletDescriptor } } - ) function updateResultQuery (search: string): void { resultQuery = search === '' ? { ...query } : { ...query, $search: search } @@ -66,30 +52,9 @@ let viewlet: WithLookup | undefined - const preferenceQuery = createQuery() let preference: ViewletPreference | undefined let loading = true - $: viewlet && - preferenceQuery.query( - view.class.ViewletPreference, - { - attachedTo: viewlet._id - }, - (res) => { - preference = res[0] - loading = false - }, - { limit: 1 } - ) - $: viewslist = viewlets.map((views) => { - return { - id: views._id, - icon: views.$lookup?.descriptor?.icon, - tooltip: views.$lookup?.descriptor?.label - } - }) - $: viewOptions = getViewOptions(viewlet, $viewOptionStore) @@ -99,16 +64,7 @@
- {#if viewlets.length > 1} - { - if (result.detail !== undefined) viewlet = viewlets.find((vl) => vl._id === result.detail.id) - }} - /> - {/if} +
diff --git a/plugins/contact-resources/src/components/Contacts.svelte b/plugins/contact-resources/src/components/Contacts.svelte index 7686e25a7e..0dfcaaf32c 100644 --- a/plugins/contact-resources/src/components/Contacts.svelte +++ b/plugins/contact-resources/src/components/Contacts.svelte @@ -18,7 +18,13 @@ import { ActionContext } from '@hcengineering/presentation' import { Button, Label, Loading, SearchEdit, showPopup } from '@hcengineering/ui' import view, { Viewlet, ViewletPreference, ViewOptions } from '@hcengineering/view' - import { FilterBar, FilterButton, TableBrowser, ViewletSettingButton } from '@hcengineering/view-resources' + import { + FilterBar, + FilterButton, + TableBrowser, + ViewletSelector, + ViewletSettingButton + } from '@hcengineering/view-resources' import contact from '../plugin' import CreateContact from './CreateContact.svelte' // import { deviceOptionsStore as deviceInfo } from '@hcengineering/ui' @@ -68,16 +74,17 @@
-
diff --git a/plugins/contact-resources/src/components/Members.svelte b/plugins/contact-resources/src/components/Members.svelte index cc9a34a4e0..8c7002e036 100644 --- a/plugins/contact-resources/src/components/Members.svelte +++ b/plugins/contact-resources/src/components/Members.svelte @@ -18,7 +18,7 @@ import { createQuery, getClient } from '@hcengineering/presentation' import { Button, Icon, IconAdd, Label, showPopup } from '@hcengineering/ui' import { Viewlet, ViewletPreference } from '@hcengineering/view' - import { Table, ViewletSettingButton } from '@hcengineering/view-resources' + import { Table, ViewletSelector, ViewletSettingButton } from '@hcengineering/view-resources' import contact from '../plugin' import UsersPopup from './UsersPopup.svelte' import IconMembersOutline from './icons/MembersOutline.svelte' @@ -75,13 +75,14 @@