From ea364db75269e723045668e645702e9ab4706bf3 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Mon, 5 Jan 2026 04:09:16 +0500 Subject: [PATCH] Allow open relations in new tab from context menu (#10359) * Allow open relations in new tab from context menu Signed-off-by: Denis Bykhov * Fix formatting Signed-off-by: Denis Bykhov --------- Signed-off-by: Denis Bykhov --- .../src/components/RelationEditor.svelte | 8 +++++++- .../src/components/RelationshipTable.svelte | 13 +++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/view-resources/src/components/RelationEditor.svelte b/plugins/view-resources/src/components/RelationEditor.svelte index c5ceccf311..b8aa18ad4e 100644 --- a/plugins/view-resources/src/components/RelationEditor.svelte +++ b/plugins/view-resources/src/components/RelationEditor.svelte @@ -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 { diff --git a/plugins/view-resources/src/components/RelationshipTable.svelte b/plugins/view-resources/src/components/RelationshipTable.svelte index de9008ab53..9b1beeeaec 100644 --- a/plugins/view-resources/src/components/RelationshipTable.svelte +++ b/plugins/view-resources/src/components/RelationshipTable.svelte @@ -192,10 +192,6 @@ gtotal = total } - const showContextMenu = async (ev: MouseEvent, object: Doc, row: number): Promise => { - 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) }}