to be able to clear all of them at once

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
sending this as a separate patch since i'm not sure if the button is
worth it. if deemed appropriate could also be squashed into the previous
patch
 www/manager6/window/BulkAction.js | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/www/manager6/window/BulkAction.js 
b/www/manager6/window/BulkAction.js
index 333d5d30..44171390 100644
--- a/www/manager6/window/BulkAction.js
+++ b/www/manager6/window/BulkAction.js
@@ -162,6 +162,13 @@ Ext.define('PVE.window.BulkAction', {
        let tagList = Object.keys(tagMap).map(key => ({ value: key }));
        let haList = Object.keys(haMap).map(key => [key, key]);
 
+       let clearFilters = function() {
+           me.down('#namefilter').setValue('');
+           ['name', 'status', 'pool', 'type', 'hastate', 'includetag', 
'excludetag', 'vmid'].forEach((filter) => {
+               me.down(`#${filter}filter`).setValue('');
+           });
+       };
+
        let filterChange = function() {
            let nameValue = me.down('#namefilter').getValue();
            let filterCount = 0;
@@ -192,10 +199,13 @@ Ext.define('PVE.window.BulkAction', {
            }
 
            let fieldSet = me.down('#filters');
+           let clearBtn = me.down('#clearBtn');
            if (filterCount) {
                fieldSet.setTitle(Ext.String.format(gettext('Filters ({0})'), 
filterCount));
+               clearBtn.setDisabled(false);
            } else {
                fieldSet.setTitle(gettext('Filters'));
+               clearBtn.setDisabled(true);
            }
 
            let filterFn = function(value) {
@@ -383,6 +393,22 @@ Ext.define('PVE.window.BulkAction', {
                                change: filterChange,
                            },
                        },
+                       {
+                           xtype: 'container',
+                           layout: {
+                               type: 'vbox',
+                               align: 'end',
+                           },
+                           items: [
+                               {
+                                   xtype: 'button',
+                                   itemId: 'clearBtn',
+                                   text: gettext('Clear Filters'),
+                                   disabled: true,
+                                   handler: clearFilters,
+                               },
+                           ],
+                       },
                    ],
                },
            ],
-- 
2.39.2


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to