[pbs-devel] [PATCH proxmox-backup v4 2/5] ui: tape/TapeRestore: improve SnapshotGrid

Dominik Csapak d.csapak at proxmox.com
Fri May 21 12:20:19 CEST 2021


* handle not rendered call of getErrors
* return 'all' as value if all snaphots where selected
  (for better distinction)
* remove the default height
* add checkChange on stores filterChange
  (now change also fires on the gridfilter plugin change)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/tape/window/TapeRestore.js | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/www/tape/window/TapeRestore.js b/www/tape/window/TapeRestore.js
index 2a876619..10624f9a 100644
--- a/www/tape/window/TapeRestore.js
+++ b/www/tape/window/TapeRestore.js
@@ -336,6 +336,13 @@ Ext.define('PBS.TapeManagement.SnapshotGrid', {
 	    }
 	});
 
+	// getSource returns null if data is not filtered
+	let originalData = me.store.getData().getSource() || me.store.getData();
+
+	if (snapshots.length === originalData.length) {
+	    return "all";
+	}
+
 	return snapshots;
     },
 
@@ -347,20 +354,25 @@ Ext.define('PBS.TapeManagement.SnapshotGrid', {
 
     getErrors: function(value) {
 	let me = this;
-	if (me.getSelection() < 1) {
+	if (me.getSelection().length < 1) {
 	    me.addCls(['x-form-trigger-wrap-default', 'x-form-trigger-wrap-invalid']);
 	    let errorMsg = gettext("Need at least one snapshot");
-	    me.getActionEl().dom.setAttribute('data-errorqtip', errorMsg);
+	    let el = me.getActionEl();
+	    if (el) {
+		el.dom.setAttribute('data-errorqtip', errorMsg);
+	    }
 
 	    return [errorMsg];
 	}
 	me.removeCls(['x-form-trigger-wrap-default', 'x-form-trigger-wrap-invalid']);
-	me.getActionEl().dom.setAttribute('data-errorqtip', "");
+	let el = me.getActionEl();
+	if (el) {
+	    el.dom.setAttribute('data-errorqtip', "");
+	}
 	return [];
     },
 
     scrollable: true,
-    height: 350,
     plugins: 'gridfilters',
 
     viewConfig: {
@@ -424,5 +436,7 @@ Ext.define('PBS.TapeManagement.SnapshotGrid', {
 		},
 	    );
 	}
+
+	me.mon(me.store, 'filterchange', () => me.checkChange());
     },
 });
-- 
2.20.1






More information about the pbs-devel mailing list