diff options
author | Andrejs Verza <andrejs.verza@zabbix.com> | 2022-11-07 17:14:07 +0300 |
---|---|---|
committer | Andrejs Verza <andrejs.verza@zabbix.com> | 2022-11-07 17:14:07 +0300 |
commit | a9d71a4f4e0c0e3a5bde96538d19243f52baba60 (patch) | |
tree | 9ba72c9d763a2476c8ab1425e3a10cbbb7722406 | |
parent | 3adb02dc1787318c461afd99eafe089a679bbfd2 (diff) |
..F....... [ZBXNEXT-7469] fixed pasting an inaccessible widget over existing one
-rw-r--r-- | ui/js/class.dashboard.js | 16 | ||||
-rw-r--r-- | ui/js/class.widget.js | 4 |
2 files changed, 19 insertions, 1 deletions
diff --git a/ui/js/class.dashboard.js b/ui/js/class.dashboard.js index 2cf9875662c..25a03c2b751 100644 --- a/ui/js/class.dashboard.js +++ b/ui/js/class.dashboard.js @@ -747,7 +747,11 @@ class CDashboard extends CBaseComponent { return; } + let old_widget_data = null; + if (widget !== null) { + old_widget_data = widget.getDataCopy({is_single_copy: false}); + dashboard_page.deleteWidget(widget, {is_batch_mode: true}); } @@ -792,7 +796,17 @@ class CDashboard extends CBaseComponent { } if (response.widgets[0] === null) { - dashboard_page.deleteWidget(paste_placeholder_widget); + if (widget !== null) { + dashboard_page.replaceWidget(paste_placeholder_widget, { + ...old_widget_data, + widgetid: widget.getWidgetId(), + is_new: false, + unique_id: widget.getUniqueId() + }); + } + else { + dashboard_page.deleteWidget(paste_placeholder_widget); + } this._warn(t('Cannot paste inaccessible widget.')); diff --git a/ui/js/class.widget.js b/ui/js/class.widget.js index 2584a6c23cc..36abd91e9c2 100644 --- a/ui/js/class.widget.js +++ b/ui/js/class.widget.js @@ -346,6 +346,10 @@ class CWidget extends CBaseComponent { this._fields = fields; } + getWidgetId() { + return this._widgetid; + } + _hasPadding() { return this._view_mode != ZBX_WIDGET_VIEW_MODE_HIDDEN_HEADER; } |