]> git.proxmox.com Git - pmg-gui.git/commitdiff
QuarantineList: improve savedPosition behaviour
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 15 Apr 2020 07:56:44 +0000 (09:56 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 15 Apr 2020 12:07:46 +0000 (14:07 +0200)
by not saving the position across time or email changes, since that
makes no real sense. (The user cannot really know what will be selected,
in contrast to when the mails will be deleted etc.)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
js/QuarantineList.js

index 25749ab6940ce6958878520fa3e3b563c5ffda3e..57f1a6ef2f04d4ff9784be4eebd386158c377275 100644 (file)
@@ -18,6 +18,8 @@ Ext.define('PMG.QuarantineList', {
        to: 0
     },
 
+    allowPositionSave: false,
+
     controller: {
        xclass: 'Ext.app.ViewController',
 
@@ -67,6 +69,7 @@ Ext.define('PMG.QuarantineList', {
 
        load: function(callback) {
            var me = this;
+           me.allowPositionSave = false;
            var view = me.getView();
            var store = view.getStore();
            if (view.emailSelection) {
@@ -82,10 +85,13 @@ Ext.define('PMG.QuarantineList', {
                        me.savedPosition = store.getCount() - 1;
                    }
                    view.setSelection(store.getAt(me.savedPosition));
+               } else {
+                   view.setSelection();
                }
                if (Ext.isFunction(callback)) {
                    callback();
                }
+               me.allowPositionSave = true;
            });
        },
 
@@ -118,6 +124,9 @@ Ext.define('PMG.QuarantineList', {
            var me = this;
            var list = me.getView();
 
+           me.allowPositionSave = false;
+           me.savedPosition = undefined;
+
            if (!value) {
                return;
            }
@@ -158,18 +167,23 @@ Ext.define('PMG.QuarantineList', {
 
        changeEmail: function(tb, value) {
            var me = this;
+           me.savedPosition = undefined;
+           me.allowPositionSave = false;
            me.setUser(value);
            me.load();
        },
 
        savePosition: function(grid, selected, eopts) {
+           let me = this;
+           if (!me.allowPositionSave) {
+               return;
+           }
            if (!selected.length) {
+               me.savedPosition = undefined;
                return;
            }
 
-           var me = this;
            var view = me.getView();
-
            var id = view.getStore().indexOf(selected[0]);
 
            me.savedPosition = id;