diff --git a/plugins/recruit-resources/src/components/Vacancies.svelte b/plugins/recruit-resources/src/components/Vacancies.svelte index dba95f6964..65a322e79d 100644 --- a/plugins/recruit-resources/src/components/Vacancies.svelte +++ b/plugins/recruit-resources/src/components/Vacancies.svelte @@ -13,7 +13,7 @@ // limitations under the License. -->
@@ -118,12 +123,21 @@ key: '', presenter: recruit.component.VacancyCountPresenter, label: recruit.string.Applications, - props: { applications, resultQuery } + props: { applications, resultQuery }, + sortingKey: '@applications', + sortingFunction: applicationSorting }, 'company', 'location', 'description', - 'modifiedOn' + { + key: '', + presenter: recruit.component.VacancyModifiedPresenter, + label: core.string.Modified, + props: { applications }, + sortingKey: 'modifiedOn', + sortingFunction: modifiedSorting + } ]} options={{}} query={{ diff --git a/plugins/recruit-resources/src/components/VacancyCountPresenter.svelte b/plugins/recruit-resources/src/components/VacancyCountPresenter.svelte index 5bf977252f..c50d250586 100644 --- a/plugins/recruit-resources/src/components/VacancyCountPresenter.svelte +++ b/plugins/recruit-resources/src/components/VacancyCountPresenter.svelte @@ -21,14 +21,14 @@ import recruit from '../plugin' import VacancyApplicationsPopup from './VacancyApplicationsPopup.svelte' export let value: Vacancy -export let applications: Map, number> | undefined +export let applications: Map, {count: number, modifiedOn: number}> | undefined export let resultQuery: DocumentQuery -{#if (applications?.get(value._id) ?? 0) > 0} +{#if (applications?.get(value._id)?.count ?? 0) > 0}
-  {(applications?.get(value._id) ?? 0)} +  {(applications?.get(value._id)?.count ?? 0)}
{/if} \ No newline at end of file diff --git a/plugins/recruit-resources/src/components/VacancyModifiedPresenter.svelte b/plugins/recruit-resources/src/components/VacancyModifiedPresenter.svelte new file mode 100644 index 0000000000..19d0adee34 --- /dev/null +++ b/plugins/recruit-resources/src/components/VacancyModifiedPresenter.svelte @@ -0,0 +1,25 @@ + + + + + diff --git a/plugins/recruit-resources/src/index.ts b/plugins/recruit-resources/src/index.ts index b3563ee3f9..57b5828eee 100644 --- a/plugins/recruit-resources/src/index.ts +++ b/plugins/recruit-resources/src/index.ts @@ -47,6 +47,7 @@ import Vacancies from './components/Vacancies.svelte' import VacancyItemPresenter from './components/VacancyItemPresenter.svelte' import VacancyPresenter from './components/VacancyPresenter.svelte' import VacancyCountPresenter from './components/VacancyCountPresenter.svelte' +import VacancyModifiedPresenter from './components/VacancyModifiedPresenter.svelte' import recruit from './plugin' import PersonsPresenter from './components/review/PersonsPresenter.svelte' @@ -155,6 +156,7 @@ export default async (): Promise => ({ Vacancies, VacancyItemPresenter, VacancyCountPresenter, + VacancyModifiedPresenter, CreateReviewCategory, EditReviewCategory, diff --git a/plugins/recruit-resources/src/plugin.ts b/plugins/recruit-resources/src/plugin.ts index db73aba0ab..d0765b3b04 100644 --- a/plugins/recruit-resources/src/plugin.ts +++ b/plugins/recruit-resources/src/plugin.ts @@ -116,6 +116,7 @@ export default mergeIds(recruitId, recruit, { VacancyItemPresenter: '' as AnyComponent, VacancyCountPresenter: '' as AnyComponent, OpinionsPresenter: '' as AnyComponent, - PersonsPresenter: '' as AnyComponent + PersonsPresenter: '' as AnyComponent, + VacancyModifiedPresenter: '' as AnyComponent } }) diff --git a/plugins/view-resources/src/components/Table.svelte b/plugins/view-resources/src/components/Table.svelte index 82d7ab7c36..a27ad69e76 100644 --- a/plugins/view-resources/src/components/Table.svelte +++ b/plugins/view-resources/src/components/Table.svelte @@ -45,6 +45,8 @@ const q = createQuery() + $: sortingFunction = (config.find(it => (typeof it !== 'string') && it.sortingKey === sortKey) as BuildModelKey)?.sortingFunction + async function update ( _class: Ref>, query: DocumentQuery, @@ -58,6 +60,10 @@ query, (result) => { objects = result + if (sortingFunction !== undefined) { + const sf = sortingFunction + objects.sort((a, b) => -1 * sortOrder * sf(a, b)) + } loading = false }, { sort: { [sortKey]: sortOrder }, ...options, limit: 200 } diff --git a/plugins/view/src/index.ts b/plugins/view/src/index.ts index 700b132a61..d48a059c1b 100644 --- a/plugins/view/src/index.ts +++ b/plugins/view/src/index.ts @@ -124,6 +124,9 @@ export interface BuildModelKey { label?: IntlString sortingKey?: string + + // On client sorting function + sortingFunction?: (a: Doc, b: Doc) => number } /**