From 5fb0f71ea079d5011d4d4449f11a937771c234fd Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 28 Mar 2018 16:55:42 +0200 Subject: [PATCH] quarantine: do not deselect when list changes 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 --- 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.39.2