From 3b028edc68c67297f303f4f5cc731edd5346e6d2 Mon Sep 17 00:00:00 2001
From: Thomas Bernard <thomas@nexedi.com>
Date: Tue, 13 Jun 2006 15:25:12 +0000
Subject: [PATCH] special functions added to handle new PlanningBox. This
 includes setZoom(), setZoomLevel(), nextZoom(), previousZoom().

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7708 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/SelectionTool.py | 67 ++++++++++++++++++++++++++++---
 1 file changed, 62 insertions(+), 5 deletions(-)

diff --git a/product/ERP5Form/SelectionTool.py b/product/ERP5Form/SelectionTool.py
index 1f0cc2efa2..d9c831d496 100644
--- a/product/ERP5Form/SelectionTool.py
+++ b/product/ERP5Form/SelectionTool.py
@@ -565,22 +565,79 @@ class SelectionTool( UniqueObject, SimpleItem ):
       return self.checkAll(selection_name, uids, REQUEST=REQUEST, query_string=query_string)
 
 
+    # PlanningBox related methods
+    security.declareProtected(ERP5Permissions.View, 'setZoomLevel')
+    def setZoomLevel(self, uids=None, REQUEST=None):
+      """
+      Set graphic zoom level in PlanningBox
+      """
+      if uids is None: uids = []
+      request = REQUEST
+      #zoom_level=request.get('zoom_level')
+      selection_name=request.list_selection_name
+      selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
+      if selection is not None:
+        params = selection.getParams()
+        zoom_level = request.form.get('zoom_level',1)
+        zoom_start = request.form.get('zoom_start',0)
+        params['zoom_level'] = zoom_level
+        if zoom_level <= zoom_start:
+          zoom_start = max(int(float(zoom_level)),1) - 1
+          params['zoom_start'] = zoom_start
+        selection.edit(params= params)
+      if REQUEST is not None:
+        return self._redirectToOriginalForm(REQUEST=REQUEST)
+
     security.declareProtected(ERP5Permissions.View, 'setZoom')
-    def setZoom(self, uids=None, REQUEST=None, form_id=None, query_string=None):
+    def setZoom(self, uids=None, REQUEST=None):
       """
       Set graphic zoom in PlanningBox
       """
       if uids is None: uids = []
-      zoom=REQUEST.get('zoom')
+      request = REQUEST
       selection_name=request.list_selection_name
       selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
       if selection is not None:
         params = selection.getParams()
-        params['zoom'] = zoom
+        zoom_start = request.form.get('zoom_start')
+        params['zoom_start'] = zoom_start
         selection.edit(params= params)
       if REQUEST is not None:
-        return self._redirectToOriginalForm(REQUEST=REQUEST, form_id=form_id,
-                                            query_string=query_string)
+        return self._redirectToOriginalForm(REQUEST=REQUEST)
+
+    security.declareProtected(ERP5Permissions.View, 'nextZoom')
+    def nextZoom(self, uids=None, REQUEST=None):
+      """
+      Set next graphic zoom start in PlanningBox
+      """
+      if uids is None: uids = []
+      request = REQUEST
+      selection_name=request.list_selection_name
+      selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
+      if selection is not None:
+        params = selection.getParams()
+        zoom_start = params.get('zoom_start')
+        params['zoom_start'] = int(zoom_start) + 1
+        selection.edit(params= params)
+      if REQUEST is not None:
+        return self._redirectToOriginalForm(REQUEST=REQUEST)
+
+    security.declareProtected(ERP5Permissions.View, 'previousZoom')
+    def previousZoom(self, uids=None, REQUEST=None):
+      """
+      Set previous graphic zoom in PlanningBox
+      """
+      if uids is None: uids = []
+      request = REQUEST
+      selection_name=request.list_selection_name
+      selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
+      if selection is not None:
+        params = selection.getParams()
+        zoom_start = params.get('zoom_start')
+        params['zoom_start'] = int(zoom_start) - 1
+        selection.edit(params= params)
+      if REQUEST is not None:
+        return self._redirectToOriginalForm(REQUEST=REQUEST)
 
     security.declareProtected(ERP5Permissions.View, 'setDomainRoot')
     def setDomainRoot(self, REQUEST, form_id=None, query_string=None):
-- 
2.30.9