[pmg-devel] [PATCH pmg-gui 1/5] simply quarantine controllers a bit
Dominik Csapak
d.csapak at proxmox.com
Fri Nov 4 16:04:21 CET 2022
by making use of the optional chaining operator, we don't need to
override the 'onSelectMail' if both the attachment quarantine and the
spam quarantine. simply call lookup(id)?.setID everytime for both the
attachments and the spaminfo
this makes the seperate attachment quarantine controller unnecessary.
also remove the stray 'xtype' of the QuarantineController
(it's not a component, thus no xtype)
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
js/AttachmentQuarantine.js | 30 +--------------------------
js/SpamQuarantine.js | 13 ------------
js/controller/QuarantineController.js | 3 ++-
3 files changed, 3 insertions(+), 43 deletions(-)
diff --git a/js/AttachmentQuarantine.js b/js/AttachmentQuarantine.js
index 8abfcad..5e0c2ea 100644
--- a/js/AttachmentQuarantine.js
+++ b/js/AttachmentQuarantine.js
@@ -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'),
diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js
index cf7f181..c86ce79 100644
--- a/js/SpamQuarantine.js
+++ b/js/SpamQuarantine.js
@@ -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',
},
diff --git a/js/controller/QuarantineController.js b/js/controller/QuarantineController.js
index dfe2915..d47af6a 100644
--- a/js/controller/QuarantineController.js
+++ b/js/controller/QuarantineController.js
@@ -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);
--
2.30.2
More information about the pmg-devel
mailing list