Author: johannes
Date: 2007-06-04 08:16:59 -0500 (Mon, 04 Jun 2007)
New Revision: 9652
Modified:
trunk/gnue-forms/src/GFObjects/GFBlock.py
trunk/gnue-forms/src/GFObjects/GFField.py
Log:
Added (all) and (empty) choices to lookup style entries
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2007-06-04 12:51:21 UTC (rev 9651)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2007-06-04 13:16:59 UTC (rev 9652)
@@ -530,6 +530,7 @@
self.__query_values = {}
self.__query_values.update(self._queryDefaults)
self.__current_record_changed(True)
+ self.__refresh_choices()
if self._form.get_focus_block() is self:
self.__update_record_status()
@@ -549,6 +550,7 @@
self.__query_values = {}
self.__query_values.update(self.__last_query_values)
self.__current_record_changed(True)
+ self.__refresh_choices()
if self._form.get_focus_block() is self:
self.__update_record_status()
@@ -565,6 +567,7 @@
self.mode = 'normal'
self.__current_record_changed(True)
+ self.__refresh_choices()
# -------------------------------------------------------------------------
@@ -582,6 +585,7 @@
if self.__get_master_block() is None:
# Condition for the master block
conditions = self.__generate_condition_tree()
+ self.__refresh_choices()
self.__in_query = True
try:
@@ -1374,6 +1378,16 @@
# -------------------------------------------------------------------------
+ # Update the list of choices in all fields of the block
+ # -------------------------------------------------------------------------
+
+ def __refresh_choices(self):
+
+ for field in self._fieldMap.itervalues():
+ field.refresh_choices()
+
+
+ # -------------------------------------------------------------------------
# Things that have to be done if a new current record is activated
# -------------------------------------------------------------------------
@@ -1532,11 +1546,16 @@
pass
val = cond_value(val)
+ # a Null-Character means a dropdown with '(empty)'
+ # selected.
+ if val == chr(0):
+ conditions.append(['null', ['field', entry.field]])
- if (val.find('%') >= 0 or val.find('_') >= 0):
- condLike[entry] = val
else:
- condEq[entry] = val
+ if (val.find('%') >= 0 or val.find('_') >= 0):
+ condLike[entry] = val
+ else:
+ condEq[entry] = val
else:
condEq[entry] = val
Modified: trunk/gnue-forms/src/GFObjects/GFField.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFField.py 2007-06-04 12:51:21 UTC (rev 9651)
+++ trunk/gnue-forms/src/GFObjects/GFField.py 2007-06-04 13:16:59 UTC (rev 9652)
@@ -313,6 +313,10 @@
if value is None:
return None
+ elif self._block.mode == 'query' and value.lower() == u_('(all)'):
+ return ''
+ elif self._block.mode == 'query' and value.lower() == u_('(empty)'):
+ return chr(0)
elif isinstance(value, datatypes.InvalidValueType):
return value
elif value in self.__lookup_dict_reverse:
@@ -336,6 +340,11 @@
db_value = self.__get_value(offset)
+ if self._block.mode == 'query' and db_value == chr(0):
+ return u_('(empty)')
+ elif self._block.mode == 'query' and db_value in ['', None]:
+ return u_('(all)')
+
if self.__lookup_dict is None or db_value is None:
return None
elif db_value in self.__lookup_dict:
@@ -629,11 +638,27 @@
def __refresh_ui_choices(self):
+ if self._block.mode == 'query':
+ lookup = ['(all)', '(empty)'] + self.__lookup_list
+ lookup.remove('')
+ else:
+ lookup = self.__lookup_list
+
for entry in self._entryList:
- entry.refresh_ui_choices(self.__lookup_list)
+ entry.refresh_ui_choices(lookup)
# -------------------------------------------------------------------------
+ # Update the list of choices for all bound entries
+ # -------------------------------------------------------------------------
+
+ def refresh_choices(self):
+
+ if self.__is_lookup:
+ self.__refresh_ui_choices()
+
+
+ # -------------------------------------------------------------------------
# Trigger functions
# -------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.