mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-16 13:21:57 +00:00
Context menu Copy section (#2154)
Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
This commit is contained in:
parent
5eb343f103
commit
4d836d38a1
@ -783,4 +783,67 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
tracker.action.SetDueDate
|
||||
)
|
||||
createAction(
|
||||
builder,
|
||||
{
|
||||
action: tracker.actionImpl.CopyToClipboard,
|
||||
actionProps: {
|
||||
type: 'id'
|
||||
},
|
||||
label: tracker.string.CopyIssueId,
|
||||
icon: tracker.icon.CopyID,
|
||||
keyBinding: [],
|
||||
input: 'none',
|
||||
category: tracker.category.Tracker,
|
||||
target: tracker.class.Issue,
|
||||
context: {
|
||||
mode: ['context', 'browser'],
|
||||
application: tracker.app.Tracker,
|
||||
group: 'copy'
|
||||
}
|
||||
},
|
||||
tracker.action.CopyIssueId
|
||||
)
|
||||
createAction(
|
||||
builder,
|
||||
{
|
||||
action: tracker.actionImpl.CopyToClipboard,
|
||||
actionProps: {
|
||||
type: 'title'
|
||||
},
|
||||
label: tracker.string.CopyIssueTitle,
|
||||
icon: tracker.icon.CopyBranch,
|
||||
keyBinding: [],
|
||||
input: 'none',
|
||||
category: tracker.category.Tracker,
|
||||
target: tracker.class.Issue,
|
||||
context: {
|
||||
mode: ['context', 'browser'],
|
||||
application: tracker.app.Tracker,
|
||||
group: 'copy'
|
||||
}
|
||||
},
|
||||
tracker.action.CopyIssueTitle
|
||||
)
|
||||
createAction(
|
||||
builder,
|
||||
{
|
||||
action: tracker.actionImpl.CopyToClipboard,
|
||||
actionProps: {
|
||||
type: 'link'
|
||||
},
|
||||
label: tracker.string.CopyIssueUrl,
|
||||
icon: tracker.icon.CopyURL,
|
||||
keyBinding: [],
|
||||
input: 'none',
|
||||
category: tracker.category.Tracker,
|
||||
target: tracker.class.Issue,
|
||||
context: {
|
||||
mode: ['context', 'browser'],
|
||||
application: tracker.app.Tracker,
|
||||
group: 'copy'
|
||||
}
|
||||
},
|
||||
tracker.action.CopyIssueLink
|
||||
)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import { IntlString, mergeIds, Resource } from '@anticrm/platform'
|
||||
import { trackerId } from '@anticrm/tracker'
|
||||
import tracker from '@anticrm/tracker-resources/src/plugin'
|
||||
import type { AnyComponent } from '@anticrm/ui/src/types'
|
||||
import { ViewletDescriptor } from '@anticrm/view'
|
||||
import { ViewAction, ViewletDescriptor } from '@anticrm/view'
|
||||
import { Application } from '@anticrm/workbench'
|
||||
|
||||
export default mergeIds(trackerId, tracker, {
|
||||
@ -49,5 +49,8 @@ export default mergeIds(trackerId, tracker, {
|
||||
completion: {
|
||||
IssueQuery: '' as Resource<ObjectSearchFactory>,
|
||||
IssueCategory: '' as Ref<ObjectSearchCategory>
|
||||
},
|
||||
actionImpl: {
|
||||
CopyToClipboard: '' as ViewAction
|
||||
}
|
||||
})
|
||||
|
@ -112,6 +112,7 @@
|
||||
"CopyIssueUrl": "Copy Issue URL to clipboard",
|
||||
"CopyIssueId": "Copy Issue ID to clipboard",
|
||||
"CopyIssueBranch": "Copy Git branch name to clipboard",
|
||||
"CopyIssueTitle": "Copy Issue title to clipboard",
|
||||
"AssetLabel": "Asset",
|
||||
"AddToProject": "Add to project\u2026",
|
||||
"MoveToProject": "Move to project\u2026",
|
||||
|
@ -112,6 +112,7 @@
|
||||
"CopyIssueUrl": "Копировать URL-адрес задачи в буфер обмена",
|
||||
"CopyIssueId": "Копировать ID задачи в буфер обмена",
|
||||
"CopyIssueBranch": "Копировать имя ветки Git в буфер обмена",
|
||||
"CopyIssueTitle": "Копировать имя задачи в буфер обмена",
|
||||
"AssetLabel": "Asset",
|
||||
"AddToProject": "Добавить в проект\u2026",
|
||||
"MoveToProject": "Переместить в проект\u2026",
|
||||
|
@ -56,7 +56,7 @@ import SetParentIssueActionPopup from './components/SetParentIssueActionPopup.sv
|
||||
import Views from './components/views/Views.svelte'
|
||||
import KanbanView from './components/issues/KanbanView.svelte'
|
||||
import tracker from './plugin'
|
||||
import { getIssueId, getIssueTitle } from './utils'
|
||||
import { copyToClipboard, getIssueId, getIssueTitle } from './utils'
|
||||
import CreateIssue from './components/CreateIssue.svelte'
|
||||
|
||||
export async function queryIssue<D extends Issue> (
|
||||
@ -107,6 +107,7 @@ export async function queryIssue<D extends Issue> (
|
||||
component: IssueItem
|
||||
}))
|
||||
}
|
||||
|
||||
export default async (): Promise<Resources> => ({
|
||||
component: {
|
||||
NopeComponent,
|
||||
@ -153,5 +154,8 @@ export default async (): Promise<Resources> => ({
|
||||
},
|
||||
function: {
|
||||
IssueTitleProvider: getIssueTitle
|
||||
},
|
||||
actionImpl: {
|
||||
CopyToClipboard: copyToClipboard
|
||||
}
|
||||
})
|
||||
|
@ -148,6 +148,7 @@ export default mergeIds(trackerId, tracker, {
|
||||
CopyIssueUrl: '' as IntlString,
|
||||
CopyIssueId: '' as IntlString,
|
||||
CopyIssueBranch: '' as IntlString,
|
||||
CopyIssueTitle: '' as IntlString,
|
||||
|
||||
FilterIs: '' as IntlString,
|
||||
FilterIsNot: '' as IntlString,
|
||||
|
@ -17,6 +17,7 @@ import contact, { Employee, formatName } from '@anticrm/contact'
|
||||
import { Doc, DocumentQuery, Ref, SortingOrder, TxOperations } from '@anticrm/core'
|
||||
import { TypeState } from '@anticrm/kanban'
|
||||
import { Asset, IntlString, translate } from '@anticrm/platform'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import {
|
||||
Issue,
|
||||
IssuesDateModificationPeriod,
|
||||
@ -26,7 +27,13 @@ import {
|
||||
ProjectStatus,
|
||||
Team
|
||||
} from '@anticrm/tracker'
|
||||
import { AnyComponent, AnySvelteComponent, getMillisecondsInMonth, MILLISECONDS_IN_WEEK } from '@anticrm/ui'
|
||||
import {
|
||||
AnyComponent,
|
||||
AnySvelteComponent,
|
||||
getMillisecondsInMonth,
|
||||
getPanelURI,
|
||||
MILLISECONDS_IN_WEEK
|
||||
} from '@anticrm/ui'
|
||||
import tracker from './plugin'
|
||||
import { defaultPriorities, defaultProjectStatuses, issuePriorities } from './types'
|
||||
|
||||
@ -461,3 +468,23 @@ export async function getIssueTitle (client: TxOperations, ref: Ref<Doc>): Promi
|
||||
if (object?.$lookup?.space === undefined) throw new Error(`Issue Team not found, _id: ${ref}`)
|
||||
return getIssueId(object.$lookup.space, object)
|
||||
}
|
||||
|
||||
export async function copyToClipboard (object: Issue, ev: Event, { type }: { type: string }): Promise<void> {
|
||||
const client = getClient()
|
||||
let text: string
|
||||
switch (type) {
|
||||
case 'id':
|
||||
text = await getIssueTitle(client, object._id)
|
||||
break
|
||||
case 'title':
|
||||
text = object.title
|
||||
break
|
||||
case 'link':
|
||||
// TODO: fix when short link is available
|
||||
text = `${window.location.href}#${getPanelURI(tracker.component.EditIssue, object._id, object._class, 'content')}`
|
||||
break
|
||||
default:
|
||||
return
|
||||
}
|
||||
await navigator.clipboard.writeText(text)
|
||||
}
|
||||
|
@ -280,7 +280,10 @@ export default plugin(trackerId, {
|
||||
SetStatus: '' as Ref<Action>,
|
||||
SetPriority: '' as Ref<Action>,
|
||||
SetAssignee: '' as Ref<Action>,
|
||||
SetProject: '' as Ref<Action>
|
||||
SetProject: '' as Ref<Action>,
|
||||
CopyIssueId: '' as Ref<Action>,
|
||||
CopyIssueTitle: '' as Ref<Action>,
|
||||
CopyIssueLink: '' as Ref<Action>
|
||||
},
|
||||
team: {
|
||||
DefaultTeam: '' as Ref<Team>
|
||||
|
Loading…
Reference in New Issue
Block a user