mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-23 18:15:03 +02:00
TSK-833 Доработка Таблицы Vacations TSK-817 Click on Employee is broken, it should open Edit Contact TSK-805 Открывать задачу в новой вкладке при клике колесиком TSK-794 Прикрепление ссылки на вакансию/аппликейшн в чате (#2734)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import core, {
|
||||
Collection,
|
||||
concatLink,
|
||||
Doc,
|
||||
matchQuery,
|
||||
Obj,
|
||||
Ref,
|
||||
RefTo,
|
||||
@@ -33,7 +34,6 @@ import core, {
|
||||
import login from '@hcengineering/login'
|
||||
import { getMetadata } from '@hcengineering/platform'
|
||||
import type { TriggerControl } from '@hcengineering/server-core'
|
||||
import view from '@hcengineering/view'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
|
||||
/**
|
||||
@@ -271,13 +271,36 @@ export async function OnEmployeeUpdate (tx: Tx, control: TriggerControl): Promis
|
||||
return result
|
||||
}
|
||||
|
||||
async function getContactLink (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const hierarchy = control.hierarchy
|
||||
let clazz = hierarchy.getClass(doc._class)
|
||||
let label = clazz.shortLabel
|
||||
while (label === undefined && clazz.extends !== undefined) {
|
||||
clazz = hierarchy.getClass(clazz.extends)
|
||||
label = clazz.shortLabel
|
||||
}
|
||||
label = label ?? 'CONT'
|
||||
let length = 5
|
||||
let id = doc._id.slice(-length)
|
||||
const contacts = await control.findAll(clazz._id, {}, { projection: { _id: 1 } })
|
||||
let res = matchQuery(contacts, { _id: { $like: `@${id}` } }, clazz._id, hierarchy)
|
||||
while (res.length > 1) {
|
||||
length++
|
||||
id = doc._id.slice(-length)
|
||||
res = matchQuery(contacts, { _id: { $like: `@${id}` } }, clazz._id, hierarchy)
|
||||
}
|
||||
|
||||
return `${contactId}|${label}-${id}`
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function personHTMLPresenter (doc: Doc, control: TriggerControl): string {
|
||||
export async function personHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const person = doc as Person
|
||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||
const path = `${workbenchId}/${control.workspace.name}/${contactId}#${view.component.EditDoc}|${person._id}|${person._class}|content`
|
||||
const fragment = await getContactLink(doc, control)
|
||||
const path = `${workbenchId}/${control.workspace.name}/${contactId}#${fragment}`
|
||||
const link = concatLink(front, path)
|
||||
return `<a href="${link}">${getName(person)}</a>`
|
||||
}
|
||||
@@ -293,10 +316,11 @@ export function personTextPresenter (doc: Doc): string {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function organizationHTMLPresenter (doc: Doc, control: TriggerControl): string {
|
||||
export async function organizationHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const organization = doc as Organization
|
||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||
const path = `${workbenchId}/${control.workspace.name}/${contactId}#${view.component.EditDoc}|${organization._id}|${organization._class}|content`
|
||||
const fragment = await getContactLink(doc, control)
|
||||
const path = `${workbenchId}/${control.workspace.name}/${contactId}#${fragment}`
|
||||
const link = concatLink(front, path)
|
||||
return `<a href="${link}">${organization.name}</a>`
|
||||
}
|
||||
|
||||
@@ -31,16 +31,30 @@ import { getMetadata } from '@hcengineering/platform'
|
||||
import recruit, { Applicant, recruitId, Vacancy } from '@hcengineering/recruit'
|
||||
import { TriggerControl } from '@hcengineering/server-core'
|
||||
import { addAssigneeNotification } from '@hcengineering/server-task-resources'
|
||||
import view from '@hcengineering/view'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
|
||||
function getSequenceId (doc: Vacancy | Applicant, control: TriggerControl): string {
|
||||
const hierarchy = control.hierarchy
|
||||
let clazz = hierarchy.getClass(doc._class)
|
||||
let label = clazz.shortLabel
|
||||
while (label === undefined && clazz.extends !== undefined) {
|
||||
clazz = hierarchy.getClass(clazz.extends)
|
||||
label = clazz.shortLabel
|
||||
}
|
||||
|
||||
return label !== undefined ? `${label}-${doc.number}` : doc.number.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function vacancyHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const vacancy = doc as Vacancy
|
||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||
const path = `${workbenchId}/${control.workspace.name}/${recruitId}/${vacancy._id}/#${recruit.component.EditVacancy}|${vacancy._id}|${vacancy._class}|content`
|
||||
const path = `${workbenchId}/${control.workspace.name}/${recruitId}/${vacancy._id}/#${recruitId}|${getSequenceId(
|
||||
vacancy,
|
||||
control
|
||||
)}`
|
||||
const link = concatLink(front, path)
|
||||
return `<a href="${link}">${vacancy.name}</a>`
|
||||
}
|
||||
@@ -59,17 +73,19 @@ export async function vacancyTextPresenter (doc: Doc): Promise<string> {
|
||||
export async function applicationHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const applicant = doc as Applicant
|
||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||
const path = `${workbenchId}/${control.workspace.name}/${recruitId}/${applicant.space}/#${view.component.EditDoc}|${applicant._id}|${applicant._class}|content`
|
||||
const id = getSequenceId(applicant, control)
|
||||
const path = `${workbenchId}/${control.workspace.name}/${recruitId}/${applicant.space}/#${recruitId}|${id}`
|
||||
const link = concatLink(front, path)
|
||||
return `<a href="${link}">APP-${applicant.number}</a>`
|
||||
return `<a href="${link}">id</a>`
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function applicationTextPresenter (doc: Doc): Promise<string> {
|
||||
export async function applicationTextPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const applicant = doc as Applicant
|
||||
return `APP-${applicant.number}`
|
||||
const id = getSequenceId(applicant, control)
|
||||
return id
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,12 +31,12 @@ import core, {
|
||||
WithLookup
|
||||
} from '@hcengineering/core'
|
||||
import login from '@hcengineering/login'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
import { getMetadata } from '@hcengineering/platform'
|
||||
import { Resource } from '@hcengineering/platform/lib/platform'
|
||||
import { TriggerControl } from '@hcengineering/server-core'
|
||||
import { addAssigneeNotification } from '@hcengineering/server-task-resources'
|
||||
import tracker, { Issue, IssueParentInfo, Project, Team, TimeSpendReport, trackerId } from '@hcengineering/tracker'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
|
||||
async function updateSubIssues (
|
||||
updateTx: TxUpdateDoc<Issue>,
|
||||
@@ -55,12 +55,9 @@ async function updateSubIssues (
|
||||
* @public
|
||||
*/
|
||||
export async function issueHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const issue = doc as Issue
|
||||
const team = (await control.findAll(tracker.class.Team, { _id: issue.space })).shift()
|
||||
const issueName = `${team?.identifier ?? '?'}-${issue.number}`
|
||||
|
||||
const issueName = await issueTextPresenter(doc, control)
|
||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||
const path = `${workbenchId}/${control.workspace.name}/${trackerId}/${issue.space}/#${tracker.component.EditIssue}|${issue._id}|${issue._class}|content`
|
||||
const path = `${workbenchId}/${control.workspace.name}/${trackerId}/${doc.space}/issues/#${trackerId}|${issueName}`
|
||||
const link = concatLink(front, path)
|
||||
return `<a href="${link}">${issueName}</a>`
|
||||
}
|
||||
@@ -70,7 +67,7 @@ export async function issueHTMLPresenter (doc: Doc, control: TriggerControl): Pr
|
||||
*/
|
||||
export async function issueTextPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||
const issue = doc as Issue
|
||||
const team = (await control.findAll(tracker.class.Team, { _id: issue.space })).shift()
|
||||
const team = (await control.findAll(tracker.class.Team, { _id: issue.space }))[0]
|
||||
const issueName = `${team?.identifier ?? '?'}-${issue.number}`
|
||||
|
||||
return issueName
|
||||
|
||||
Reference in New Issue
Block a user