changeset 473:b9e30e556844

Switch to projects when entries are empty. *update CHANGES
author Magnus Schieder <mschieder@intevation.de>
date Wed, 09 May 2018 15:13:36 +0200
parents ca6d11781e2f
children 0d831a9f547b
files CHANGES getan/states.py
diffstat 2 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Wed May 09 13:38:04 2018 +0200
+++ b/CHANGES	Wed May 09 15:13:36 2018 +0200
@@ -1,8 +1,13 @@
 2.x 20xx-xx-xx UNRELEASED
 
+ * Better fix for the multiple selection bug.
+   The multi-selection is deleted when deleting or moving is confirmed.
+
  * Better control of the walker.
    If you move entries and switch back to the projects you get to the project
    you were in. Before, you always got the first project.
+   If the entries are empty, the walker will automatically switches to the
+   projects.
    Patch by Magnus Schieder
 
  * Enhanced overview.
--- a/getan/states.py	Wed May 09 13:38:04 2018 +0200
+++ b/getan/states.py	Wed May 09 15:13:36 2018 +0200
@@ -493,11 +493,12 @@
     def renew_focus(self):
         e_len = self.view.row_count()
         if e_len == 0:
-            return
+            return False
         f = self.view.get_focus_pos()
         if f >= e_len:
             f = e_len - 1
         self.view.set_focus(f)
+        return True
 
     def set_focus(self):
         self.controller.view.set_focus("entries")
@@ -589,13 +590,18 @@
         if 'y' in key:
             if self.entries:
                 self.controller.delete_entries(self.entries)
-                self.renew_focus()
+                new_focus =  self.renew_focus()
                 self.projectlist_state.view.update_rows()
                 # Deletes the selection of entries
                 self.view.selection = []
             self.view.set_footer_text("", 'entry_footer')
             # avoid creating new DefaultEntryListState and setting focus
-            self.set_next_state(self.old_state)
+            if new_focus:
+                self.set_next_state(self.old_state)
+            else:
+                self.set_next_state(self.projectlist_state)
+                self.controller.view.set_focus(0)
+
             self.controller.project_view.show_total_time()
             return True
 
@@ -653,14 +659,19 @@
         if 'y' in key and self.proj:
             logger.debug("MoveEntryState: move selected entries.")
             self.controller.move_entries(self.entries, self.proj)
-            self.renew_focus()
+            new_focus =  self.renew_focus()
             # Deletes the selection of entries
             self.view.selection = []
             self.view.set_footer_text('', 'entry_footer')
             self.proj = None
-            self.set_next_state(DefaultEntryListState(self.projectlist_state,
-                                                      self.controller,
-                                                      self.view))
+            if new_focus:
+                self.set_next_state(DefaultEntryListState(self.projectlist_state,
+                                                          self.controller,
+                                                          self.view))
+            else:
+                self.set_next_state(self.projectlist_state)
+                self.controller.view.set_focus(0)
+
             return True
 
         if 'n' in key and self.proj:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)