]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/AttachmentGrid.js
mail-proxy-relaying: format function arguments
[pmg-gui.git] / js / AttachmentGrid.js
index eaac638f7fe9e8af30d7a1a90f4b4f6aa23be20c..746812d6e02b43c09951a18bd98d21e222d1fbb0 100644 (file)
@@ -15,12 +15,37 @@ Ext.define('PMG.grid.AttachmentGrid', {
     collapsible: true,
     titleCollapse: true,
 
+    tbar: [
+       '->',
+       {
+           xtype: 'checkbox',
+           boxLabel: gettext('Show All Parts'),
+           boxLabelAlgign: 'before',
+           listeners: {
+               change: function(checkBox, value) {
+                   let store = this.up('pmgAttachmentGrid').getStore();
+                   store.clearFilter();
+                   if (!value) {
+                       store.filter({
+                           property: 'content-disposition',
+                           value: 'attachment',
+                       });
+                   }
+               },
+           },
+       },
+    ],
+
     store: {
        autoDestroy: true,
-       fields: ['name', 'content-type', 'size'],
+       fields: ['name', 'content-type', 'size', 'content-disposition'],
        proxy: {
            type: 'proxmox',
        },
+       filters: {
+           property: 'content-disposition',
+           value: 'attachment',
+       },
     },
 
     controller: {
@@ -35,8 +60,9 @@ Ext.define('PMG.grid.AttachmentGrid', {
                view.updateTitleStats(-1);
                return;
            }
-           let totalSize = records.reduce((sum, { data }) => sum + data.size, 0);
-           view.updateTitleStats(records.length, totalSize);
+           let attachments = records.filter(({ data }) => data['content-disposition'] === 'attachment');
+           let totalSize = attachments.reduce((sum, { data }) => sum + data.size, 0);
+           view.updateTitleStats(attachments.length, totalSize);
        },
     },
 
@@ -44,7 +70,7 @@ Ext.define('PMG.grid.AttachmentGrid', {
        let me = this;
        let title;
        if (count > 0) {
-           title = Ext.String.format(gettext('{0} Attachements'), count);
+           title = Ext.String.format(gettext('{0} Attachments'), count);
            title += ` (${Proxmox.Utils.format_size(totalSize)})`;
            if (me.collapsible) {
                me.expand();