]> git.proxmox.com Git - pmg-gui.git/commitdiff
quarantine controller: drop specialized classes, check at runtime instead
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 4 Nov 2022 15:04:21 +0000 (16:04 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 5 Nov 2022 15:33:28 +0000 (16:33 +0100)
By making use of the optional chaining operator, we don't need to
override the 'onSelectMail' in both the attachment quarantine and the
spam quarantine. Instead, we opportunistically call lookup(id)?.setID
in the common handler for both, the attachments and the spaminfo
references.

As that was the single change from the parent class we can now drop
the specialized controller classes.

While at it, remove the stray 'xtype' property of the quarantine
controller, which make only sense for component derived classes.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [T: fix typos and reword message a bit]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
js/AttachmentQuarantine.js
js/SpamQuarantine.js
js/controller/QuarantineController.js

index 8abfcad4f0977cffba25d5f2ab5933b07a383dbd..5e0c2ea7d644d558c7a59c8e0257675539bafdbe 100644 (file)
@@ -18,34 +18,6 @@ Ext.define('pmg-attachment-list', {
     idProperty: 'id',
 });
 
-Ext.define('PMG.AttachmentQuarantineController', {
-    extend: 'PMG.controller.QuarantineController',
-    alias: 'controller.attachmentquarantine',
-    xtype: 'pmgAttachmentQuarantineController',
-
-    onSelectMail: function() {
-       let me = this;
-       let list = this.lookupReference('list');
-       let selection = list.selModel.getSelection();
-       if (selection.length <= 1) {
-           let rec = selection[0] || {};
-           me.lookup('attachmentlist').setID(rec);
-       }
-
-       me.callParent();
-    },
-
-    control: {
-       'button[reference=raw]': {
-           click: 'toggleRaw',
-       },
-       'pmgQuarantineList': {
-           selectionChange: 'onSelectMail',
-       },
-    },
-
-});
-
 Ext.define('PMG.AttachmentQuarantine', {
     extend: 'Ext.container.Container',
     xtype: 'pmgAttachmentQuarantine',
@@ -64,7 +36,7 @@ Ext.define('PMG.AttachmentQuarantine', {
            downloadMailURL: get => '/api2/json/quarantine/download?mailid=' + encodeURIComponent(get('mailid')),
        },
     },
-    controller: 'attachmentquarantine',
+    controller: 'quarantine',
     items: [
        {
            title: gettext('Attachment Quarantine'),
index cf7f181be7bb7b84fbd174bc7a150f6be3541443..c86ce79ac45e4d2a840ebc396a43cdb26c1fc592 100644 (file)
@@ -54,18 +54,6 @@ Ext.define('PMG.SpamQuarantineController', {
        me.callParent(selection);
     },
 
-    onSelectMail: function() {
-       let me = this;
-       let list = me.lookupReference('list');
-       let selection = list.selModel.getSelection();
-       if (selection.length <= 1) {
-           let rec = selection[0] || {};
-           me.lookupReference('spaminfo').setID(rec);
-       }
-       me.callParent();
-    },
-
-
     toggleSpamInfo: function(btn) {
        var grid = this.lookupReference('spaminfo');
        grid.setVisible(!grid.isVisible());
@@ -121,7 +109,6 @@ Ext.define('PMG.SpamQuarantineController', {
            click: 'toggleSpamInfo',
        },
        'pmgQuarantineList': {
-           selectionChange: 'onSelectMail',
            itemkeypress: 'keyPress',
            rowcontextmenu: 'openContextMenu',
        },
index dfe29154f54411396f9a9197aff302f8fc7854f9..d47af6ab1e0ca1e06fd779dc27081845b514c1eb 100644 (file)
@@ -1,6 +1,5 @@
 Ext.define('PMG.controller.QuarantineController', {
     extend: 'Ext.app.ViewController',
-    xtype: 'controller.Quarantine',
     alias: 'controller.quarantine',
 
     updatePreview: function(raw, rec) {
@@ -120,6 +119,8 @@ Ext.define('PMG.controller.QuarantineController', {
        }
 
        let rec = selection[0] || {};
+       me.lookup('spaminfo')?.setID(rec);
+       me.lookup('attachmentlist')?.setID(rec);
 
        me.getViewModel().set('mailid', rec.data ? rec.data.id : '');
        me.updatePreview(me.raw || false, rec);