diff options
author | Dace Petra <dace.petra@zabbix.com> | 2022-07-07 13:04:07 +0300 |
---|---|---|
committer | Dace Petra <dace.petra@zabbix.com> | 2022-07-07 13:04:07 +0300 |
commit | 1b0d29604b9e57b8affa419fa3ab1d88453ce5c7 (patch) | |
tree | d7a8962b7a4db6fe361f49063b6978a0be1992d4 | |
parent | 931e073f3053f80810ff77a779d557f8af1d64e2 (diff) | |
parent | 9a0c3ae086937ba32012aced5773d1645b44f358 (diff) |
..F....... [ZBX-18534] fixed name autocomplete when select element has been selected in map navigation tree
Merge in ZBX/zabbix from feature/ZBX-18534-6.0 to release/6.0
* commit '9a0c3ae086937ba32012aced5773d1645b44f358':
..F....... [ZBX-18534] refactored the Javascript code into a separate file
..F....... [ZBX-18534] fixed name autocomplete when select element has been selected in map navigation tree
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-18534 | 1 | ||||
-rw-r--r-- | ui/app/views/js/monitoring.widget.navtreeitem.edit.js.php | 48 | ||||
-rw-r--r-- | ui/app/views/monitoring.widget.navtreeitem.edit.php | 26 | ||||
-rw-r--r-- | ui/js/widgets/class.widget.navtree.js | 3 |
4 files changed, 58 insertions, 20 deletions
diff --git a/ChangeLog.d/bugfix/ZBX-18534 b/ChangeLog.d/bugfix/ZBX-18534 new file mode 100644 index 00000000000..f96eb539897 --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-18534 @@ -0,0 +1 @@ +..F....... [ZBX-18534] fixed name autocomplete when select element has been selected in map navigation tree (dpetra) diff --git a/ui/app/views/js/monitoring.widget.navtreeitem.edit.js.php b/ui/app/views/js/monitoring.widget.navtreeitem.edit.js.php new file mode 100644 index 00000000000..fd68a9c09a0 --- /dev/null +++ b/ui/app/views/js/monitoring.widget.navtreeitem.edit.js.php @@ -0,0 +1,48 @@ +<?php declare(strict_types = 0); +/* +** Zabbix +** Copyright (C) 2001-2022 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + + +/** + * @var CView $this + */ +?> + +window.navtreeitem_edit_popup = new class { + init() { + jQuery('#sysmapname').on('change', (e) => { + const name_input = document.getElementById('name'); + + if (name_input.value === '') { + name_input.value = e.target.value; + } + }); + + document.getElementById('select').addEventListener('click', () => { + return PopUp('popup.generic', { + srctbl: 'sysmaps', + srcfld1: 'sysmapid', + srcfld2: 'name', + dstfrm: 'widget_dialogue_form', + dstfld1: 'sysmapid', + dstfld2: 'sysmapname' + }, {dialogue_class: 'modal-popup-generic'}); + }); + } +}; diff --git a/ui/app/views/monitoring.widget.navtreeitem.edit.php b/ui/app/views/monitoring.widget.navtreeitem.edit.php index accedaf91f9..1794d6e1ef1 100644 --- a/ui/app/views/monitoring.widget.navtreeitem.edit.php +++ b/ui/app/views/monitoring.widget.navtreeitem.edit.php @@ -39,24 +39,9 @@ $form_list = (new CFormList()) ) ->addRow(_('Linked map'), [ new CVar('sysmapid', $data['sysmap']['sysmapid']), - (new CTextBox('sysmapname', $data['sysmap']['name'], true)) - ->setAttribute('onChange', - 'javascript: if(jQuery("#'.$form->getName().' input[type=text]:first").val() === ""){'. - 'jQuery("#widget-dialogue-form input[type=text]:first").val(this.value);}') - ->setWidth(ZBX_TEXTAREA_MEDIUM_WIDTH), + (new CTextBox('sysmapname', $data['sysmap']['name'], true))->setWidth(ZBX_TEXTAREA_MEDIUM_WIDTH), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), - (new CButton('select', _('Select'))) - ->addClass(ZBX_STYLE_BTN_GREY) - ->onClick( - 'return PopUp("popup.generic", '.json_encode([ - 'srctbl' => 'sysmaps', - 'srcfld1' => 'sysmapid', - 'srcfld2' => 'name', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'sysmapid', - 'dstfld2' => 'sysmapname' - ]).', {dialogue_class: "modal-popup-generic"});' - ) + (new CButton('select', _('Select')))->addClass(ZBX_STYLE_BTN_GREY) ]); if ($data['depth'] >= WIDGET_NAVIGATION_TREE_MAX_DEPTH) { @@ -69,10 +54,13 @@ else { ]); } -$form->addItem($form_list); +$form + ->addItem($form_list) + ->addItem((new CScriptTag('navtreeitem_edit_popup.init();'))->setOnDocumentReady()); $output = [ - 'body' => $form->toString() + 'body' => $form->toString(), + 'script_inline' => $this->readJsFile('monitoring.widget.navtreeitem.edit.js.php') ]; if (($messages = getMessages()) !== null) { diff --git a/ui/js/widgets/class.widget.navtree.js b/ui/js/widgets/class.widget.navtree.js index e25c364d996..c424c86c8f8 100644 --- a/ui/js/widgets/class.widget.navtree.js +++ b/ui/js/widgets/class.widget.navtree.js @@ -961,7 +961,8 @@ class CWidgetNavTree extends CWidget { 'action': () => {} } ], - 'dialogueid': 'navtreeitem' + 'dialogueid': 'navtreeitem', + 'script_inline': resp.script_inline }, trigger_elmnt); } }); |