[Freeipa-devel] [PATCH] 107 Fixed evaluating checkbox dirty status

Petr Vobornik pvoborni at redhat.com
Fri Mar 9 17:20:19 UTC 2012


Problem:
When value in checkbox is modified twice in a row (so it is at its 
original value) an 'undo' button is still visible even when it shouldn't be.

Cause:
IPA server sends boolean values as 'TRUE' or 'FALSE' (strings). 
Checkbox_widget converts them to JavaScript? boolean (true, false). Save 
method in checkbox_widget is returning array with a boolean. So 
test_dirty method always evaluates to dirty because 'FALSE' != false.

This patch is fixing the problem.

Note (future enhancements):
As we were talking before about making fields less dependent on widget 
types. The dependency comes from the fact that dirty evaluation is in 
field. I plan to move the core to widget. I'm thinking about something 
like:
Widget would have:
   * input value parser - ie for parsing strings to booleans - configurable
   * original value (parsed)
   * inner state (inner_save())
   * is_dirty() - compare inner state with original value
   * output formatter - can make boolean back to strings (just example) 
- configurable
   * save() would return array of formatted values

Field:
   * load(record) would pick values from record as now
   * is_dirty - needed for facets. Would be: dirty = 'one of associated 
widgets is dirty'
   * save() - merge associated widgets values - usually only on array 
from one widget

Maybe input and output formatters should be in field.

https://fedorahosted.org/freeipa/ticket/2494
-- 
Petr Vobornik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-pvoborni-0107-Fixed-evaluating-checkbox-dirty-status.patch
Type: text/x-patch
Size: 4145 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20120309/045a60be/attachment.bin>


More information about the Freeipa-devel mailing list