]> git.proxmox.com Git - pmg-gui.git/commitdiff
quarantine: do not deselect when list changes
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 28 Mar 2018 14:55:42 +0000 (16:55 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 29 Mar 2018 12:31:00 +0000 (14:31 +0200)
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@proxmox.com>
js/QuarantineList.js

index cd2ef3e97463df146cbcff2fa14b15174ecfcc2c..f5a7e11f54be195c0ef754f70f0a102b7caaafa7 100644 (file)
@@ -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: {