UBER-252: mode int URL in MyLeads/MyApplications (#3347)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-06-06 16:13:24 +05:00 committed by GitHub
parent e72e16d97c
commit 1ceec126f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 47 deletions

View File

@ -130,6 +130,13 @@ export function createModel (builder: Builder): void {
label: lead.string.MyLeads,
icon: lead.icon.Lead,
component: lead.component.MyLeads,
componentProps: {
config: [
['assigned', view.string.Assigned, {}],
['created', view.string.Created, {}],
['subscribed', view.string.Subscribed, {}]
]
},
position: 'top'
},
{

View File

@ -336,7 +336,12 @@ export function createModel (builder: Builder): void {
position: 'event',
componentProps: {
labelTasks: recruit.string.Applications,
_class: recruit.class.Applicant
_class: recruit.class.Applicant,
config: [
['assigned', view.string.Assigned, {}],
['created', view.string.Created, {}],
['subscribed', view.string.Subscribed, {}]
]
}
},
{

View File

@ -1095,7 +1095,7 @@ export function createModel (builder: Builder): void {
componentProps: {
config: [
['assigned', view.string.Assigned, {}],
['created', view.string.Created, { value: 2 }],
['created', view.string.Created, {}],
['subscribed', view.string.Subscribed, {}]
]
}

View File

@ -16,7 +16,7 @@
import { EmployeeAccount } from '@hcengineering/contact'
import { AttachedDoc, Class, DocumentQuery, getCurrentAccount, Ref } from '@hcengineering/core'
import { createQuery, getClient } from '@hcengineering/presentation'
import task, { Task } from '@hcengineering/task'
import task from '@hcengineering/task'
import { IModeSelector, Label, resolvedLocationStore, SearchEdit, ModeSelector, Loading } from '@hcengineering/ui'
import {
FilterButton,
@ -26,26 +26,29 @@
viewOptionStore
} from '@hcengineering/view-resources'
import { IntlString } from '@hcengineering/platform'
import ViewletSettingButton from '@hcengineering/view-resources/src/components/ViewletSettingButton.svelte'
import view, { Viewlet, ViewletPreference } from '@hcengineering/view'
import { onDestroy } from 'svelte'
import FilterBar from '@hcengineering/view-resources/src/components/filter/FilterBar.svelte'
import { createEventDispatcher, onDestroy } from 'svelte'
import { FilterBar, ViewletSettingButton } from '@hcengineering/view-resources'
import lead from '../plugin'
import { Lead } from '@hcengineering/lead'
export let _class: Ref<Class<Lead>> = lead.class.Lead
export let labelTasks = lead.string.MyLeads
export let config: [string, IntlString, object][] = []
let search = ''
const dispatch = createEventDispatcher()
const currentUser = getCurrentAccount() as EmployeeAccount
const assigned = { assignee: currentUser.employee }
const created = { createdBy: currentUser._id }
let subscribed = { _id: { $in: [] as Ref<Task>[] } }
let subscribed = { _id: { $in: [] as Ref<Lead>[] } }
let mode: string | undefined = undefined
let baseQuery: DocumentQuery<Lead> | undefined = undefined
let modeSelectorProps: IModeSelector | undefined = undefined
$: queries = { assigned, created, subscribed }
$: mode = $resolvedLocationStore.query?.mode ?? undefined
$: baseQuery = updateBaseQuery(mode, { assigned, created, subscribed })
function updateBaseQuery (mode: string, queries: { [key: string]: DocumentQuery<Lead> }) {
return { ...queries[mode] }
}
let searchQuery: DocumentQuery<Lead> = { ...baseQuery }
function updateSearchQuery (search: string): void {
searchQuery = search === '' ? { ...baseQuery } : { ...baseQuery, $search: search }
@ -69,21 +72,17 @@
)
}
$: if (mode === 'subscribed') getSubscribed()
const config: [string, IntlString, object][] = [
['assigned', view.string.Assigned, {}],
['created', view.string.Created, {}],
['subscribed', view.string.Subscribed, {}]
]
let [[mode]] = config
function handleChangeMode (newMode: string) {
if (newMode === mode) return
mode = newMode
$: if (mode === undefined || queries[mode] === undefined) {
;[[mode]] = config
}
$: if (mode !== undefined) {
baseQuery = { ...queries[mode] }
modeSelectorProps = {
config,
mode,
onChange: (newMode: string) => dispatch('action', { mode: newMode })
}
}
$: modeSelectorProps = {
config,
mode,
onChange: handleChangeMode
} as IModeSelector
let viewlet: Viewlet | undefined
let loading = true

View File

@ -38,25 +38,28 @@
} from '@hcengineering/view-resources'
import task from '../plugin'
import { IntlString } from '@hcengineering/platform'
import ViewletSettingButton from '@hcengineering/view-resources/src/components/ViewletSettingButton.svelte'
import view, { Viewlet, ViewletPreference } from '@hcengineering/view'
import { onDestroy } from 'svelte'
import FilterBar from '@hcengineering/view-resources/src/components/filter/FilterBar.svelte'
import { createEventDispatcher, onDestroy } from 'svelte'
import { FilterBar, ViewletSettingButton } from '@hcengineering/view-resources'
export let _class: Ref<Class<Task>> = task.class.Task
export let labelTasks = task.string.Tasks
export let config: [string, IntlString, object][] = []
let search = ''
const dispatch = createEventDispatcher()
const currentUser = getCurrentAccount() as EmployeeAccount
const assigned = { assignee: currentUser.employee }
const created = { createdBy: currentUser._id }
let subscribed = { _id: { $in: [] as Ref<Task>[] } }
let mode: string | undefined = undefined
let baseQuery: DocumentQuery<Task> | undefined = undefined
let modeSelectorProps: IModeSelector | undefined = undefined
$: baseQuery = updateBaseQuery(mode, { assigned, created, subscribed })
function updateBaseQuery (mode: string, queries: { [key: string]: DocumentQuery<Task> }) {
return { ...queries[mode] }
}
let searchQuery: DocumentQuery<Task> = { ...baseQuery }
$: queries = { assigned, created, subscribed }
$: mode = $resolvedLocationStore.query?.mode ?? undefined
let searchQuery: DocumentQuery<Task> = { baseQuery }
function updateSearchQuery (search: string): void {
searchQuery = search === '' ? { ...baseQuery } : { ...baseQuery, $search: search }
}
@ -110,21 +113,17 @@
)
}
$: if (mode === 'subscribed') getSubscribed()
const config: [string, IntlString, object][] = [
['assigned', view.string.Assigned, {}],
['created', view.string.Created, {}],
['subscribed', view.string.Subscribed, {}]
]
let [[mode]] = config
function handleChangeMode (newMode: string) {
if (newMode === mode) return
mode = newMode
$: if (mode === undefined || queries[mode as keyof typeof queries] === undefined) {
;[[mode]] = config
}
$: if (mode !== undefined) {
baseQuery = { ...queries[mode as keyof typeof queries] }
modeSelectorProps = {
config,
mode,
onChange: (newMode: string) => dispatch('action', { mode: newMode })
}
}
$: modeSelectorProps = {
config,
mode,
onChange: handleChangeMode
} as IModeSelector
$: updateResultQuery(search, documentIds, doneStates)
let viewlets: WithLookup<Viewlet>[] | undefined