]> git.proxmox.com Git - pmg-gui.git/commitdiff
implement multiselection of spamquarantine mails
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 28 Mar 2018 08:36:00 +0000 (10:36 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 29 Mar 2018 12:22:42 +0000 (14:22 +0200)
and allow the actions to be sent for all simultaniously

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
js/QuarantineList.js
js/SpamQuarantine.js
js/VirusQuarantine.js

index fcfa3b4cc814ce99eb1ea41fdef295d1154fc03d..597e573d7ceb3b684e4666447736ea5740d81f03 100644 (file)
@@ -18,6 +18,10 @@ Ext.define('PMG.QuarantineList', {
        to: 0
     },
 
+    selModel: {
+       selType: 'checkboxmodel'
+    },
+
     controller: {
        xclass: 'Ext.app.ViewController',
 
index cec03c169e8c30a672f3f2321c7c43cc657440f2..5c6865b31e5eef17e05a86c655a40632ef0520ef 100644 (file)
@@ -63,9 +63,25 @@ Ext.define('PMG.SpamQuarantine', {
 
            var url = '/api2/htmlmail/quarantine/content?id=' + rec.data.id + ((raw)?'&raw=1':'');
            preview.setDisabled(false);
+           this.lookupReference('raw').setDisabled(false);
+           this.lookupReference('spam').setDisabled(false);
            preview.update("<iframe frameborder=0 width=100% height=100% sandbox='allow-same-origin' src='" + url +"'></iframe>");
        },
 
+       multiSelect: function() {
+           var preview = this.lookupReference('preview');
+           var raw = this.lookupReference('raw');
+           var spam = this.lookupReference('spam');
+           var spaminfo = this.lookupReference('spaminfo');
+
+           preview.setDisabled(false);
+           preview.update('<h3>' + gettext('Multiple E-Mails selected') + '</h3>');
+           raw.setDisabled(true);
+           spam.setDisabled(true);
+           spam.setPressed(false);
+           spaminfo.setVisible(false);
+       },
+
        toggleRaw: function(button) {
            var me = this;
            var list = this.lookupReference('list');
@@ -83,6 +99,30 @@ Ext.define('PMG.SpamQuarantine', {
 
            var action = button.reference;
 
+           if (selected.length > 1) {
+               var idlist = [];
+               selected.forEach(function(item) {
+                   idlist.push(item.data.id);
+               });
+               Ext.Msg.confirm(
+                   gettext('Confirm'),
+                   Ext.String.format(
+                       gettext("Action '{0}' for '{1}' items"),
+                       action, selected.length
+                   ),
+                   function(button) {
+                       if (button !== 'yes') {
+                           return;
+                       }
+
+                       PMG.Utils.doQuarantineAction(action, idlist.join(';'), function() {
+                           list.getController().load();
+                       });
+                   }
+               );
+               return;
+           }
+
            PMG.Utils.doQuarantineAction(action, selected[0].data.id, function() {
                list.getController().load();
            });
@@ -91,6 +131,11 @@ Ext.define('PMG.SpamQuarantine', {
        onSelectMail: function() {
            var me = this;
            var list = this.lookupReference('list');
+           var selection = list.selModel.getSelection();
+           if (selection.length > 1) {
+               me.multiSelect();
+               return;
+           }
            var rec = list.selModel.getSelection()[0];
 
            me.updatePreview(me.raw || false, rec);
index 8a1d46f315391e3558da48eab69f0e35b576f67c..bd8ee8f4fa84433aef2115d55f97d25209fa1f91 100644 (file)
@@ -91,6 +91,7 @@ Ext.define('PMG.VirusQuarantine', {
        {
            title: gettext('Virus Quarantine'),
            xtype: 'pmgQuarantineList',
+           selModel: 'rowmodel',
            emptyText: gettext('No data in database'),
            emailSelection: false,
            reference: 'list',