Changeset 1869


Ignore:
Timestamp:
2011-02-24 10:27:55 (15 months ago)
Author:
mpo
Message:

fixes #448 (and adds the tests)
We need to propagate hide and show methods to children of containers to make sure all spread out elements are hidden/shown correctly.

Location:
trunk/modules/kauri-forms/kauri-forms-framework/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/control.js

    r1866 r1869  
    21352135     
    21362136     
    2137      
     2137    AbstractContainerControl.prototype.hide = function(){ 
     2138        this.eachChild(function(i, child){ child.hide();}); 
     2139        this['<super.call>']('hide'); 
     2140    } 
     2141     
     2142    AbstractContainerControl.prototype.show = function(){ 
     2143        this.eachChild(function(i, child){ child.show();}); 
     2144        this['<super.call>']('show'); 
     2145    } 
     2146 
    21382147    AbstractContainerControl.prototype.disable = function() { 
    2139         this.eachChild(AbstractContainerControl.childDisabler); 
     2148        this.eachChild(function(i, child){ child.disable();}); 
    21402149        this['<super.call>']('disable'); 
    21412150    }; 
    2142     AbstractContainerControl.childDisabler = function(i, child){ 
    2143         child.disable(); 
    2144     };  
    21452151     
    21462152    AbstractContainerControl.prototype.enable = function() { 
    2147         this.eachChild(AbstractContainerControl.childEnabler); 
     2153        this.eachChild(function(i, child){ child.enable();}); 
    21482154        this['<super.call>']('enable'); 
    2149     }; 
    2150     AbstractContainerControl.childEnabler = function(i, child){ 
    2151         child.enable(); 
    21522155    }; 
    21532156     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-case.js

    r1865 r1869  
    99    var id = "tcase"; 
    1010    var fconf = { "members": {}}; 
    11     fconf.members[id] = { 
    12         base : 'case',  
     11    fconf.members[id] = { base : 'case',  
    1312        cases : { 
    1413            "c1" : 'integer', 
    15             "c2" : 'boolean' 
     14            "c2" : 'boolean',  
     15            "c3" : { base: 'composite', 
     16                members: { "a": "string", "b": "string" } 
     17            } 
    1618        } 
    1719    }; 
     
    2729    var $c1 = $('<input kauri-idref="case-c1" ><span kauri-idref="case-c1" kauri-role="messages">init</span>').appendTo($case); 
    2830    var $c2 = $('<input kauri-idref="case-c2" type="checkbox" ><span kauri-idref="case-c2" kauri-role="messages">init</span>').appendTo($cas2); 
     31    var $c3a = $('<input kauri-idref="case-c3/a">').appendTo($case); 
     32    var $c3b = $('<div kauri-idref="case-c3"><input kauri-idref="b" /></div>').appendTo($cas2); 
     33     
     34    // Note: the composite case c3 was added to check for the side effects of #448 
     35    // While it should just work: using this in a case might be indication that you should switch to actually using eventhandlers 
    2936     
    3037    var $msg = $("<span kauri-role='messages'/>").appendTo($case); 
     
    3340 
    3441    // test 
    35     expect(9); 
     42    expect(17); 
    3643     
    3744    // verify creation of control 
     
    4653    ok($c1.is(':visible'), "the first member should be visible"); 
    4754    ok($c2.is(':hidden'), "the second member should be hidden"); 
     55    ok($c3a.is(':hidden'), "the third a-member should be hidden"); 
     56    ok($c3b.is(':hidden'), "the third b-member should be hidden"); 
    4857     
    4958    var $c1Msg = form.findControl(id + "/case-c1").getElement("messages"); 
     
    5766    ok($c1.is(':hidden'), "the first member should be hidden"); 
    5867    ok($c2.is(':visible'), "the second member should be visible"); 
    59      
     68    ok($c3a.is(':hidden'), "the third a-member should be hidden"); 
     69    ok($c3b.is(':hidden'), "the third b-member should be hidden"); 
     70 
     71    c.setValue( { "case" : "c3", value : {a: "one", b: "two"}}); 
     72 
     73    ok($c1.is(':hidden'), "the first member should be hidden"); 
     74    ok($c2.is(':hidden'), "the second member should be hidden"); 
     75    ok($c3a.is(':visible'), "the third a-member should be visible"); 
     76    ok($c3b.is(':visible'), "the third b-member should be visible"); 
     77 
    6078    // cleanup 
    6179    $main.html("").hide(); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-composite.js

    r1845 r1869  
    149149    $main.html("").hide(); 
    150150}); 
     151 
     152 
     153test("composite with split HTML should hide/show all parts", function() { 
     154    // create 
     155    var $main = $('#main').show(); 
     156     
     157    // init form 
     158    var id = "tcomp3"; 
     159 
     160    var fconf = { "members": {}}; 
     161    fconf.members[id] = { "base": "composite", 
     162        "members" : { "m1" : "string", "m2" : "string" , "m3" : "string"} 
     163    };     
     164     
     165    var $form = $('<form />').appendTo($main); 
     166    var $compo1 = $('<div kauri-idref="' + id + '" ></div>)').appendTo($form);         
     167    var $compo2 = $('<div></div>)').appendTo($form);         
     168    var $compo3 = $('<div kauri-idref="' + id + '" ></div>)').appendTo($form);         
     169    var $m1 = $('<input kauri-idref="m1" ><span kauri-idref="m1" kauri-role="messages">init</span>').appendTo($compo1); 
     170    var $m2 = $('<input kauri-idref="'+id+'/m2" ><span kauri-idref="'+id+'/m2" kauri-role="messages">init</span>').appendTo($compo2); 
     171    var $m3 = $('<input kauri-idref="m3" ><span kauri-idref="m3" kauri-role="messages">init</span>').appendTo($compo3); 
     172     
     173    var form = new $.org.kauriproject.forms.Form($form, fconf); 
     174     
     175    // start test 
     176    expect(15); 
     177 
     178 
     179    // verify creation of control 
     180    var c = form.findControl(id); 
     181    ok(c != null, "control creation passed"); 
     182    equals(c.getForm(), form, "control form ok"); 
     183    equals(c.getId(), id, "control id checked"); 
     184 
     185    debugger; 
     186    c.hide(); 
     187    ok($compo1.is(':hidden'),  "m1 container is associated to the composite and should be hidden"); 
     188    ok($compo2.is(':visible'), "m2 container is not associated to the composite and should always be visible"); 
     189    ok($compo3.is(':hidden'),  "m3 container is associated to the composite and should be hidden"); 
     190    ok($m1.is(':hidden'), "m1 member should be hidden"); 
     191    ok($m2.is(':hidden'), "m2 member should be hidden"); 
     192    ok($m3.is(':hidden'), "m3 member should be hidden"); 
     193 
     194    c.show(); 
     195    ok($compo1.is(':visible'), "m1 container is associated to the composite and should always be visible"); 
     196    ok($compo2.is(':visible'), "m2 container is not associated to the composite and should be visible"); 
     197    ok($compo3.is(':visible'), "m1 container is associated to the composite and should always be visible"); 
     198    ok($m1.is(':visible'), "m1 member should be visible"); 
     199    ok($m2.is(':visible'), "m2 member should be visible"); 
     200    ok($m3.is(':visible'), "m3 member should be visible"); 
     201     
     202    // cleanup 
     203    $main.html("").hide(); 
     204}); 
Note: See TracChangeset for help on using the changeset viewer.