public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-gui 1/5] simply quarantine controllers a bit
Date: Fri,  4 Nov 2022 16:04:21 +0100	[thread overview]
Message-ID: <20221104150425.124194-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20221104150425.124194-1-d.csapak@proxmox.com>

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@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





  parent reply	other threads:[~2022-11-04 15:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 15:04 [pmg-devel] [PATCH pmg-api/pmg-gui] improvements to the quarantine interface Dominik Csapak
2022-11-04 15:04 ` [pmg-devel] [PATCH pmg-api 1/1] api/quarantine: allow 'listattachments' for quarantine users Dominik Csapak
2022-11-07  8:47   ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-04 15:04 ` Dominik Csapak [this message]
2022-11-07  8:47   ` [pmg-devel] applied: [PATCH pmg-gui 1/5] simply quarantine controllers a bit Thomas Lamprecht
2022-11-04 15:04 ` [pmg-devel] [PATCH pmg-gui 2/5] quarantines: add attachment grid to spam and virus quarantine Dominik Csapak
2022-11-07 12:21   ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-04 15:04 ` [pmg-devel] [PATCH pmg-gui 3/5] fix #4238: SpamInfoGrid: enable sorting & add colors for spam score Dominik Csapak
2022-11-07  9:56   ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-04 15:04 ` [pmg-devel] [PATCH pmg-gui 4/5] quarantine: improve borders for docked items Dominik Csapak
2022-11-07  9:57   ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-04 15:04 ` [pmg-devel] [PATCH pmg-gui 5/5] fix #2533: quarantine: add overflowHandler to the preview panel Dominik Csapak
2022-11-07  9:57   ` [pmg-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221104150425.124194-3-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal