Changeset 1924
- Timestamp:
- 2011-08-04 13:52:13 (10 months ago)
- Location:
- trunk/modules/kauri-forms
- Files:
-
- 1 added
- 3 edited
-
kauri-forms-extra/src/main/kauri/static/radioselection/js/radioselection.js (modified) (3 diffs)
-
kauri-forms-framework/src/test/kauri.forms/test-basic-controls.js (modified) (1 diff)
-
kauri-forms-framework/src/test/kauri.forms/test-radioselection.js (added)
-
kauri-forms-framework/src/test/kauri.forms/testPage.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/radioselection/js/radioselection.js
r1920 r1924 112 112 var $radioControlDiv = this.getElement(); 113 113 114 var $checkedRadioButton = $radioControlDiv.find("input[ checked]");114 var $checkedRadioButton = $radioControlDiv.find("input[type='radio']:checked"); //input[checked] 115 115 return $checkedRadioButton.val(); 116 116 } … … 134 134 135 135 // clear options from list that are not available 136 value = trimToOptions(value, values);136 value = this.options.trimValues(value); 137 137 138 138 if (value === undefined // if no matches left after trim … … 144 144 return value; 145 145 } 146 147 function trimToOptions(val, values) {148 149 if (val === undefined || values === undefined) return undefined;150 if (val.constructor != Array) {151 var wrapped = trimToOptions([val], values); //wrap152 return (wrapped != undefined) ? wrapped[0] : undefined; // unwrapped153 }154 155 var result = [];156 for (var i = 0; i< val.length; i++) {157 var testval = val[i];158 if ($.valueInArray(testval, values) >= 0) {159 result[result.length] = testval;160 }161 }162 return (result.length == 0 ) ? undefined : result;163 }164 146 165 147 -
trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-basic-controls.js
r1918 r1924 301 301 }); 302 302 303 test("selection-control", function() { 304 305 // create 306 var $main = $('#main').show(); 307 var $form = $('<form />').appendTo($main); 308 309 var id = "selection1"; 310 var fconf = { "members": {}}; 311 fconf.members[id] = { 312 "base": "string", 313 "label": "Number select", 314 "control": { 315 "base": "selection-control", 316 "options": { 317 "data": [{name:"one",id:1}, {name:"two",id:2}, {name:"three",id:3}], 318 "valueTemplate": "{id}", 319 "labelTemplate": "{name}" 320 } 321 } 322 }; 323 324 var form = new $.org.kauriproject.forms.Form($form, fconf); 325 326 327 expect(8); 328 329 330 // verify creation of control 331 var c = form.findControl(id); 332 ok(c != null, "control creation passed"); 333 ok(c.getForm() == form, "control form ok"); 334 equal(c.getId(), id, "control id checked"); 335 336 // verify creation of control elements 337 var $input = $('select[kauri-idref*="'+id+'"]', $form); 338 var $messages = $("span[kauri-idref*='"+id+"']", $form); 339 $messages.html("text that should get cleared upon validation"); 340 sameJq(c.getElement(), $input, "input element found and indexed."); 341 sameJq(c.getElement('messages'), $messages, "messages element found and indexed.") 342 343 equal(c.getValue(), 1, "initial value should be the first"); 344 345 // verify setting some value 346 c.setValue(3); 347 equal(c.getValue(), 3, "setValue should trigger a change of value"); 348 349 c.setWireValue(2); 350 equal(c.getValue(), 2, "setWireValue should trigger a change of value"); 351 352 // cleanup 353 $main.html("").hide(); 354 355 }); 356 303 357 304 358 test("trimmed selection-control stringvalues", function() { -
trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/testPage.html
r1899 r1924 47 47 <script type="text/javascript" src="../../main/kauri/static-{build}.key/kauri.forms/date.js" ></script> 48 48 <script type="text/javascript" src="../../main/kauri/static-{build}.key/kauri.forms/numeric-range.js" ></script> 49 <script type="text/javascript" src="../../../../kauri-forms-extra/src/main/kauri/static/radioselection/js/radioselection.js" ></script> 49 50 <!-- 50 51 <script type="text/javascript" src="../../main/kauri/static/js/location.js" ></script> … … 86 87 <script type="text/javascript" src="test-date.js" ></script> 87 88 <script type="text/javascript" src="test-numeric-range.js" ></script> 89 <script type="text/javascript" src="test-radioselection.js" ></script> 88 90 89 91 <!-- Haven't found a way to test the control since the page has to be completly loaded to be able to load the maps api
Note: See TracChangeset
for help on using the changeset viewer.