Skip to content

Commit

Permalink
UBER-691 (#3564)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
  • Loading branch information
BykhovDenis authored Aug 7, 2023
1 parent 85d0400 commit 07cc690
Show file tree
Hide file tree
Showing 26 changed files with 346 additions and 306 deletions.
52 changes: 4 additions & 48 deletions plugins/calendar-resources/src/components/Events.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<Event> = {}
let viewlets: WithLookup<Viewlet>[] = []
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 }
Expand All @@ -66,30 +52,9 @@
let viewlet: WithLookup<Viewlet> | 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)
</script>

Expand All @@ -99,16 +64,7 @@
</div>

<div class="ac-header-full medium-gap mb-1">
{#if viewlets.length > 1}
<TabList
items={viewslist}
multiselect={false}
selected={viewlet?._id}
on:select={(result) => {
if (result.detail !== undefined) viewlet = viewlets.find((vl) => vl._id === result.detail.id)
}}
/>
{/if}
<ViewletSelector bind:viewlet bind:loading bind:preference bind:viewlets viewletQuery={{ attachTo: _class }} />
<Button icon={IconAdd} label={createLabel} kind={'accented'} on:click={showCreateDialog} />
</div>
</div>
Expand Down
19 changes: 13 additions & 6 deletions plugins/contact-resources/src/components/Contacts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -68,16 +74,17 @@
<FilterButton _class={contact.class.Contact} />
</div>
<div class="ac-header-full medium-gap">
<ViewletSettingButton
bind:viewOptions
<ViewletSelector
hidden
bind:viewlet
bind:preference
bind:loading
viewletQuery={{
attachTo: contact.class.Contact,
descriptor: view.viewlet.Table
}}
bind:viewlet
bind:preference
bind:loading
/>
<ViewletSettingButton bind:viewOptions bind:viewlet />
<!-- <ActionIcon icon={IconMoreH} size={'small'} /> -->
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions plugins/contact-resources/src/components/Members.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -75,13 +75,14 @@
<Label label={contact.string.Members} />
</span>
<div class="buttons-group xsmall-gap">
<ViewletSettingButton
viewletQuery={{ _id: contact.viewlet.TableMember }}
kind={'ghost'}
<ViewletSelector
hidden
bind:viewlet
bind:preference
bind:loading
viewletQuery={{ _id: contact.viewlet.TableMember }}
/>
<ViewletSettingButton kind={'ghost'} bind:viewlet />
<Button id={contact.string.AddMember} icon={IconAdd} kind={'ghost'} on:click={createApp} />
</div>
</div>
Expand Down
12 changes: 7 additions & 5 deletions plugins/document-resources/src/components/Documents.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { ActionContext } from '@hcengineering/presentation'
import { Label, Loading, SearchEdit } from '@hcengineering/ui'
import view, { Viewlet, ViewletPreference } from '@hcengineering/view'
import { FilterButton, TableBrowser, ViewletSettingButton } from '@hcengineering/view-resources'
import { FilterButton, TableBrowser, ViewletSelector, ViewletSettingButton } from '@hcengineering/view-resources'
import document from '../plugin'
export let query: DocumentQuery<Document> = {}
Expand Down Expand Up @@ -57,15 +57,17 @@
<FilterButton _class={document.class.Document} />
</div>
<div class="ac-header-full medium-gap">
<ViewletSettingButton
<ViewletSelector
hidden
bind:viewlet
bind:preference
bind:loading
viewletQuery={{
attachTo: document.class.Document,
descriptor: view.viewlet.Table
}}
bind:viewlet
bind:preference
bind:loading
/>
<ViewletSettingButton bind:viewlet />
<!-- <ActionIcon icon={IconMoreH} size={'small'} /> -->
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions plugins/hr-resources/src/components/DepartmentStaff.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { createQuery, getClient } from '@hcengineering/presentation'
import { Button, IconAdd, Label, Scroller, eventToHTMLElement, 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 hr from '../plugin'
import { addMember } from '../utils'
Expand Down Expand Up @@ -73,13 +73,14 @@
<Label label={hr.string.Members} />
</span>
<div class="flex-row-center gap-2 reverse">
<ViewletSettingButton
viewletQuery={{ _id: hr.viewlet.TableMember }}
kind={'ghost'}
<ViewletSelector
hidden
bind:viewlet
bind:preference
bind:loading
viewletQuery={{ _id: hr.viewlet.TableMember }}
/>
<ViewletSettingButton kind={'ghost'} bind:viewlet />
<Button id={hr.string.AddEmployee} icon={IconAdd} kind={'ghost'} on:click={add} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { getEmbeddedLabel } from '@hcengineering/platform'
import { Button, Label, Loading, showPopup, tableToCSV } from '@hcengineering/ui'
import { BuildModelKey, Viewlet, ViewletPreference } from '@hcengineering/view'
import { TableBrowser, ViewletSettingButton } from '@hcengineering/view-resources'
import { TableBrowser, ViewletSelector, ViewletSettingButton } from '@hcengineering/view-resources'
import hr from '../../plugin'
import {
EmployeeReports,
Expand Down Expand Up @@ -367,7 +367,14 @@
<div class="clear-mins" />
<div class="ac-header-full small-gap">
<Button label={getEmbeddedLabel('Export')} on:click={(evt) => exportTable(evt)} />
<ViewletSettingButton viewletQuery={{ _id: hr.viewlet.StaffStats }} bind:viewlet bind:preference bind:loading />
<ViewletSelector
hidden
bind:viewlet
bind:preference
bind:loading
viewletQuery={{ _id: hr.viewlet.StaffStats }}
/>
<ViewletSettingButton bind:viewlet />
</div>
</div>
{#if viewlet}
Expand Down
19 changes: 13 additions & 6 deletions plugins/lead-resources/src/components/MyLeads.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
import task from '@hcengineering/task'
import { IModeSelector, Label, Loading, ModeSelector, resolvedLocationStore, SearchEdit } from '@hcengineering/ui'
import { 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 { createEventDispatcher } from 'svelte'
import lead from '../plugin'
Expand Down Expand Up @@ -102,16 +108,17 @@
<div class="buttons-divider" />
<FilterButton {_class} />
</div>
<ViewletSettingButton
bind:viewOptions
<ViewletSelector
hidden
bind:viewlet
bind:preference
bind:loading
viewletQuery={{
attachTo: _class,
descriptor: task.viewlet.StatusTable
}}
bind:viewlet
bind:preference
bind:loading
/>
<ViewletSettingButton bind:viewOptions bind:viewlet />
</div>
<FilterBar {_class} query={searchQuery} {viewOptions} on:change={(e) => (resultQuery = e.detail)} />

Expand Down
4 changes: 2 additions & 2 deletions plugins/recruit-resources/src/components/Applications.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import type { Doc, Ref } from '@hcengineering/core'
import { Button, Icon, IconAdd, Label, Scroller, showPopup } from '@hcengineering/ui'
import { Viewlet, ViewletPreference } from '@hcengineering/view'
import { Table, ViewletSettingButton } from '@hcengineering/view-resources'
import { Table, ViewletsSettingButton } from '@hcengineering/view-resources'
import recruit from '../plugin'
import CreateApplication from './CreateApplication.svelte'
import IconApplication from './icons/Application.svelte'
Expand Down Expand Up @@ -44,7 +44,7 @@
<Label label={recruit.string.Applications} />
</span>
<div class="flex-row-center gap-2 reverse">
<ViewletSettingButton
<ViewletsSettingButton
viewletQuery={{ _id: recruit.viewlet.VacancyApplicationsEmbeddeed }}
kind={'ghost'}
bind:viewlet
Expand Down
15 changes: 11 additions & 4 deletions plugins/recruit-resources/src/components/Organizations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
import { Applicant, Vacancy } from '@hcengineering/recruit'
import { Button, IconAdd, Label, Loading, SearchEdit, showPopup } from '@hcengineering/ui'
import view, { BuildModelKey, 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 recruit from '../plugin'
import CreateOrganization from './CreateOrganization.svelte'
import VacancyListApplicationsPopup from './organizations/VacancyListApplicationsPopup.svelte'
Expand Down Expand Up @@ -205,16 +211,17 @@
<FilterButton _class={recruit.mixin.VacancyList} />
</div>
<div class="ac-header-full medium-gap">
<ViewletSettingButton
bind:viewOptions
<ViewletSelector
hidden
viewletQuery={{
attachTo: recruit.mixin.VacancyList,
descriptor: view.viewlet.Table
}}
bind:viewlet
bind:preference
bind:loading
bind:viewlet
/>
<ViewletSettingButton bind:viewOptions bind:viewlet />
<!-- <ActionIcon icon={IconMoreH} size={'small'} /> -->
</div>
</div>
Expand Down
15 changes: 11 additions & 4 deletions plugins/recruit-resources/src/components/Vacancies.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
import { Vacancy } from '@hcengineering/recruit'
import { Button, IconAdd, Label, Loading, SearchEdit, showPopup, tableToCSV } from '@hcengineering/ui'
import view, { BuildModelKey, ViewOptions, Viewlet, ViewletPreference } from '@hcengineering/view'
import { FilterBar, FilterButton, TableBrowser, ViewletSettingButton } from '@hcengineering/view-resources'
import {
FilterBar,
FilterButton,
TableBrowser,
ViewletSelector,
ViewletSettingButton
} from '@hcengineering/view-resources'
import recruit from '../plugin'
import CreateVacancy from './CreateVacancy.svelte'
Expand Down Expand Up @@ -149,16 +155,17 @@
<FilterButton _class={recruit.class.Vacancy} />
</div>
<div class="ac-header-full medium-gap">
<ViewletSettingButton
bind:viewOptions
<ViewletSelector
hidden
viewletQuery={{
attachTo: recruit.class.Vacancy,
descriptor: view.viewlet.Table
}}
bind:viewlet
bind:preference
bind:loading
bind:viewlet
/>
<ViewletSettingButton bind:viewOptions bind:viewlet />
<!-- <ActionIcon icon={IconMoreH} size={'small'} /> -->
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { recruitId, Vacancy } from '@hcengineering/recruit'
import { Button, Icon, IconAdd, Label, Loading, resizeObserver, Scroller, showPopup } from '@hcengineering/ui'
import { Viewlet, ViewletPreference } from '@hcengineering/view'
import { NavLink, Table, ViewletSettingButton } from '@hcengineering/view-resources'
import { NavLink, Table, ViewletsSettingButton } from '@hcengineering/view-resources'
import recruit from '../plugin'
import CreateApplication from './CreateApplication.svelte'
import IconApplication from './icons/Application.svelte'
Expand Down Expand Up @@ -53,7 +53,7 @@
</NavLink>
</span>
<div class="flex-row-center gap-2 reverse">
<ViewletSettingButton
<ViewletsSettingButton
viewletQuery={{ _id: recruit.viewlet.VacancyApplicationsShort }}
kind={'ghost'}
bind:viewlet
Expand Down
Loading

0 comments on commit 07cc690

Please sign in to comment.