diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index d590f7012c..a623e3504c 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -621,6 +621,20 @@ export function createModel (builder: Builder): void { configOptions: { hiddenKeys: ['name'], sortable: true + }, + viewOptions: { + groupBy: [], + orderBy: [], + other: [ + { + key: 'hideInactive', + type: 'toggle', + defaultValue: true, + actionTarget: 'query', + action: contact.function.HideInactive, + label: contact.string.HideInactive + } + ] } }, contact.viewlet.TableEmployee diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 5414d33bd8..4e5ebff78a 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -16,7 +16,7 @@ import { contactId } from '@hcengineering/contact' import contact from '@hcengineering/contact-resources/src/plugin' -import type { Client, Doc, DocManager, Ref } from '@hcengineering/core' +import type { Client, Doc, DocManager, DocumentQuery, Ref } from '@hcengineering/core' import { type ObjectSearchCategory, type ObjectSearchFactory } from '@hcengineering/model-presentation' import { type NotificationGroup } from '@hcengineering/notification' import { type IntlString, mergeIds, type Resource } from '@hcengineering/platform' @@ -144,7 +144,8 @@ export default mergeIds(contactId, contact, { ChannelTitleProvider: '' as Resource<(client: Client, ref: Ref, doc?: Doc) => Promise>, ChannelIdentifierProvider: '' as Resource<(client: Client, ref: Ref, doc?: Doc) => Promise>, SetPersonStore: '' as Resource<(manager: DocManager) => void>, - PersonFilterFunction: '' as Resource<(doc: Doc, target: Doc) => boolean> + PersonFilterFunction: '' as Resource<(doc: Doc, target: Doc) => boolean>, + HideInactive: '' as Resource<(value: any, query: DocumentQuery) => DocumentQuery> }, resolver: { LocationData: '' as Resource<(loc: Location) => Promise> diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index 3f87a0afd1..9dc5446f38 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -422,7 +422,21 @@ export function createModel (builder: Builder): void { { attachTo: hr.mixin.Staff, descriptor: view.viewlet.Table, - config: [''] + config: [''], + viewOptions: { + groupBy: [], + orderBy: [], + other: [ + { + key: 'hideInactive', + type: 'toggle', + defaultValue: true, + actionTarget: 'query', + action: contact.function.HideInactive, + label: contact.string.HideInactive + } + ] + } }, hr.viewlet.StaffStats ) diff --git a/plugins/contact-assets/lang/cs.json b/plugins/contact-assets/lang/cs.json index 9c821d9480..bdb23e5828 100644 --- a/plugins/contact-assets/lang/cs.json +++ b/plugins/contact-assets/lang/cs.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "Za 1 hodinu", "WorkspaceStatusIn4Hours": "Za 4 hodiny", "WorkspaceStatusEndOfDay": "Do konce dne", - "WorkspaceStatusPickDate": "Vyberte datum" + "WorkspaceStatusPickDate": "Vyberte datum", + "HideInactive": "Skrýt neaktivní" } } diff --git a/plugins/contact-assets/lang/de.json b/plugins/contact-assets/lang/de.json index eaf64bfafe..52c1b58ca3 100644 --- a/plugins/contact-assets/lang/de.json +++ b/plugins/contact-assets/lang/de.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "In 1 Stunde", "WorkspaceStatusIn4Hours": "In 4 Stunden", "WorkspaceStatusEndOfDay": "Ende des Tages", - "WorkspaceStatusPickDate": "Datum wählen" + "WorkspaceStatusPickDate": "Datum wählen", + "HideInactive": "Inaktive ausblenden" } } diff --git a/plugins/contact-assets/lang/en.json b/plugins/contact-assets/lang/en.json index 315baf7a16..785db069dd 100644 --- a/plugins/contact-assets/lang/en.json +++ b/plugins/contact-assets/lang/en.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "In 1 hour", "WorkspaceStatusIn4Hours": "In 4 hours", "WorkspaceStatusEndOfDay": "End of day", - "WorkspaceStatusPickDate": "Choose date" + "WorkspaceStatusPickDate": "Choose date", + "HideInactive": "Hide inactive" } } diff --git a/plugins/contact-assets/lang/es.json b/plugins/contact-assets/lang/es.json index a1a6837567..a6234d1411 100644 --- a/plugins/contact-assets/lang/es.json +++ b/plugins/contact-assets/lang/es.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "En 1 hora", "WorkspaceStatusIn4Hours": "En 4 horas", "WorkspaceStatusEndOfDay": "Fin del día", - "WorkspaceStatusPickDate": "Elegir fecha" + "WorkspaceStatusPickDate": "Elegir fecha", + "HideInactive": "Ocultar inactivos" } } diff --git a/plugins/contact-assets/lang/fr.json b/plugins/contact-assets/lang/fr.json index 8401064a71..90c95f8fdd 100644 --- a/plugins/contact-assets/lang/fr.json +++ b/plugins/contact-assets/lang/fr.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "Dans 1 heure", "WorkspaceStatusIn4Hours": "Dans 4 heures", "WorkspaceStatusEndOfDay": "Fin de journée", - "WorkspaceStatusPickDate": "Choisir une date" + "WorkspaceStatusPickDate": "Choisir une date", + "HideInactive": "Masquer les inactifs" } } diff --git a/plugins/contact-assets/lang/it.json b/plugins/contact-assets/lang/it.json index 3f853c6e30..93d171e9f7 100644 --- a/plugins/contact-assets/lang/it.json +++ b/plugins/contact-assets/lang/it.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "Tra 1 ora", "WorkspaceStatusIn4Hours": "Tra 4 ore", "WorkspaceStatusEndOfDay": "Fine giornata", - "WorkspaceStatusPickDate": "Scegli data" + "WorkspaceStatusPickDate": "Scegli data", + "HideInactive": "Nascondi inattivi" } } diff --git a/plugins/contact-assets/lang/ja.json b/plugins/contact-assets/lang/ja.json index 82575cdba0..4ef802e014 100644 --- a/plugins/contact-assets/lang/ja.json +++ b/plugins/contact-assets/lang/ja.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "1時間後", "WorkspaceStatusIn4Hours": "4時間後", "WorkspaceStatusEndOfDay": "今日の終わりまで", - "WorkspaceStatusPickDate": "日付を選択" + "WorkspaceStatusPickDate": "日付を選択", + "HideInactive": "非アクティブを非表示" } } diff --git a/plugins/contact-assets/lang/pt-br.json b/plugins/contact-assets/lang/pt-br.json index f9624fb6c5..d61ef6eb92 100644 --- a/plugins/contact-assets/lang/pt-br.json +++ b/plugins/contact-assets/lang/pt-br.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "Em 1 hora", "WorkspaceStatusIn4Hours": "Em 4 horas", "WorkspaceStatusEndOfDay": "Fim do dia", - "WorkspaceStatusPickDate": "Escolher data" + "WorkspaceStatusPickDate": "Escolher data", + "HideInactive": "Ocultar inativos" } } diff --git a/plugins/contact-assets/lang/pt.json b/plugins/contact-assets/lang/pt.json index 759d6f10c2..bf4e701f65 100644 --- a/plugins/contact-assets/lang/pt.json +++ b/plugins/contact-assets/lang/pt.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "Em 1 hora", "WorkspaceStatusIn4Hours": "Em 4 horas", "WorkspaceStatusEndOfDay": "Fim do dia", - "WorkspaceStatusPickDate": "Escolher data" + "WorkspaceStatusPickDate": "Escolher data", + "HideInactive": "Ocultar inativos" } } diff --git a/plugins/contact-assets/lang/ru.json b/plugins/contact-assets/lang/ru.json index e98bbc5892..37bc47b0bf 100644 --- a/plugins/contact-assets/lang/ru.json +++ b/plugins/contact-assets/lang/ru.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "Через 1 час", "WorkspaceStatusIn4Hours": "Через 4 часа", "WorkspaceStatusEndOfDay": "До конца дня", - "WorkspaceStatusPickDate": "Выбрать дату" + "WorkspaceStatusPickDate": "Выбрать дату", + "HideInactive": "Скрыть неактивных" } } diff --git a/plugins/contact-assets/lang/tr.json b/plugins/contact-assets/lang/tr.json index efbea87cea..968ce5953b 100644 --- a/plugins/contact-assets/lang/tr.json +++ b/plugins/contact-assets/lang/tr.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "1 saat içinde", "WorkspaceStatusIn4Hours": "4 saat içinde", "WorkspaceStatusEndOfDay": "Gün sonu", - "WorkspaceStatusPickDate": "Tarih seç" + "WorkspaceStatusPickDate": "Tarih seç", + "HideInactive": "Etkin olmayanları gizle" } } diff --git a/plugins/contact-assets/lang/zh.json b/plugins/contact-assets/lang/zh.json index 663081fbcd..8a0f5d6e98 100644 --- a/plugins/contact-assets/lang/zh.json +++ b/plugins/contact-assets/lang/zh.json @@ -149,6 +149,7 @@ "WorkspaceStatusIn1Hour": "1 小时后", "WorkspaceStatusIn4Hours": "4 小时后", "WorkspaceStatusEndOfDay": "今天结束", - "WorkspaceStatusPickDate": "选择日期" + "WorkspaceStatusPickDate": "选择日期", + "HideInactive": "隐藏非活跃" } } diff --git a/plugins/contact-resources/src/index.ts b/plugins/contact-resources/src/index.ts index 315b454710..81cc7b5870 100644 --- a/plugins/contact-resources/src/index.ts +++ b/plugins/contact-resources/src/index.ts @@ -150,6 +150,7 @@ import { getCurrentEmployeePosition, getPersonTooltip, grouppingPersonManager, + hideInactive, permissionsStore, resolveLocation, resolveLocationData @@ -469,7 +470,8 @@ export default async (): Promise => ({ ChannelTitleProvider: channelTitleProvider, ChannelIdentifierProvider: channelIdentifierProvider, CanResendInvitation: canResendInvitation, - CanMergePersons: canMergePersons + CanMergePersons: canMergePersons, + HideInactive: hideInactive }, resolver: { Location: resolveLocation, diff --git a/plugins/contact-resources/src/plugin.ts b/plugins/contact-resources/src/plugin.ts index f2f6bfc5e3..0b9e5c0130 100644 --- a/plugins/contact-resources/src/plugin.ts +++ b/plugins/contact-resources/src/plugin.ts @@ -28,6 +28,7 @@ import { export default mergeIds(contactId, contact, { string: { + HideInactive: '' as IntlString, Apply: '' as IntlString, CreatePerson: '' as IntlString, OrganizationNamePlaceholder: '' as IntlString, diff --git a/plugins/contact-resources/src/utils.ts b/plugins/contact-resources/src/utils.ts index 88eec57a5c..652b487094 100644 --- a/plugins/contact-resources/src/utils.ts +++ b/plugins/contact-resources/src/utils.ts @@ -886,3 +886,7 @@ export function getPersonByPersonRefStore ( ): Readable, Readonly>> { return contactCacheStoreManager.getPersonByPersonRefStore(personRefs) } + +export function hideInactive (value: any, query: DocumentQuery): DocumentQuery { + return value === true ? { ...query, active: true } : query +} diff --git a/plugins/hr-resources/src/components/Schedule.svelte b/plugins/hr-resources/src/components/Schedule.svelte index 1854ab6d6e..da7681fc11 100644 --- a/plugins/hr-resources/src/components/Schedule.svelte +++ b/plugins/hr-resources/src/components/Schedule.svelte @@ -37,7 +37,7 @@ tableToCSV, showPopup } from '@hcengineering/ui' - import view, { Viewlet, ViewletPreference } from '@hcengineering/view' + import view, { Viewlet, ViewletPreference, type ViewOptions } from '@hcengineering/view' import { ViewletSelector, ViewletSettingButton } from '@hcengineering/view-resources' import { getCurrentEmployee } from '@hcengineering/contact' @@ -65,10 +65,13 @@ let search = '' let resultQuery: DocumentQuery = {} - function updateResultQuery (search: string): void { - resultQuery = search === '' ? {} : { name: { $like: '%' + search + '%' } } + function updateResultQuery (search: string, viewOptions: ViewOptions | undefined): void { + const q: DocumentQuery = search === '' ? {} : { name: { $like: '%' + search + '%' } } + resultQuery = viewOptions?.hideInactive !== false ? { ...q, active: true } : q } + $: updateResultQuery(search, viewOptions) + const query = createQuery() let descendants: Map, Department[]> = new Map, Department[]>() @@ -131,6 +134,7 @@ ] let viewlet: Viewlet | undefined + let viewOptions: ViewOptions | undefined let preference: ViewletPreference | undefined let loading = false @@ -220,29 +224,21 @@ if (result.detail !== undefined) display = result.detail.id }} /> - {#if display === 'stats'} -