mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 07:10:02 +00:00
TSK-1242 Short link for organization in recruit (#3008)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
5f0566bb9f
commit
d5f1668532
@ -97,7 +97,7 @@ export class TVacancy extends TSpaceWithStates implements Vacancy {
|
|||||||
export class TCandidates extends TSpace implements Candidates {}
|
export class TCandidates extends TSpace implements Candidates {}
|
||||||
|
|
||||||
@Mixin(recruit.mixin.Candidate, contact.class.Person)
|
@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 {
|
export class TCandidate extends TPerson implements Candidate {
|
||||||
@Prop(TypeString(), recruit.string.Title)
|
@Prop(TypeString(), recruit.string.Title)
|
||||||
@Index(IndexKind.FullText)
|
@Index(IndexKind.FullText)
|
||||||
@ -135,7 +135,7 @@ export class TCandidate extends TPerson implements Candidate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Mixin(recruit.mixin.VacancyList, contact.class.Organization)
|
@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 {
|
export class TVacancyList extends TOrganization implements VacancyList {
|
||||||
@Prop(Collection(recruit.class.Vacancy), recruit.string.Vacancies)
|
@Prop(Collection(recruit.class.Vacancy), recruit.string.Vacancies)
|
||||||
vacancies!: number
|
vacancies!: number
|
||||||
@ -748,7 +748,11 @@ export function createModel (builder: Builder): void {
|
|||||||
})
|
})
|
||||||
|
|
||||||
builder.mixin(recruit.mixin.Candidate, core.class.Class, view.mixin.LinkProvider, {
|
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(
|
builder.createDoc(
|
||||||
|
@ -40,7 +40,7 @@ export default mergeIds(recruitId, recruit, {
|
|||||||
},
|
},
|
||||||
function: {
|
function: {
|
||||||
GetObjectLinkFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
GetObjectLinkFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
||||||
GetCandidateLinkFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
GetIdObjectLinkFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
||||||
GetObjectLink: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<string>>
|
GetObjectLink: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<string>>
|
||||||
},
|
},
|
||||||
string: {
|
string: {
|
||||||
|
@ -65,7 +65,7 @@ import VacancyTemplateEditor from './components/VacancyTemplateEditor.svelte'
|
|||||||
import recruit from './plugin'
|
import recruit from './plugin'
|
||||||
import {
|
import {
|
||||||
getAppTitle,
|
getAppTitle,
|
||||||
getCandidateLink,
|
getObjectLink,
|
||||||
getRevTitle,
|
getRevTitle,
|
||||||
getSequenceId,
|
getSequenceId,
|
||||||
getSequenceLink,
|
getSequenceLink,
|
||||||
@ -338,7 +338,7 @@ export default async (): Promise<Resources> => ({
|
|||||||
NoneApplications: noneApplicant,
|
NoneApplications: noneApplicant,
|
||||||
GetObjectLink: objectLinkProvider,
|
GetObjectLink: objectLinkProvider,
|
||||||
GetObjectLinkFragment: getSequenceLink,
|
GetObjectLinkFragment: getSequenceLink,
|
||||||
GetCandidateLinkFragment: getCandidateLink
|
GetIdObjectLinkFragment: getObjectLink
|
||||||
},
|
},
|
||||||
resolver: {
|
resolver: {
|
||||||
Location: resolveLocation
|
Location: resolveLocation
|
||||||
|
@ -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 { 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 { getCurrentLocation, getPanelURI, Location, ResolvedLocation } from '@hcengineering/ui'
|
||||||
import view from '@hcengineering/view'
|
import view from '@hcengineering/view'
|
||||||
import { workbenchId } from '@hcengineering/workbench'
|
import { workbenchId } from '@hcengineering/workbench'
|
||||||
@ -31,18 +31,36 @@ export async function resolveLocation (loc: Location): Promise<ResolvedLocation
|
|||||||
// shortlink
|
// shortlink
|
||||||
if (isShortId(shortLink)) {
|
if (isShortId(shortLink)) {
|
||||||
return await generateLocation(loc, shortLink)
|
return await generateLocation(loc, shortLink)
|
||||||
} else {
|
} else if (shortLink !== undefined) {
|
||||||
return await generateCandidateLink(loc, shortLink)
|
return await generateIdLocation(loc, shortLink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateCandidateLink (loc: Location, _id: string): Promise<ResolvedLocation | undefined> {
|
async function generateIdLocation (loc: Location, shortLink: string): Promise<ResolvedLocation | undefined> {
|
||||||
|
const tokens = shortLink.split('-')
|
||||||
|
if (tokens.length < 2) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const hierarchy = client.getHierarchy()
|
const hierarchy = client.getHierarchy()
|
||||||
|
|
||||||
const doc = await client.findOne(recruit.mixin.Candidate, { _id: _id as Ref<Candidate> })
|
const classLabel = tokens[0]
|
||||||
|
const _id = tokens[1]
|
||||||
|
const classes = [recruit.mixin.VacancyList, recruit.mixin.Candidate]
|
||||||
|
let _class: Ref<Class<Doc>> | 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<Doc> })
|
||||||
if (doc === undefined) {
|
if (doc === undefined) {
|
||||||
console.error(`Could not find candidate with id ${_id}.`)
|
console.error(`Could not find ${_class} with id ${_id}.`)
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
const appComponent = loc.path[0] ?? ''
|
const appComponent = loc.path[0] ?? ''
|
||||||
@ -50,17 +68,18 @@ async function generateCandidateLink (loc: Location, _id: string): Promise<Resol
|
|||||||
const targetClass = hierarchy.getClass(recruit.mixin.Candidate)
|
const targetClass = hierarchy.getClass(recruit.mixin.Candidate)
|
||||||
const panelComponent = hierarchy.as(targetClass, view.mixin.ObjectPanel)
|
const panelComponent = hierarchy.as(targetClass, view.mixin.ObjectPanel)
|
||||||
const component = panelComponent.component ?? view.component.EditDoc
|
const component = panelComponent.component ?? view.component.EditDoc
|
||||||
const defaultPath = [appComponent, workspace, recruitId, 'talents']
|
const special = _class === recruit.mixin.Candidate ? 'talents' : 'organizations'
|
||||||
|
const defaultPath = [appComponent, workspace, recruitId, special]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loc: {
|
loc: {
|
||||||
path: [appComponent, workspace],
|
path: [appComponent, workspace],
|
||||||
fragment: getPanelURI(component, doc._id, recruit.mixin.Candidate, 'content')
|
fragment: getPanelURI(component, doc._id, _class, 'content')
|
||||||
},
|
},
|
||||||
shouldNavigate: false,
|
shouldNavigate: false,
|
||||||
defaultLocation: {
|
defaultLocation: {
|
||||||
path: defaultPath,
|
path: defaultPath,
|
||||||
fragment: getPanelURI(component, doc._id, recruit.mixin.Candidate, 'content')
|
fragment: getPanelURI(component, doc._id, _class, 'content')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,13 +145,16 @@ export async function getSequenceLink (doc: RecruitDocument): Promise<Location>
|
|||||||
return loc
|
return loc
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCandidateLink (doc: Candidate): Promise<Location> {
|
export async function getObjectLink (doc: Candidate | VacancyList): Promise<Location> {
|
||||||
|
const _class = Hierarchy.mixinOrClass(doc)
|
||||||
|
const client = getClient()
|
||||||
|
const clazz = client.getHierarchy().getClass(_class)
|
||||||
const loc = getCurrentLocation()
|
const loc = getCurrentLocation()
|
||||||
loc.path.length = 2
|
loc.path.length = 2
|
||||||
loc.fragment = undefined
|
loc.fragment = undefined
|
||||||
loc.query = undefined
|
loc.query = undefined
|
||||||
loc.path[2] = recruitId
|
loc.path[2] = recruitId
|
||||||
loc.path[3] = doc._id
|
loc.path[3] = clazz.shortLabel !== undefined ? `${clazz.shortLabel}-${doc._id}` : doc._id
|
||||||
|
|
||||||
return loc
|
return loc
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,10 @@
|
|||||||
loc.path[2] = (currentAppAlias as string) ?? resolved.defaultLocation.path[2]
|
loc.path[2] = (currentAppAlias as string) ?? resolved.defaultLocation.path[2]
|
||||||
loc.path[3] = currentSpace ?? (currentSpecial as string) ?? resolved.defaultLocation.path[3]
|
loc.path[3] = currentSpace ?? (currentSpecial as string) ?? resolved.defaultLocation.path[3]
|
||||||
if (loc.path[3] !== undefined) {
|
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 {
|
} else {
|
||||||
loc.path.length = 4
|
loc.path.length = 4
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user