changeset 439:3103429ec963

Makes 'move' operation more consistent. * Improves 'move' operation to work in the current entry, if there is no selection. This is more consistent with 'delete'. Patch by Frank Koormann. * Removes two superfluous methods in controller. * Improves README: Adds Frank Koormann as contributor. Better phrasing for the license indication. * TODO: Details problem with multi-selections.
author Bernhard Reiter <bernhard@intevation.de>
date Wed, 13 Sep 2017 09:06:28 +0200
parents d56fee6fd7ca
children f441913a5cdc
files CHANGES README TODO getan/controller.py getan/states.py
diffstat 5 files changed, 22 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Tue Sep 12 14:52:30 2017 +0200
+++ b/CHANGES	Wed Sep 13 09:06:28 2017 +0200
@@ -2,6 +2,9 @@
 
 TODO
 
+ * Improves 'move' operation to work in the current entry, if there is no
+   selection. This is more consistent with 'delete'. Patch by Frank Koormann.
+
  * Documentation: Adds description of the available tree mode.
 
 
--- a/README	Tue Sep 12 14:52:30 2017 +0200
+++ b/README	Wed Sep 13 09:06:28 2017 +0200
@@ -179,7 +179,7 @@
 
 CREDITS
 =======
-Getan is Free Software licensed under the terms of GPLv3 or later.
+Getan is Free Software licensed under the terms of GNU GPL v>=3.
 For details see LICENSE coming with the source of 'getan'.
 
 
@@ -193,6 +193,7 @@
 
 Contributions
 -------------
+Frank Koormann
 Stephan Holl
 Tom Gottfried
 
@@ -201,5 +202,4 @@
 To all users that gave feedback, especially at Intevation.
 
 
-
 .. vim: set ts=4 sw=4 tw=80 filetype=rst :
--- a/TODO	Tue Sep 12 14:52:30 2017 +0200
+++ b/TODO	Wed Sep 13 09:06:28 2017 +0200
@@ -8,7 +8,10 @@
   We could solve this requirement by making it configurable.
 
 20170317 BER: Reproduce and then fix a defect that it is surprising which
-  entries are moved by `m`. It happens when you have changed a lot of entries
+  entries are moved by `m` or deleted by 'd'.
+  It probably has to do how multi-selection are handled. Maybe they
+  are not cleared properly at the end of an operation.
+  One description: It happens when you have changed a lot of entries
   from different projects (I assume), e.g. by editing the description,
   the length or timedate and then use move where you intend to only move
   one, the unwanted result is several moved entries.
--- a/getan/controller.py	Tue Sep 12 14:52:30 2017 +0200
+++ b/getan/controller.py	Wed Sep 13 09:06:28 2017 +0200
@@ -73,28 +73,12 @@
         if self.view:
             self.view.update_entries(project.entries)
 
-    def move_entry(self, entry, project):
-        self.move_entries([entry], project)
-
     def move_entries(self, entries, project):
         old_project = self.project_by_id(entries[0].project_id)
         self.backend.move_entries(entries, project.id)
         self.update_entries(old_project)
         self.project_view.update_rows()
 
-    def move_selected_entries(self, project):
-        entries = []
-        while self.entries_view.selection:
-            node = self.entries_view.selection.pop()
-            if node.selected:
-                node.select()
-            entries.append(node.item)
-            logger.info("GetanController: move entry '%s' (id = %d, "
-                        "project id = %d) to project '%s'"
-                        % (node.item.desc, node.item.id,
-                            node.item.project_id, project.desc))
-        self.move_entries(entries, project)
-
     def delete_entries(self, entry_nodes):
         if not entry_nodes:
             return
--- a/getan/states.py	Tue Sep 12 14:52:30 2017 +0200
+++ b/getan/states.py	Wed Sep 13 09:06:28 2017 +0200
@@ -533,6 +533,11 @@
             if self.view.selection:
                 self.set_next_state(MoveEntryState(self.projectlist_state,
                                                    self.controller, self.view))
+            else:
+                entry = self.view.item_in_focus()
+                self.set_next_state(MoveEntryState(self.projectlist_state,
+                                                     self.controller,
+                                                     self.view, [entry]))
             return True
 
         if keys.get_entry_edit() in key:
@@ -608,11 +613,14 @@
 
     proj = None
 
-    def __init__(self, state, controller, view):
+    def __init__(self, state, controller, view, entries=None):
         super(MoveEntryState, self).__init__(state, controller, view)
         self.view.set_footer_text(self.msg('project'), 'question')
+        self.entries = entries
         self.proj_keys = ""
         self.project_view = controller.project_view
+        if not self.entries:
+            self.entries = [x.item for x in self.view.selection]
 
     def set_project_footer(self):
         self.project_view.set_footer_text("Selecting project from "
@@ -638,7 +646,7 @@
         keys = self.config.get_keybinding()
         if 'y' in key and self.proj:
             logger.debug("MoveEntryState: move selected entries.")
-            self.controller.move_selected_entries(self.proj)
+            self.controller.move_entries(self.entries, self.proj)
             self.renew_focus()
             self.view.set_footer_text('', 'entry_footer')
             self.proj = None
@@ -685,6 +693,9 @@
 
         return False
 
+    def set_focus(self):
+        self.controller.view.set_focus("entries")
+
 
 class AlterProjectState(HandleUserInputState):
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)