changeset 169:d10a0e35b982

Fix: Allow to move entries to projects with similar names Use the same selection as in the project selection. This allows to select overlapping projects with keys like a, ab, abc.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 10 Dec 2012 09:33:40 +0100
parents 75fef53ebc36
children fa3f6cd394db
files getan/states.py
diffstat 1 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/getan/states.py	Thu Dec 06 15:50:58 2012 +0100
+++ b/getan/states.py	Mon Dec 10 09:33:40 2012 +0100
@@ -512,6 +512,19 @@
     def reset_project_footer(self):
         self.project_view.reset_footer()
 
+    def check_key(self, key):
+        return len(self.controller.find_projects_by_key(key))
+
+    def select_project(self):
+        proj = self.controller.project_by_key(self.proj_keys)
+        if proj:
+            self.proj = proj
+            self.reset_project_footer()
+            logger.debug("MoveEntryState: prepared entries to be " \
+                            "moved to project '%s'" % self.proj.desc)
+            self.view.set_footer_text(self.msg('really'), 'question')
+
+
     def keypress(self, key):
         keys = self.config.get_keybinding()
         if 'y' in key and self.proj:
@@ -540,16 +553,17 @@
                 self.set_project_footer()
             return self
 
+        if keys.get_enter() in key and self.proj is None:
+            self.select_project()
+
         if len(key) > 0 and len(key[0]) == 1 and self.proj is None:
-            self.proj_keys += key[0]
-            self.set_project_footer()
-            self.proj = self.controller.project_by_key(self.proj_keys)
-            if self.proj:
-                self.reset_project_footer()
-                logger.debug("MoveEntryState: prepared entries to be moved to "\
-                             "project '%s'" % self.proj.desc)
-                self.view.set_footer_text(self.msg('really'), 'question')
-
+            proj_key = self.proj_keys + key[0]
+            num = self.check_key(proj_key)
+            if num > 0:
+                self.proj_keys = proj_key
+                self.set_project_footer()
+                if num == 1:
+                    self.select_project()
         return self
 
 class CreateProjectState(HandleUserInputState):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)