diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-02-02 16:18:35 -0600 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-02-03 20:09:15 -0500 |
commit | bd493d47a736fab4e74efbe9b603dcc8f1986512 (patch) | |
tree | 00f21fb46a747c8ef3219773b2d669c9b1d76f7f /install/ui/test/widget_tests.js | |
parent | ff646ec3a428647cac8fa9304a5695c7f29456a2 (diff) | |
download | freeipa-bd493d47a736fab4e74efbe9b603dcc8f1986512.tar.gz freeipa-bd493d47a736fab4e74efbe9b603dcc8f1986512.tar.xz freeipa-bd493d47a736fab4e74efbe9b603dcc8f1986512.zip |
Added multi-valued text widget.
A multi-valued text widget has been created to replace the old
IPA.details_field. The old code was designed to handle all data
types, and it uses one <dd> tag for each value, so the code is
still incomplete and complex. The new code was designed to handle
only multi-valued text attributes, and it uses one <dd> tag for
all values, so it's easier to maintain. There are already other
widgets that can be used to handle other data types.
The new code supports line-level undo and line-out for removal
like the old code, but there are some changes:
- Undoing a newly added line will remove the entire line.
- Editing the value of a removed line will cancel the removal.
- It provides 'undo all' link to reset the entire attribute.
The old code will be cleaned up in a subsequent patch.
Diffstat (limited to 'install/ui/test/widget_tests.js')
-rw-r--r-- | install/ui/test/widget_tests.js | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/install/ui/test/widget_tests.js b/install/ui/test/widget_tests.js index 3d827cdb8..f4281e38f 100644 --- a/install/ui/test/widget_tests.js +++ b/install/ui/test/widget_tests.js @@ -67,7 +67,7 @@ function base_widget_test(widget,entity_name, value){ } -function widget_string_test(widget, value){ +function widget_string_test(widget) { var value = 'test_title'; var mock_record = {'title': value}; @@ -117,6 +117,31 @@ function text_tests(widget,input){ } +function multivalued_text_tests(widget) { + + var values = ['val1', 'val2', 'val3']; + + var record = {}; + record[widget.name] = values; + + widget.load(record); + + same(widget.save(), values, "All values loaded"); + same(widget.is_dirty(), false, "Field initially clean"); + + values = ['val1', 'val2', 'val3', 'val4']; + widget.add_row('val4'); + + same(widget.save(), values, "Value added"); + same(widget.is_dirty(), true, "Field is dirty"); + + values = ['val1', 'val3', 'val4']; + widget.remove_row(1); + + same(widget.save(), values, "Value removed"); + same(widget.is_dirty(), true, "Field is dirty"); +} + test("IPA.table_widget" ,function(){ var widget = IPA.table_widget({undo:true,name:'users'}); @@ -191,6 +216,13 @@ test("Testing text widget.", function() { }); +test("Testing multi-valued text widget.", function() { + var widget = IPA.multivalued_text_widget({undo:true,name:'title'}); + base_widget_test(widget,'user','test_value'); + widget_string_test(widget); + multivalued_text_tests(widget); +}); + test("Testing checkbox widget.", function() { var widget = IPA.checkbox_widget({name:'title'}); base_widget_test(widget,'user','test_value'); |