diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 7debd9e597..005b740f45 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -647,6 +647,70 @@ export function createModel (builder: Builder): void { group: 'edit' } }) + // TODO: fix icons + createAction( + builder, + { + action: recruit.actionImpl.CopyToClipboard, + actionProps: { + type: 'id' + }, + label: recruit.string.CopyId, + icon: recruit.icon.Application, + keyBinding: [], + input: 'none', + category: recruit.category.Recruit, + target: recruit.class.Applicant, + context: { + mode: ['context', 'browser'], + application: recruit.app.Recruit, + group: 'copy' + } + }, + recruit.action.CopyApplicationId + ) + createAction( + builder, + { + action: recruit.actionImpl.CopyToClipboard, + actionProps: { + type: 'link' + }, + label: recruit.string.CopyLink, + icon: recruit.icon.Application, + keyBinding: [], + input: 'none', + category: recruit.category.Recruit, + target: recruit.class.Applicant, + context: { + mode: ['context', 'browser'], + application: recruit.app.Recruit, + group: 'copy' + } + }, + recruit.action.CopyApplicationLink + ) + createAction( + builder, + { + action: recruit.actionImpl.CopyToClipboard, + actionProps: { + type: 'link' + }, + label: recruit.string.CopyLink, + icon: recruit.icon.Application, + keyBinding: [], + input: 'none', + category: recruit.category.Recruit, + target: contact.class.Person, + context: { + mode: ['context', 'browser'], + application: recruit.app.Recruit, + group: 'copy' + } + }, + recruit.action.CopyCandidateLink + ) } export { recruitOperation } from './migration' diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts index f470ea095f..8f122fdadd 100644 --- a/models/recruit/src/plugin.ts +++ b/models/recruit/src/plugin.ts @@ -26,10 +26,14 @@ import type { Action, ActionCategory, ViewAction, Viewlet } from '@anticrm/view' export default mergeIds(recruitId, recruit, { action: { CreateOpinion: '' as Ref, - CreateGlobalApplication: '' as Ref + CreateGlobalApplication: '' as Ref, + CopyApplicationId: '' as Ref, + CopyApplicationLink: '' as Ref, + CopyCandidateLink: '' as Ref }, actionImpl: { - CreateOpinion: '' as ViewAction + CreateOpinion: '' as ViewAction, + CopyToClipboard: '' as ViewAction }, category: { Recruit: '' as Ref diff --git a/plugins/recruit-assets/lang/en.json b/plugins/recruit-assets/lang/en.json index 1e8859af00..91ba06dd58 100644 --- a/plugins/recruit-assets/lang/en.json +++ b/plugins/recruit-assets/lang/en.json @@ -87,7 +87,9 @@ "GotoAssigned": "Go to my Assigned", "GotoApplicants": "Go to Applications", "GotoRecruitApplication": "Switch to Recruit Application", - "AddDropHere": "Add or drop resume" + "AddDropHere": "Add or drop resume", + "CopyId": "Copy ID", + "CopyLink": "Copy link" }, "status": { "TalentRequired": "Please select talent", diff --git a/plugins/recruit-assets/lang/ru.json b/plugins/recruit-assets/lang/ru.json index 2931ee5c7f..3cffb01324 100644 --- a/plugins/recruit-assets/lang/ru.json +++ b/plugins/recruit-assets/lang/ru.json @@ -89,7 +89,9 @@ "GotoAssigned": "Перейти к моим назначениям", "GotoApplicants": "Перейти к кандидатам", "GotoRecruitApplication": "Перейти к Приложению Рекрутинг", - "AddDropHere": "Добавить или перетянуть резюме" + "AddDropHere": "Добавить или перетянуть резюме", + "CopyId": "Копировать ID", + "CopyLink": "Копировать ссылку" }, "status": { "TalentRequired": "Пожалуйста выберите таланта", diff --git a/plugins/recruit-resources/src/index.ts b/plugins/recruit-resources/src/index.ts index 12447c3a16..b4bc10f300 100644 --- a/plugins/recruit-resources/src/index.ts +++ b/plugins/recruit-resources/src/index.ts @@ -45,7 +45,7 @@ import VacancyCountPresenter from './components/VacancyCountPresenter.svelte' import VacancyItemPresenter from './components/VacancyItemPresenter.svelte' import VacancyModifiedPresenter from './components/VacancyModifiedPresenter.svelte' import VacancyPresenter from './components/VacancyPresenter.svelte' -import { getApplicationTitle } from './utils' +import { getApplicationTitle, copyToClipboard } from './utils' import recruit from './plugin' async function createOpinion (object: Doc): Promise { @@ -113,7 +113,8 @@ export async function queryApplication (client: Client, search: string): Promise export default async (): Promise => ({ actionImpl: { - CreateOpinion: createOpinion + CreateOpinion: createOpinion, + CopyToClipboard: copyToClipboard }, validator: { ApplicantValidator: applicantValidator diff --git a/plugins/recruit-resources/src/plugin.ts b/plugins/recruit-resources/src/plugin.ts index 48d6793641..903a087f79 100644 --- a/plugins/recruit-resources/src/plugin.ts +++ b/plugins/recruit-resources/src/plugin.ts @@ -76,6 +76,9 @@ export default mergeIds(recruitId, recruit, { Title: '' as IntlString, Vacancies: '' as IntlString, + CopyLink: '' as IntlString, + CopyId: '' as IntlString, + Review: '' as IntlString, ReviewCreateLabel: '' as IntlString, CreateReview: '' as IntlString, diff --git a/plugins/recruit-resources/src/utils.ts b/plugins/recruit-resources/src/utils.ts index 98402cdadf..7ac63ca202 100644 --- a/plugins/recruit-resources/src/utils.ts +++ b/plugins/recruit-resources/src/utils.ts @@ -1,6 +1,9 @@ import core, { Doc, Ref, TxOperations } from '@anticrm/core' import { translate } from '@anticrm/platform' -import { Applicant } from '@anticrm/recruit' +import { getClient } from '@anticrm/presentation' +import { Applicant, Candidate } from '@anticrm/recruit' +import { getPanelURI } from '@anticrm/ui' +import view from '@anticrm/view' import recruit from './plugin' export async function getApplicationTitle (client: TxOperations, ref: Ref): Promise { @@ -15,3 +18,24 @@ export async function getApplicationTitle (client: TxOperations, ref: Ref): const label = await translate(object.$lookup._class.shortLabel, {}) return `${label}-${object.number}` } + +export async function copyToClipboard ( + object: Applicant | Candidate, + ev: Event, + { type }: { type: string } +): Promise { + const client = getClient() + let text: string + switch (type) { + case 'id': + text = await getApplicationTitle(client, object._id) + break + case 'link': + // TODO: fix when short link is available + text = `${window.location.href}#${getPanelURI(view.component.EditDoc, object._id, object._class, 'content')}` + break + default: + return + } + await navigator.clipboard.writeText(text) +}