[pmg-devel] [PATCH pmg-gui 1/4] quarantine: do not deselect when list changes

Dominik Csapak d.csapak at proxmox.com
Wed Mar 28 16:55:42 CEST 2018


when an e-mail is selected and an action goes through,
select the e-mail on the position the old one was,
this way, one does not have to reselect an e-mail after
an action is done

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 js/QuarantineList.js | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/js/QuarantineList.js b/js/QuarantineList.js
index cd2ef3e..f5a7e11 100644
--- a/js/QuarantineList.js
+++ b/js/QuarantineList.js
@@ -72,6 +72,7 @@ Ext.define('PMG.QuarantineList', {
 	load: function(callback) {
 	    var me = this;
 	    var view = me.getView();
+	    var store = view.getStore();
 	    if (view.emailSelection) {
 		if (!me.lookupReference('email').getSelection()) {
 		    // if the combobox has no selection we do not reload
@@ -79,7 +80,17 @@ Ext.define('PMG.QuarantineList', {
 		}
 		me.setEmptyText();
 	    }
-	    view.getStore().load(callback);
+	    store.load(function() {
+		if (me.savedPosition !== undefined) {
+		    if (store.getCount() - 1 < me.savedPosition) {
+			me.savedPosition = store.getCount() - 1;
+		    }
+		    view.setSelection(store.getAt(me.savedPosition));
+		}
+		if (Ext.isFunction(callback)) {
+		    callback();
+		}
+	    });
 	},
 
 	setFrom: function(from) {
@@ -161,9 +172,25 @@ Ext.define('PMG.QuarantineList', {
 	    this.lookupReference('email').queryCaching = true;
 	},
 
+
+	savePosition: function(grid, selected, eopts) {
+	    if (!selected.length) {
+		return;
+	    }
+
+	    var me = this;
+	    var view = me.getView();
+
+	    var id = view.getStore().indexOf(selected[0]);
+
+	    me.savedPosition = id;
+	},
+
+
 	control: {
 	    '#':{
-		beforedestroy: 'resetEmail'
+		beforedestroy: 'resetEmail',
+		selectionchange: 'savePosition'
 	    },
 	    'combobox[reference=email]': {
 		change: {
-- 
2.11.0




More information about the pmg-devel mailing list