diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 579879b21a..8dd9898e99 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -97,7 +97,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.Talent, recruit.icon.RecruitApplication, undefined, 'name') +@UX(recruit.string.Talent, recruit.icon.RecruitApplication, 'TLNT', 'name') export class TCandidate extends TPerson implements Candidate { @Prop(TypeString(), recruit.string.Title) @Index(IndexKind.FullText) @@ -135,7 +135,7 @@ export class TCandidate extends TPerson implements Candidate { } @Mixin(recruit.mixin.VacancyList, contact.class.Organization) -@UX(recruit.string.VacancyList, recruit.icon.RecruitApplication, undefined, 'name') +@UX(recruit.string.VacancyList, recruit.icon.RecruitApplication, 'CM', 'name') export class TVacancyList extends TOrganization implements VacancyList { @Prop(Collection(recruit.class.Vacancy), recruit.string.Vacancies) vacancies!: number @@ -748,7 +748,11 @@ export function createModel (builder: Builder): void { }) builder.mixin(recruit.mixin.Candidate, core.class.Class, view.mixin.LinkProvider, { - encode: recruit.function.GetCandidateLinkFragment + encode: recruit.function.GetIdObjectLinkFragment + }) + + builder.mixin(recruit.mixin.VacancyList, core.class.Class, view.mixin.LinkProvider, { + encode: recruit.function.GetIdObjectLinkFragment }) builder.createDoc( diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts index ee7ded9172..cf9435fb96 100644 --- a/models/recruit/src/plugin.ts +++ b/models/recruit/src/plugin.ts @@ -40,7 +40,7 @@ export default mergeIds(recruitId, recruit, { }, function: { GetObjectLinkFragment: '' as Resource<(doc: Doc, props: Record) => Promise>, - GetCandidateLinkFragment: '' as Resource<(doc: Doc, props: Record) => Promise>, + GetIdObjectLinkFragment: '' as Resource<(doc: Doc, props: Record) => Promise>, GetObjectLink: '' as Resource<(doc: Doc, props: Record) => Promise> }, string: { diff --git a/plugins/recruit-resources/src/index.ts b/plugins/recruit-resources/src/index.ts index cba699f3eb..60018e12c6 100644 --- a/plugins/recruit-resources/src/index.ts +++ b/plugins/recruit-resources/src/index.ts @@ -65,7 +65,7 @@ import VacancyTemplateEditor from './components/VacancyTemplateEditor.svelte' import recruit from './plugin' import { getAppTitle, - getCandidateLink, + getObjectLink, getRevTitle, getSequenceId, getSequenceLink, @@ -338,7 +338,7 @@ export default async (): Promise => ({ NoneApplications: noneApplicant, GetObjectLink: objectLinkProvider, GetObjectLinkFragment: getSequenceLink, - GetCandidateLinkFragment: getCandidateLink + GetIdObjectLinkFragment: getObjectLink }, resolver: { Location: resolveLocation diff --git a/plugins/recruit-resources/src/utils.ts b/plugins/recruit-resources/src/utils.ts index 20dd585d8a..c84572eb0f 100644 --- a/plugins/recruit-resources/src/utils.ts +++ b/plugins/recruit-resources/src/utils.ts @@ -1,6 +1,6 @@ -import { Class, Client, Doc, Ref } from '@hcengineering/core' +import { Class, Client, Doc, Hierarchy, Ref } from '@hcengineering/core' import { getClient } from '@hcengineering/presentation' -import { Applicant, Candidate, recruitId, Review, Vacancy } from '@hcengineering/recruit' +import { Applicant, Candidate, recruitId, Review, Vacancy, VacancyList } from '@hcengineering/recruit' import { getCurrentLocation, getPanelURI, Location, ResolvedLocation } from '@hcengineering/ui' import view from '@hcengineering/view' import { workbenchId } from '@hcengineering/workbench' @@ -31,18 +31,36 @@ export async function resolveLocation (loc: Location): Promise { +async function generateIdLocation (loc: Location, shortLink: string): Promise { + const tokens = shortLink.split('-') + if (tokens.length < 2) { + return undefined + } const client = getClient() const hierarchy = client.getHierarchy() - const doc = await client.findOne(recruit.mixin.Candidate, { _id: _id as Ref }) + const classLabel = tokens[0] + const _id = tokens[1] + const classes = [recruit.mixin.VacancyList, recruit.mixin.Candidate] + let _class: Ref> | undefined + for (const clazz of classes) { + if (hierarchy.getClass(clazz).shortLabel === classLabel) { + _class = clazz + break + } + } + if (_class === undefined) { + console.error(`Not found class with short label ${classLabel}`) + return undefined + } + const doc = await client.findOne(_class, { _id: _id as Ref }) if (doc === undefined) { - console.error(`Could not find candidate with id ${_id}.`) + console.error(`Could not find ${_class} with id ${_id}.`) return undefined } const appComponent = loc.path[0] ?? '' @@ -50,17 +68,18 @@ async function generateCandidateLink (loc: Location, _id: string): Promise return loc } -export async function getCandidateLink (doc: Candidate): Promise { +export async function getObjectLink (doc: Candidate | VacancyList): Promise { + const _class = Hierarchy.mixinOrClass(doc) + const client = getClient() + const clazz = client.getHierarchy().getClass(_class) const loc = getCurrentLocation() loc.path.length = 2 loc.fragment = undefined loc.query = undefined loc.path[2] = recruitId - loc.path[3] = doc._id + loc.path[3] = clazz.shortLabel !== undefined ? `${clazz.shortLabel}-${doc._id}` : doc._id return loc } diff --git a/plugins/workbench-resources/src/components/Workbench.svelte b/plugins/workbench-resources/src/components/Workbench.svelte index 45ab6e24c5..604e77e506 100644 --- a/plugins/workbench-resources/src/components/Workbench.svelte +++ b/plugins/workbench-resources/src/components/Workbench.svelte @@ -232,7 +232,10 @@ loc.path[2] = (currentAppAlias as string) ?? resolved.defaultLocation.path[2] loc.path[3] = currentSpace ?? (currentSpecial as string) ?? resolved.defaultLocation.path[3] if (loc.path[3] !== undefined) { - loc.path[4] = currentSpecial ?? (asideId as string) ?? resolved.defaultLocation.path[4] + loc.path[4] = + (currentSpace !== undefined ? currentSpecial : undefined) ?? + (asideId as string) ?? + resolved.defaultLocation.path[4] } else { loc.path.length = 4 }