From 06867083d18088eebcf7ba3737986da4e25cf600 Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Fri, 20 May 2022 13:17:57 +0600 Subject: [PATCH] Filters fix (#1808) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- models/contact/src/index.ts | 2 +- models/recruit/src/index.ts | 4 +- models/view/src/index.ts | 4 + packages/core/src/predicate.ts | 6 +- .../src/components/CreateApplication.svelte | 144 ++++++++++-------- .../src/components/filter/ObjectFilter.svelte | 77 ++++++---- .../src/components/filter/ValueFilter.svelte | 51 +++++-- 7 files changed, 174 insertions(+), 114 deletions(-) diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 575a80ad03..86587b96a8 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -103,7 +103,7 @@ export class TStatus extends TAttachedDoc implements Status { } @Model(contact.class.Employee, contact.class.Person) -@UX(contact.string.Employee, contact.icon.Person) +@UX(contact.string.Employee, contact.icon.Person, undefined, 'name') export class TEmployee extends TPerson implements Employee { @Prop(Collection(contact.class.Status), contact.string.Status) statuses?: number diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 5c08932b67..ad79749ae3 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -75,7 +75,7 @@ export class TVacancy extends TSpaceWithStates implements Vacancy { export class TCandidates extends TSpace implements Candidates {} @Mixin(recruit.mixin.Candidate, contact.class.Person) -@UX(recruit.string.Candidate, recruit.icon.RecruitApplication) +@UX(recruit.string.Candidate, recruit.icon.RecruitApplication, undefined, 'name') export class TCandidate extends TPerson implements Candidate { @Prop(TypeString(), recruit.string.Title) @Index(IndexKind.FullText) @@ -452,7 +452,7 @@ export function createModel (builder: Builder): void { }) builder.mixin(recruit.mixin.Candidate, core.class.Class, view.mixin.ClassFilters, { - filters: ['title', 'source', 'city', 'modifiedOn'] + filters: ['title', 'source', 'city', 'modifiedOn', 'onsite', 'remote'] }) builder.mixin(recruit.class.Applicant, core.class.Class, view.mixin.ClassFilters, { diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 11f8731137..1aeb303b2f 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -501,6 +501,10 @@ export function createModel (builder: Builder): void { component: view.component.ValueFilter }) + builder.mixin(core.class.TypeBoolean, core.class.Class, view.mixin.AttributeFilter, { + component: view.component.ValueFilter + }) + builder.mixin(core.class.TypeNumber, core.class.Class, view.mixin.AttributeFilter, { component: view.component.ValueFilter }) diff --git a/packages/core/src/predicate.ts b/packages/core/src/predicate.ts index aa360664c1..b1d5812d51 100644 --- a/packages/core/src/predicate.ts +++ b/packages/core/src/predicate.ts @@ -39,13 +39,15 @@ const predicates: Record = { if (!Array.isArray(o)) { throw new Error('$in predicate requires array') } - return (docs) => execPredicate(docs, propertyKey, (value) => o.includes(value)) + // eslint-disable-next-line eqeqeq + return (docs) => execPredicate(docs, propertyKey, (value) => o.some((p) => p == value)) }, $nin: (o, propertyKey) => { if (!Array.isArray(o)) { throw new Error('$nin predicate requires array') } - return (docs) => execPredicate(docs, propertyKey, (value) => !o.includes(value)) + // eslint-disable-next-line eqeqeq + return (docs) => execPredicate(docs, propertyKey, (value) => !o.some((p) => p == value)) }, $like: (query: string, propertyKey: string): Predicate => { diff --git a/plugins/recruit-resources/src/components/CreateApplication.svelte b/plugins/recruit-resources/src/components/CreateApplication.svelte index 77d50fbf05..2d2f3d170d 100644 --- a/plugins/recruit-resources/src/components/CreateApplication.svelte +++ b/plugins/recruit-resources/src/components/CreateApplication.svelte @@ -18,7 +18,7 @@ import { Account, Class, Client, Doc, generateId, Ref, SortingOrder } from '@anticrm/core' import { getResource, OK, Resource, Severity, Status } from '@anticrm/platform' import { Card, createQuery, getClient, SpaceSelector, UserBox } from '@anticrm/presentation' - import type { Applicant, Candidate, Vacancy } from '@anticrm/recruit' + import type { Applicant, Candidate } from '@anticrm/recruit' import task, { calcRank, SpaceWithStates, State } from '@anticrm/task' import ui, { Button, @@ -41,8 +41,9 @@ export let preserveCandidate = false let status: Status = OK + let createMore: boolean = false - const doc: Applicant = { + let doc: Applicant = { state: '' as Ref, doneState: null, number: 0, @@ -111,6 +112,25 @@ rank: calcRank(lastOne, undefined) } ) + + if (createMore) { + // Prepare for next + doc = { + state: selectedState._id, + doneState: null, + number: 0, + assignee: assignee, + rank: '', + attachedTo: candidate, + attachedToClass: recruit.mixin.Candidate, + _class: recruit.class.Applicant, + space: space, + _id: generateId(), + collection: 'applications', + modifiedOn: Date.now(), + modifiedBy: '' as Ref + } + } } async function invokeValidate ( @@ -134,20 +154,6 @@ $: validate(doc, doc._class) - let selectedVacancy: Vacancy - let selectedCandidate: Person - const vacancyQuery = createQuery() - $: if (doc.space !== undefined) { - vacancyQuery.query(recruit.class.Vacancy, { _id: doc.space }, (result) => { - selectedVacancy = result[0] - }) - } - const candidateQuery = createQuery() - $: if (doc.attachedTo !== undefined) { - candidateQuery.query(contact.class.Person, { _id: doc.attachedTo as Ref }, (result) => { - selectedCandidate = result[0] - }) - } let states: Array<{ id: number | string; color: number; label: string }> = [] let selectedState: State const statesQuery = createQuery() @@ -164,6 +170,8 @@ }, { sort: { rank: SortingOrder.Ascending } } ) + } else { + states = [] } const manager = createFocusManager() @@ -192,7 +200,7 @@ label={recruit.string.CreateApplication} okAction={createApplication} canSave={status.severity === Severity.OK} - createMore={false} + bind:createMore on:close={() => { dispatch('close') }} @@ -211,61 +219,63 @@ - {#if !preserveCandidate} + {#key doc} + {#if !preserveCandidate} + + {/if} - {/if} - - {#if states && doc.space} - - {/if} + ) + }} + > +
+ {#if selectedState} +
+ {selectedState.title} + {/if} +
+ + {/if} + {/key} diff --git a/plugins/view-resources/src/components/filter/ObjectFilter.svelte b/plugins/view-resources/src/components/filter/ObjectFilter.svelte index 649c78f526..faa153cea7 100644 --- a/plugins/view-resources/src/components/filter/ObjectFilter.svelte +++ b/plugins/view-resources/src/components/filter/ObjectFilter.svelte @@ -13,10 +13,10 @@ // limitations under the License. -->