From 1f8bfa3b30a7d11e9c04fa23462de12fb1711af0 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 16 Nov 2023 12:57:53 +0100 Subject: [PATCH] notification matcher: improve wording for mode by removing the 'invert' checkbox and instead show the 4 modes possible, we still assemble/parse the invert for the backend Signed-off-by: Dominik Csapak --- src/window/NotificationMatcherEdit.js | 54 +++++++++------------------ 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/src/window/NotificationMatcherEdit.js b/src/window/NotificationMatcherEdit.js index 0f29203..5a88288 100644 --- a/src/window/NotificationMatcherEdit.js +++ b/src/window/NotificationMatcherEdit.js @@ -516,35 +516,22 @@ Ext.define('Proxmox.panel.NotificationRulesEditPanel', { let me = this; let record = me.get('selectedRecord'); let currentData = record.get('data'); + let invert = false; + if (value.startsWith('not')) { + value = value.substring(3); + invert = true; + } record.set({ data: { ...currentData, value, + invert, }, }); }, get: function(record) { - return record?.get('data')?.value; - }, - }, - invertMatch: { - bind: { - bindTo: '{selectedRecord}', - deep: true, - }, - set: function(value) { - let me = this; - let record = me.get('selectedRecord'); - let currentData = record.get('data'); - record.set({ - data: { - ...currentData, - invert: value, - }, - }); - }, - get: function(record) { - return record?.get('data')?.invert; + let prefix = record?.get('data').invert ? 'not' : ''; + return prefix + record?.get('data')?.value; }, }, }, @@ -791,8 +778,12 @@ Ext.define('Proxmox.panel.NotificationMatchRuleTree', { matchCalendarStmts.push(data.value); break; case 'mode': - modeStmt = data.value; - invertMatchStmt = data.invert; + if (data.value.startsWith('not')) { + modeStmt = data.value.substring(3); // after 'not'' + invertMatchStmt = true; + } else { + modeStmt = data.value; + } break; } @@ -1004,9 +995,13 @@ Ext.define('Proxmox.panel.NotificationMatchRuleSettings', { allowBlank: false, isFormField: false, + matchFieldWidth: false, + comboItems: [ ['all', gettext('All rules match')], ['any', gettext('Any rule matches')], + ['notall', gettext('At least one rule does not match')], + ['notany', gettext('No rule matches')], ], bind: { hidden: '{!showMatchingMode}', @@ -1014,19 +1009,6 @@ Ext.define('Proxmox.panel.NotificationMatchRuleSettings', { value: '{rootMode}', }, }, - { - xtype: 'proxmoxcheckbox', - fieldLabel: gettext('Invert match'), - isFormField: false, - uncheckedValue: 0, - defaultValue: 0, - bind: { - hidden: '{!showMatchingMode}', - disabled: '{!showMatchingMode}', - value: '{invertMatch}', - }, - - }, { xtype: 'proxmoxKVComboBox', fieldLabel: gettext('Node type'),