]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: bulk actions: add clear filters button
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 9 Nov 2023 10:48:00 +0000 (11:48 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 9 Nov 2023 11:10:48 +0000 (12:10 +0100)
to be able to clear all of them at once

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/window/BulkAction.js

index 1ffc7538c835c0f5f3260050580379ce419c08ed..5f76ef7a43f64f070e13a20867c6d881f54083be 100644 (file)
@@ -174,6 +174,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;
@@ -210,10 +217,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) {
@@ -398,6 +408,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,
+                               },
+                           ],
+                       },
                    ],
                },
            ],