From 2c6e156cf4744c93055627adbe162c04cd9cdbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 13 Jul 2023 15:41:06 +0200 Subject: [PATCH] Add menu to copy selected record from tree view to clipboard We convert the optional drop-down into a general tree menu with the copy option. Closes #12399 --- sao/CHANGELOG | 1 + sao/src/sao.less | 4 +- sao/src/view/tree.js | 171 ++++++++++++++++++++++++++----------------- 3 files changed, 106 insertions(+), 70 deletions(-) diff --git a/sao/CHANGELOG b/sao/CHANGELOG index 0eaa7a38d7..87f4305e60 100644 --- a/sao/CHANGELOG +++ b/sao/CHANGELOG @@ -1,3 +1,4 @@ +* Add menu to copy selected record from tree view to clipboard * Support PYSON comparison of timedelta * Support encoding timedelta into PYSON TimeDelta * Eagerly read string value of multiselection fields diff --git a/sao/src/sao.less b/sao/src/sao.less index d72f0cdf62..e7e4bdea99 100644 --- a/sao/src/sao.less +++ b/sao/src/sao.less @@ -440,7 +440,7 @@ img.icon { width: 100%; table-layout: fixed; - col.selection-state, col.favorite, col.draggable-handle, col.optional { + col.selection-state, col.favorite, col.tree-menu { width: 30px; } @@ -459,7 +459,7 @@ img.icon { > label.sortable { cursor: pointer; } - &.optional { + &.tree-menu { cursor: pointer; overflow: visible; diff --git a/sao/src/view/tree.js b/sao/src/view/tree.js index 8956848537..4d145bfc51 100644 --- a/sao/src/view/tree.js +++ b/sao/src/view/tree.js @@ -274,50 +274,47 @@ this.tbody = jQuery(''); this.table.append(this.tbody); + this.colgroup.prepend(jQuery('', { + 'class': 'tree-menu', + })); + this.thead.children().prepend(jQuery('', { + 'class': 'tree-menu', + })); + if (this.tfoot) { + this.tfoot.children().prepend(jQuery('')); + } + this.set_drag_and_drop(); + th = this.thead.find('th').first(); if (this.optionals.length) { - if (this.draggable) { - th = this.thead.children().children().first(); - th.addClass('optional'); - } else { - this.colgroup.prepend(jQuery('', { - 'class': 'optional', - })); - th = jQuery('', { - 'class': 'optional', - }); - this.thead.children().prepend(th); - if (this.tfoot) { - this.tfoot.children().prepend(jQuery('')); - } - } - var menu = jQuery('