[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8572 - in branches/forms-0.5/src: . GFObjects input/displayHandl
From: |
johannes |
Subject: |
[gnue] r8572 - in branches/forms-0.5/src: . GFObjects input/displayHandlers |
Date: |
Fri, 18 Aug 2006 06:30:30 -0500 (CDT) |
Author: johannes
Date: 2006-08-18 06:30:29 -0500 (Fri, 18 Aug 2006)
New Revision: 8572
Modified:
branches/forms-0.5/src/GFForm.py
branches/forms-0.5/src/GFObjects/GFBlock.py
branches/forms-0.5/src/GFObjects/GFField.py
branches/forms-0.5/src/GFParser.py
branches/forms-0.5/src/input/displayHandlers/Dropdown.py
Log:
After entering query mode add the options '(all)' and '(empty)' to the
dropdowns. This way one can query for empty (=NULL) values in
dropdowns.
Modified: branches/forms-0.5/src/GFForm.py
===================================================================
--- branches/forms-0.5/src/GFForm.py 2006-08-18 08:38:38 UTC (rev 8571)
+++ branches/forms-0.5/src/GFForm.py 2006-08-18 11:30:29 UTC (rev 8572)
@@ -575,6 +575,9 @@
for block in self._logic._blockList:
block.processRollback()
for entry in block._entryList:
+ if getattr(entry, 'style', 'default') == 'dropdown':
+ entry._field.add_query_values()
+
if hasattr(entry, 'queryDefault'):
assert gDebug (5, "%s will be set to %s" % (entry.name,
entry.queryDefault))
entry.setValue(entry.queryDefault)
@@ -605,12 +608,18 @@
#self._instance.dispatchEvent('endENTERQUERY', _form=self)
message = None #TODO: not used here and in return line /kilo/
for block in self._logic._blockList:
+ self.__end_query_mode(block)
block.cancelQuery()
self.triggerSetStatusText(_('Query canceled.'))
return message
+ def __end_query_mode(self, block):
+ for entry in block._entryList:
+ if getattr(entry, 'style', 'default') == 'dropdown':
+ entry._field.remove_query_values()
+
#---------------------------------------------------------------------------
# Copy Query, ie bring back conditions from the last query
#---------------------------------------------------------------------------
@@ -626,6 +635,7 @@
#self._instance.dispatchEvent('endENTERQUERY', _form=self);
message = None #TODO: not used here and in return line /kilo/
for block in self._logic._blockList:
+ self.__end_query_mode(block)
block.copyQuery()
return message
@@ -657,6 +667,9 @@
'exMessage': sys.exc_info ()[1]}
finally:
+ for block in self._logic._blockList:
+ self.__end_query_mode(block)
+
self.dispatchEvent ('endWAIT', _form = self)
self.refreshDisplay (self._currentBlock)
Modified: branches/forms-0.5/src/GFObjects/GFBlock.py
===================================================================
--- branches/forms-0.5/src/GFObjects/GFBlock.py 2006-08-18 08:38:38 UTC (rev
8571)
+++ branches/forms-0.5/src/GFObjects/GFBlock.py 2006-08-18 11:30:29 UTC (rev
8572)
@@ -990,11 +990,15 @@
pass
val = cond_value(val)
-
- if (val.find ('%') >= 0 or val.find ('_') >= 0):
- condLike [entry] = val
+
+ # a Null-Character means a dropdown with '(empty)' selected
+ if val == chr(0):
+ conditions.append(['null', ['field', entry.field]])
else:
- condEq [entry] = val
+ if (val.find ('%') >= 0 or val.find ('_') >= 0):
+ condLike [entry] = val
+ else:
+ condEq [entry] = val
else:
condEq [entry] = val
Modified: branches/forms-0.5/src/GFObjects/GFField.py
===================================================================
--- branches/forms-0.5/src/GFObjects/GFField.py 2006-08-18 08:38:38 UTC (rev
8571)
+++ branches/forms-0.5/src/GFObjects/GFField.py 2006-08-18 11:30:29 UTC (rev
8572)
@@ -463,7 +463,39 @@
self.__loadAllowedValues(resultSet)
pass
+ # ---------------------------------------------------------------------------
+ # Add (all) and (empty) to the list of allowed values
+ # ---------------------------------------------------------------------------
+ def add_query_values(self):
+ """
+ Add the options '(all)' and '(empty)' to the list of allowed values.
+ """
+ all = u_('(all)')
+ empty = u_('(empty)')
+
+ self.resetForeignKey(self.__fk_resultSet)
+
+ self._allowedValues[""] = all
+ self._allowedValuesDescr[0] = all
+ self._allowedValuesReverse[all] = ""
+
+ if "" in self._allowedValuesReverse:
+ del self._allowedValuesReverse[""]
+
+ if not empty in self._allowedValuesDescr:
+ self._allowedValuesDescr.insert(1, empty)
+ self._allowedValues[chr(0)] = empty
+ self._allowedValuesReverse[empty] = chr(0)
+
+
+ def remove_query_values(self):
+ """
+ Remove the options '(all)' and '(empty)' from the list of allowed values.
+ """
+ self.resetForeignKey(self.__fk_resultSet)
+
+
# This gets called by the block whenever the current record of our own
# resultset changes. We want the fk resultset to follow.
def gotNewCurrentRecord (self):
Modified: branches/forms-0.5/src/GFParser.py
===================================================================
--- branches/forms-0.5/src/GFParser.py 2006-08-18 08:38:38 UTC (rev 8571)
+++ branches/forms-0.5/src/GFParser.py 2006-08-18 11:30:29 UTC (rev 8572)
@@ -392,6 +392,7 @@
'Typecast': GTypecast.name,
'Label': _('Data Type'),
'ValueSet': {
+ 'boolean': {'Label': _('Boolean')},
'text': {'Label': _('Text')},
'number': {'Label': _('Numeric')},
'date': {'Label': _('Date/Time')} },
Modified: branches/forms-0.5/src/input/displayHandlers/Dropdown.py
===================================================================
--- branches/forms-0.5/src/input/displayHandlers/Dropdown.py 2006-08-18
08:38:38 UTC (rev 8571)
+++ branches/forms-0.5/src/input/displayHandlers/Dropdown.py 2006-08-18
11:30:29 UTC (rev 8572)
@@ -82,6 +82,11 @@
# TODO: Replace with format mask
def _buildDisplayHelper(self, value, editing):
if value in (None, ""):
+ # if we're in query-mode, make sure to get (all) for ''
+ if self.field._block.mode == 'query' and \
+ value in self.field._allowedValues:
+ return self.field._allowedValues[value]
+
return ""
if editing:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8572 - in branches/forms-0.5/src: . GFObjects input/displayHandlers,
johannes <=