]> git.proxmox.com Git - pmg-gui.git/commitdiff
spam detector: custom rules: consitent add/edit/remove button & modernization
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Feb 2024 13:41:17 +0000 (14:41 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Feb 2024 13:41:17 +0000 (14:41 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
js/SpamDetectorCustom.js

index 72bf224c500b316cf1b13e9a2863f47cd54aa797..4ccf3ace695a1bcbd6d77d4ede09923261d7b0b7 100644 (file)
@@ -106,7 +106,8 @@ Ext.define('PMG.SpamDetectorCustomScores', {
            var me = this;
            var vm = this.getViewModel();
 
-           var win = Ext.createWidget('proxmoxWindowEdit', {
+           Ext.createWidget('proxmoxWindowEdit', {
+               autoShow: true,
                method: 'POST',
                url: "/api2/extjs/config/customscores",
                isCreate: true,
@@ -137,22 +138,24 @@ Ext.define('PMG.SpamDetectorCustomScores', {
                        value: vm.get('digest'),
                    },
                ],
+               listeners: {
+                   destroy: () => me.reload(),
+               },
            });
-
-           win.on('destroy', me.reload, me);
-           win.show();
        },
 
        run_editor: function() {
-           var me = this;
-           var vm = this.getViewModel();
-           var grid = me.lookup('grid');
-           var rec = grid.getSelection()[0];
+           let me = this;
+           let vm = me.getViewModel();
+           let grid = me.lookup('grid');
+           let rec = grid.getSelection()[0];
            if (!rec) {
                return;
            }
 
-           var win = Ext.createWidget('proxmoxWindowEdit', {
+           Ext.createWidget('proxmoxWindowEdit', {
+               autoShow: true,
+               autoLoad: true,
                url: "/api2/extjs/config/customscores/" + rec.data.name,
                method: 'PUT',
                subject: gettext("Custom Rule Score"),
@@ -181,11 +184,10 @@ Ext.define('PMG.SpamDetectorCustomScores', {
                        value: vm.get('digest'),
                    },
                ],
+               listeners: {
+                   destroy: () => me.reload(),
+               },
            });
-
-           win.load();
-           win.on('destroy', me.reload, me);
-           win.show();
        },
     },
 
@@ -215,16 +217,17 @@ Ext.define('PMG.SpamDetectorCustomScores', {
            },
 
            tbar: [
+               {
+                   text: gettext('Create'),
+                   handler: 'create_custom',
+               },
+               '-',
                {
                    xtype: 'proxmoxButton',
                    text: gettext('Edit'),
                    disabled: true,
                    handler: 'run_editor',
                },
-               {
-                   text: gettext('Create'),
-                   handler: 'create_custom',
-               },
                {
                    xtype: 'proxmoxStdRemoveButton',
                    getUrl: function(rec) {