diff options
author | Andrejs Griščenko <andrejs.griscenko@zabbix.com> | 2021-05-08 10:21:00 +0300 |
---|---|---|
committer | Andrejs Griščenko <andrejs.griscenko@zabbix.com> | 2021-05-08 10:21:00 +0300 |
commit | 2da7adceca262e1a3f0acfa9b916edf9eaf8bac1 (patch) | |
tree | 5c82eb8a59da6e57d17178116789a74949140b58 /ui | |
parent | f4d1fce641d5e3c3efbe1319c0279b01074d0e92 (diff) |
..F....... [ZBXNEXT-6561] fixed changing item in condition popup always resets function to last(); fixed first function is selected in condition popup when editing trigger expression using expression constructor
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/controllers/CControllerPopupTriggerExpr.php | 7 | ||||
-rw-r--r-- | ui/app/views/js/popup.triggerexpr.js.php | 5 | ||||
-rw-r--r-- | ui/app/views/popup.triggerexpr.php | 6 | ||||
-rw-r--r-- | ui/js/common.js | 8 |
4 files changed, 6 insertions, 20 deletions
diff --git a/ui/app/controllers/CControllerPopupTriggerExpr.php b/ui/app/controllers/CControllerPopupTriggerExpr.php index 98f7091a098..c05b9823be1 100644 --- a/ui/app/controllers/CControllerPopupTriggerExpr.php +++ b/ui/app/controllers/CControllerPopupTriggerExpr.php @@ -39,10 +39,6 @@ class CControllerPopupTriggerExpr extends CController { private $allowedTypesLog = []; private $allowedTypesInt = []; private $functions = []; - private $function_types = [ZBX_FUNCTION_TYPE_AGGREGATE, ZBX_FUNCTION_TYPE_BITWISE, ZBX_FUNCTION_TYPE_DATE_TIME, - ZBX_FUNCTION_TYPE_HISTORY, ZBX_FUNCTION_TYPE_MATH, ZBX_FUNCTION_TYPE_OPERATOR, ZBX_FUNCTION_TYPE_PREDICTION, - ZBX_FUNCTION_TYPE_STRING - ]; private $operators = ['=', '<>', '>', '<', '>=', '<=']; private $period_optional = []; @@ -1044,7 +1040,6 @@ class CControllerPopupTriggerExpr extends CController { 'itemid' => 'db items.itemid', 'parent_discoveryid' => 'db items.itemid', 'function' => 'in '.implode(',', array_keys($this->functions)), - 'function_type' => 'in '.implode(',', $this->function_types), 'operator' => 'in '.implode(',', $this->operators), 'params' => '', 'paramtype' => 'in '.implode(',', [PARAM_TYPE_TIME, PARAM_TYPE_COUNTS]), @@ -1292,7 +1287,7 @@ class CControllerPopupTriggerExpr extends CController { 'item_required' => !in_array($function, array_merge(getStandaloneFunctions(), getFunctionsConstants())), 'functions' => $this->functions, 'function' => $function, - 'function_type' => $this->getInput('function_type', ZBX_FUNCTION_TYPE_HISTORY), + 'function_type' => reset($this->functions[$function]['types']), 'operator' => $operator, 'item_key' => $item_key, 'itemValueType' => $item_value_type, diff --git a/ui/app/views/js/popup.triggerexpr.js.php b/ui/app/views/js/popup.triggerexpr.js.php index 7d564ed040b..ffb6410b8ad 100644 --- a/ui/app/views/js/popup.triggerexpr.js.php +++ b/ui/app/views/js/popup.triggerexpr.js.php @@ -40,11 +40,10 @@ $(() => { } }; - $('#function').on('change', (e) => { + $('#function-select').on('change', (e) => { var form = e.target.closest('form'), - function_name_parts = form.elements.function.value.split('_'); + function_name_parts = form.elements.function_select.value.split('_'); - form.elements.function_type.value = function_name_parts[0]; form.elements.function.value = function_name_parts[1]; reloadPopup(form, 'popup.triggerexpr'); diff --git a/ui/app/views/popup.triggerexpr.php b/ui/app/views/popup.triggerexpr.php index 95615f8d5d6..57886c0c7d9 100644 --- a/ui/app/views/popup.triggerexpr.php +++ b/ui/app/views/popup.triggerexpr.php @@ -32,7 +32,7 @@ $expression_form = (new CForm()) ->addVar('dstfld1', $data['dstfld1']) ->addItem((new CVar('hostid', $data['hostid']))->removeId()) ->addVar('groupid', $data['groupid']) - ->addVar('function_type', $data['function_type']) + ->addVar('function', $data['function']) ->addItem((new CInput('submit', 'submit')) ->addStyle('display: none;') ->removeId() @@ -99,9 +99,9 @@ if ($data['item_required']) { $expression_form_list->addRow((new CLabel(_('Item'), 'item_description'))->setAsteriskMark(), $item); } -$function_select = (new CSelect('function')) +$function_select = (new CSelect('function_select')) ->setFocusableElementId('label-function') - ->setId('function') + ->setId('function-select') ->setValue($data['function_type'].'_'.$data['function']); $function_types = [ diff --git a/ui/js/common.js b/ui/js/common.js index 45fb91dc2f1..fea4b6bcf1c 100644 --- a/ui/js/common.js +++ b/ui/js/common.js @@ -717,14 +717,6 @@ function validate_trigger_expression(overlay) { var $form = overlay.$dialogue.find('form'), url = new Curl($form.attr('action')); - // Remove function type from function name. - var function_name = $form[0].elements.function, - function_name_parts = function_name.value.split('_'); - - if (function_name_parts.length == 2) { - function_name.value = function_name_parts[1]; - } - url.setArgument('add', 1); overlay.setLoading(); |