ACK. I have some comments below.

On 3/9/2012 11:20 AM, Petr Vobornik wrote:
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

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
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) -
* save() would return array of formatted values

* 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.

We might need it in both field and widget. There are 3 different values that we need to consider:
 * stored value (LDAP), e.g. TRUE/FALSE
 * internal value (JavaScript), e.g. true/false
 * external value (human readable), e.g. True/False

The field will be responsible for converting between stored and internal value. The widget will be responsible for converting between internal & external value if needed.

Suppose we want to display a boolean attribute using a checkbox. We will need a boolean field which will convert TRUE/FALSE into true/false. Then we also need a standard checkbox that displays true as checked and false as unchecked.

Suppose we want to display the boolean attribute in a table column. We should be able to use the same boolean field, but then we use a boolean column that converts true/false into True/False.

Endi S. Dewata

Freeipa-devel mailing list

Reply via email to