]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
notification matcher: improve wording for mode
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 16 Nov 2023 11:57:53 +0000 (12:57 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 17 Nov 2023 14:11:25 +0000 (15:11 +0100)
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 <d.csapak@proxmox.com>
src/window/NotificationMatcherEdit.js

index 0f292036fa00cea64c85ac2d07aa9ca01e4797a6..5a88288b0e58634f76a9639519e0c0a14ca50b94 100644 (file)
@@ -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'),