diff --git a/models/core/src/core.ts b/models/core/src/core.ts index c176e8e993..8507bb7533 100644 --- a/models/core/src/core.ts +++ b/models/core/src/core.ts @@ -54,3 +54,6 @@ export class TType extends TDoc implements Type<any> {} @Model(core.class.TypeString, core.class.Type) export class TTypeString extends TType {} + +@Model(core.class.TypeBoolean, core.class.Type) +export class TTypeBoolean extends TType {} diff --git a/models/core/src/index.ts b/models/core/src/index.ts index ddd28cec58..1d8acfc73d 100644 --- a/models/core/src/index.ts +++ b/models/core/src/index.ts @@ -15,7 +15,7 @@ import { Builder } from '@anticrm/model' import core from './component' -import { TAttribute, TClass, TDoc, TMixin, TObj, TType, TTypeString } from './core' +import { TAttribute, TClass, TDoc, TMixin, TObj, TType, TTypeString, TTypeBoolean } from './core' import { TSpace, TAccount, TState, TSpaceWithStates } from './security' import { TTx, TTxCreateDoc, TTxMixin, TTxUpdateDoc, TTxCUD, TTxPutBag, TTxRemoveDoc } from './tx' @@ -43,6 +43,7 @@ export function createModel (builder: Builder): void { TAttribute, TType, TTypeString, + TTypeBoolean, TState ) } diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index bb301ae135..fdfd2fee03 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -14,7 +14,7 @@ // import type { IntlString } from '@anticrm/platform' -import { Builder, Model, UX, Prop, TypeString, Bag as TypeBag } from '@anticrm/model' +import { Builder, Model, UX, Prop, TypeString, TypeBoolean, Bag as TypeBag } from '@anticrm/model' import type { Ref, FindOptions, Doc, Domain, State, Bag } from '@anticrm/core' import core, { TSpace, TSpaceWithStates, TDoc } from '@anticrm/model-core' import type { Vacancy, Candidates, Candidate, Applicant } from '@anticrm/recruit' @@ -48,6 +48,12 @@ export class TCandidate extends TPerson implements Candidate { @Prop(TypeString(), 'Applications' as IntlString) applications?: number + + @Prop(TypeBoolean(), 'Onsite' as IntlString) + onsite?: boolean + + @Prop(TypeBoolean(), 'Remote' as IntlString) + remote?: boolean } @Model(recruit.class.Applicant, core.class.Doc, DOMAIN_RECRUIT) diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index 08dda38a75..d7e9fae9cb 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -40,6 +40,7 @@ export default plugin(coreId, { Account: '' as Ref<Class<Account>>, State: '' as Ref<Class<State>>, TypeString: '' as Ref<Class<Type<string>>>, + TypeBoolean: '' as Ref<Class<Type<string>>>, Bag: '' as Ref<Class<Type<Record<string, PropertyType>>>> }, space: { diff --git a/packages/model/src/dsl.ts b/packages/model/src/dsl.ts index 06f6316dc9..660df8b875 100644 --- a/packages/model/src/dsl.ts +++ b/packages/model/src/dsl.ts @@ -271,6 +271,13 @@ export function TypeString (): Type<string> { return { _class: core.class.TypeString } } +/** + * @public + */ +export function TypeBoolean (): Type<string> { + return { _class: core.class.TypeBoolean } +} + /** * @public */ diff --git a/plugins/recruit-resources/src/components/CreateCandidate.svelte b/plugins/recruit-resources/src/components/CreateCandidate.svelte index 372412566a..0f1e7f4531 100644 --- a/plugins/recruit-resources/src/components/CreateCandidate.svelte +++ b/plugins/recruit-resources/src/components/CreateCandidate.svelte @@ -67,7 +67,9 @@ import { combineName } from '@anticrm/contact'; title: object.title, city: object.city, channels: object.channels, - attachments: {} + attachments: {}, + onsite: object.onsite, + remote: object.remote } if (resume.uuid !== undefined) { @@ -191,8 +193,8 @@ import { combineName } from '@anticrm/contact'; </div> <div class="flex-col locations"> <span><Label label={'Work location preferences'} /></span> - <div class="row"><Label label={'Onsite'} /><YesNo state={'yes'} /></div> - <div class="row"><Label label={'Remote'} /><YesNo state={'unknown'} /></div> + <div class="row"><Label label={'Onsite'} /><YesNo bind:value={object.onsite} /></div> + <div class="row"><Label label={'Remote'} /><YesNo bind:value={object.remote} /></div> </div> <svelte:fragment slot="contacts"> <Channels value={object.channels} /> diff --git a/plugins/recruit-resources/src/components/YesNo.svelte b/plugins/recruit-resources/src/components/YesNo.svelte index 34d3b88ed9..49a168836c 100644 --- a/plugins/recruit-resources/src/components/YesNo.svelte +++ b/plugins/recruit-resources/src/components/YesNo.svelte @@ -16,25 +16,31 @@ <script lang="ts"> import { Label } from '@anticrm/ui' - export let state: 'yes' | 'no' | 'unknown' + export let value: boolean | undefined + + function getLabel(value: boolean | undefined) { + if (value === true) return 'Yes' + if (value === false) return 'No' + return 'Unknown' + } </script> -<div class="flex-row-center yesno-container {state}" on:click={() => { - if (state === 'yes') state = 'no' - else if (state === 'no') state = 'unknown' - else state = 'yes' +<div class="flex-row-center yesno-container" class:yes={value === true} class:no={value === false} class:unknown={value === undefined} on:click={() => { + if (value === true) value = false + else if (value === false) value = undefined + else value = true }}> <svg class="svg-small" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"> <circle fill="#fff" cx="8" cy="8" r="6"/> - {#if state === 'yes'} + {#if value === true} <polygon fill="var(--primary-button-enabled)" points="7.4,10.9 4.9,8.4 5.7,7.6 7.3,9.1 10.2,5.6 11.1,6.4 "/> - {:else if state === 'no'} + {:else if value === false} <polygon fill="#F06C63" points="10.7,6 10,5.3 8,7.3 6,5.3 5.3,6 7.3,8 5.3,10 6,10.7 8,8.7 10,10.7 10.7,10 8.7,8 "/> {:else} <path fill="#77818E" d="M7.3,9.3h1.3V9c0.1-0.5,0.6-0.9,1.1-1.4c0.4-0.4,0.8-0.9,0.8-1.6c0-1.1-0.8-1.8-2.2-1.8c-1.4,0-2.4,0.8-2.5,2.2 h1.4c0.1-0.6,0.4-1,1-1C8.8,5.4,9,5.7,9,6.2c0,0.4-0.3,0.7-0.7,1.1c-0.5,0.5-1,0.9-1,1.7V9.3z M8,11.6c0.5,0,0.9-0.4,0.9-0.9 c0-0.5-0.4-0.9-0.9-0.9c-0.5,0-0.9,0.4-0.9,0.9C7.1,11.2,7.5,11.6,8,11.6z"/> {/if} </svg> - <span><Label label={state} /></span> + <span><Label label={getLabel(value)} /></span> </div> <style lang="scss"> diff --git a/plugins/recruit/src/index.ts b/plugins/recruit/src/index.ts index 36992aa5d0..5301f1c228 100644 --- a/plugins/recruit/src/index.ts +++ b/plugins/recruit/src/index.ts @@ -36,6 +36,8 @@ export interface Candidate extends Person { title?: string attachments: Bag<Attachment> applications?: number + onsite?: boolean + remote?: boolean } /**