mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-29 21:15:06 +02:00
Allow open relations in new tab from context menu (#10359)
* Allow open relations in new tab from context menu Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * Fix formatting Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> --------- Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -81,9 +81,15 @@
|
||||
? { docA: object._id, docB: doc._id, association: association._id }
|
||||
: { docA: doc._id, docB: object._id, association: association._id }
|
||||
const relation = await client.findOne(core.class.Relation, q)
|
||||
const overrides = new Map()
|
||||
if (relation !== undefined) {
|
||||
showMenu(ev, { object: relation, includedActions: [view.action.RemoveRelation] })
|
||||
overrides.set(view.action.Delete, async (obj: Doc | Doc[], ev?: Event) => {
|
||||
if (relation !== undefined) {
|
||||
await client.remove(relation)
|
||||
}
|
||||
})
|
||||
}
|
||||
showMenu(ev, { object: doc, overrides })
|
||||
}
|
||||
|
||||
function isAllowedToCreate (association: Association, docs: Doc[], direction: 'A' | 'B'): boolean {
|
||||
|
||||
@@ -192,10 +192,6 @@
|
||||
gtotal = total
|
||||
}
|
||||
|
||||
const showContextMenu = async (ev: MouseEvent, object: Doc, row: number): Promise<void> => {
|
||||
showMenu(ev, { object, baseMenuClass })
|
||||
}
|
||||
|
||||
function changeSorting (key: string | string[]): void {
|
||||
if (key === '') {
|
||||
return
|
||||
@@ -229,6 +225,7 @@
|
||||
}
|
||||
return { ...attribute.props, space: object.space, ...readonlyParams }
|
||||
}
|
||||
|
||||
function getValue (attribute: AttributeModel, object: Doc): any {
|
||||
if (attribute.castRequest) {
|
||||
return getObjectValue(
|
||||
@@ -242,6 +239,11 @@
|
||||
return getObjectValue(attribute.key, object)
|
||||
}
|
||||
|
||||
function showContextMenu (ev: MouseEvent, object: Doc | undefined): void {
|
||||
if (object === undefined) return
|
||||
showMenu(ev, { object })
|
||||
}
|
||||
|
||||
function onChange (value: any, doc: Doc, key: string, attribute: AnyAttribute): void {
|
||||
updateAttribute(client, doc, _class, { key, attr: attribute }, value)
|
||||
}
|
||||
@@ -607,6 +609,9 @@
|
||||
class:empty={cell.object === undefined}
|
||||
class:first={i === 0}
|
||||
class:cursor-pointer={cell.parentObject}
|
||||
on:contextmenu={(e) => {
|
||||
showContextMenu(e, cell.object)
|
||||
}}
|
||||
on:click={(e) => {
|
||||
clickHandler(e, cell)
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user