Changeset 1446


Ignore:
Timestamp:
2010-03-08 15:32:42 (2 years ago)
Author:
freya
Message:

Changes regarding creation of collection controls: make use of kauri-layout and kauri-cursor to define the layout of collection element and position of element. Still unstable and work in progress.

Location:
trunk
Files:
7 edited

Legend:

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

    r1438 r1446  
    3838    $.extend(InputControl.prototype.templates, kf.Control.prototype.templates); 
    3939    $.extend(InputControl.prototype.templates, { 
    40            input:"<input type='text'/>" 
     40           input:"<input type='text' kauri-role='input'/>" 
    4141    }); 
    4242 
     
    5656        } 
    5757        if(! $input.is(selector)){ 
    58             $input.html(this.getTemplate('input')); 
     58            var $element = $(this.getTemplate('input'));  
     59 
     60            $input.each( function() { 
     61                $.each(this.attributes, function(i, attrib) { 
     62                    var name = attrib.name; 
     63                    var value = attrib.value; 
     64                    if (!$element.attr(name)) { 
     65                        $element.attr(name, value); 
     66                    } 
     67                }); 
     68            }); 
     69            $input.before($element).remove();  
    5970        } 
    6071         
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/collection.js

    r1441 r1446  
    6363    $.extend(CollectionControl.prototype.templates, { 
    6464        layout: "<tr><td ><span kauri-role='label'/><span kauri-role='input'/><span kauri-role='messages'/><span kauri-role='delete'/></td></tr>", 
    65         container: "<table kauri-role='container'></table>" 
     65        container: "<table kauri-role='container'></table>", 
     66        input: "<table kauri-role='input'></table>" 
    6667    }); 
     68     
     69    CollectionControl.prototype.groupChildrenInLayoutIndex = true; 
    6770     
    6871    CollectionControl.prototype.initElements = function( ) { 
     
    8790        } 
    8891 
    89         var container = this.getElement(kf.ControlElements.REV_CONTAINER); 
     92        var container = this.getElement(kf.ControlElements.REV_INPUT); 
    9093        var layout = this.getElement(kf.ControlElements.REV_LAYOUT); 
    9194 
     
    271274        } 
    272275 
    273         this._childrenContainer.empty(); 
     276      // TODO check  this._childrenContainer.empty(); 
    274277        this._children = []; 
    275278    } 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/composite.js

    r1438 r1446  
    8080    $.extend(CompositeControl.prototype.templates, kf.AbstractContainerControl.prototype.templates); 
    8181    $.extend(CompositeControl.prototype.templates, { 
    82            container: "<dl kauri-role='container'></dl>", 
    83            layout: "<dt kauri-role='label'/><dd><span kauri-role='input'/><span kauri-role='messages'/></dd>"     
     82           input: "<dl kauri-role='input'></dl>", 
     83           layout: "<dt kauri-role='label'/><dd><span kauri-role='input'/><span kauri-role='messages'/></dd>", 
     84           "kauri-layout": "<dt kauri-role='label'/><dd><span kauri-role='input'/><span kauri-role='messages'/></dd>" 
    8485    }); 
    8586 
     
    102103             throw "[CompositeControl#createChildElements] No container to work with.";            
    103104        }  
    104         var item = $(this.getTemplate('layout')).appendTo(container); 
    105         return item; 
     105        // TODO check why this has to happen?         
     106        //var item = $(this.getTemplate('layout')).appendTo(container); 
     107        //return item; 
    106108    } 
    107109 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/control.js

    r1441 r1446  
    3939        this.elementIndex = {}; 
    4040         
     41        // index of layout cursor elements 
     42        this.layoutIndex = {}; 
     43         
    4144    } 
    4245     
     
    5659     
    5760    /** 
     61     * Html attribute name used for specifying the role 
     62     * @static 
     63     * @final 
     64     */ 
     65    ControlElements.ATTR_REV = "kauri-role"; 
     66 
     67    /** 
     68     * Html attribute name used for specifying the layout relation. 
     69     * @static 
     70     * @final 
     71     */ 
     72    ControlElements.ATTR_LAYOUT = "kauri-layout"; 
     73 
     74    /** 
     75     * Html attribute name used for specifying the layout cursor position 
     76     * @static 
     77     * @final 
     78     */ 
     79    ControlElements.ATTR_LAYOUT_CURSOR = "kauri-layout-cursor"; 
     80 
     81    /** 
     82     * Html attribute name used for specifying the layout clone id 
     83     * @static 
     84     * @final 
     85     */ 
     86    ControlElements.ATTR_LAYOUT_CLONE = "kauri-layout-clone"; 
     87 
     88     
     89    /** 
     90     * Html attribute name used for specifying the layout group which the element belongs to 
     91     * @static 
     92     * @final 
     93     */ 
     94    ControlElements.ATTR_LAYOUT_GROUP = "kauri-layout-group"; 
     95 
     96     
     97    /** 
    5898     * Html attribute name used for specifying the relation. Rev is short for reverse index 
    5999     * @static 
     
    61101     */ 
    62102    ControlElements.ATTR_REV = "kauri-role"; 
     103 
    63104     
    64105    /** 
     
    105146    ControlElements.REV_MARK = "mark"; 
    106147     
    107     /** 
    108      * Specifies that the element is a container for the control 
     148 
     149    /** 
     150     * TODO this one should be removed, it is remplaces by the kauri-layout attribute 
    109151     * @static 
    110152     * @final 
    111153     */ 
    112154    ControlElements.REV_CONTAINER = "container"; 
    113      
    114     /** 
    115      * Specifies that the element should be used as a layout or template for child elements 
    116      * @static 
    117      * @final 
    118      */ 
    119155    ControlElements.REV_LAYOUT = "layout"; 
     156 
    120157     
    121158    /** 
     
    163200             
    164201            var rev = $this.attr(ControlElements.ATTR_REV); 
    165              
    166202            store.addElementIndex(index, rev, $this); 
    167203             
     
    172208        }; 
    173209 
    174         var wrapIndexor = function($wrap){ 
    175             //var $first = $($eltArray[0]); 
    176             index = "";  
    177             var idref = $wrap.attr(ControlElements.ATTR_IDREF) || ""; 
    178             if (idref.length == 0 || idref.charAt(0) != '/')  
    179                 index = $wrap.parents("[" + ControlElements.ATTR_INDEX + "]:first").attr(ControlElements.ATTR_INDEX); 
    180             if (idref) { 
    181                 index = $.concatPath(index, idref); 
    182                  
    183             } 
    184              
    185             var rev = $wrap.attr(ControlElements.ATTR_REV); 
    186              
    187             store.addElementIndex(index, rev, $wrap.children()); 
    188              
    189             //add type property if known 
    190           //  store.addTypeAndControl(index, $elt.attr(ControlElements.ATTR_TYPE), $this.attr(ControlElements.ATTR_CONTROL)); 
    191  
    192             $wrap.attr(ControlElements.ATTR_INDEX, index); 
    193         }; 
    194          
    195210        // find all kauri-idref and kauri-role marked elements and index them 
    196         var kauriSelector = "[" + ControlElements.ATTR_IDREF + "],[" + ControlElements.ATTR_REV + "]"; 
    197  
    198          
     211        var kauriSelector = "[" + ControlElements.ATTR_IDREF + "]"; 
     212        var layoutSelector = "[kauri-layout]"; 
    199213         
    200214        // begin by index space itself, 
    201         if (space.is(kauriSelector))  
     215        if (space.is(kauriSelector) )  
    202216            space.each(indexor); 
    203217            // then go through matching children, but only once (even if they match multiple times) 
     
    205219            // TODO should we do this this way or should be traverse the tree ourselves (performance?) 
    206220            var $this = $(this); 
    207             var revParents = $this.parents("[" + ControlElements.ATTR_REV + "='" + ControlElements.REV_LAYOUT + "']"); 
    208  
    209             return ($this.attr(ControlElements.ATTR_IDREF)!=undefined || revParents == null || revParents.length==0); 
    210         });    
    211      
    212         matching.each(indexor); 
     221            var revParents = $this.parents("[" + ControlElements.ATTR_LAYOUT + "]"); 
     222 
     223            return (revParents == null || revParents.length==0); 
     224        });       
     225        $.unique($(kauriSelector, space)).each(indexor); 
     226         
     227         
     228        var matching = $($.unique($("[kauri-layout-cursor]", space))).filter(function(){ 
     229            var $this = $(this); 
     230            var revParents = $this.parents("[kauri-layout]"); 
     231            return (revParents == null || revParents.length==0); 
     232        });   
     233         
     234        $.each(matching, function(pos, element){ 
     235            var $element = $(element); 
     236            store.addCursorIndex($element.attr("kauri-layout-cursor"), $element); 
     237        }); 
     238         
     239         
     240        if (space.is(layoutSelector))  
     241            store.addLayoutIndex(space.attr("kauri-layout"), space); 
     242         
     243        var matchingLayout = $($.unique($(layoutSelector, space))).filter(function(){ 
     244            var $this = $(this); 
     245            var revParents = $this.parents("[kauri-layout]"); 
     246            return (revParents == null || revParents.length==0); 
     247        });   
     248 
     249        $.each(matchingLayout, function(pos, element){ 
     250            var $element = $(element); 
     251            store.clearLayoutIndex($element.attr("kauri-layout")); 
     252        }); 
     253 
     254        $.each(matchingLayout, function(pos, element){ 
     255            var $element = $(element); 
     256            store.addLayoutIndex($element.attr("kauri-layout"), $element); 
     257        }); 
     258 
    213259    } 
    214260     
     
    289335                $elm = form.getElementIndex(index)[0]; 
    290336             
    291              
    292                  
    293337                if ($elm) { 
    294338                    $elm.attr(ControlElements.ATTR_INDEX, index); 
     
    304348    } 
    305349 
     350      
     351     ControlElements.lookupLayout = function(control) { 
     352 
     353        var form = control.getForm(); 
     354        var index = control.getGroupId(); 
     355 
     356        var $elm = form.getLayoutIndex(index);  
     357 
     358        if ($elm) 
     359            control.setElement(ControlElements.ATTR_LAYOUT, $elm); 
     360        return $elm; 
     361    } 
     362 
     363    ControlElements.lookupLayoutCursor = function(control) { 
     364        var form = control.getForm(); 
     365        var index = control.getGroupId(); 
     366 
     367        var $elm = form.getCursorIndex(index);  
     368         
     369        if ($elm) 
     370            control.setElement(ControlElements.ATTR_LAYOUT_CURSOR, $elm); 
     371        return $elm; 
     372    } 
     373      
     374      
    306375    /** 
    307376     * Finds all elements associated to a certain control 
     
    367436        return empty; 
    368437    } 
    369      
     438 
     439     ControlElements.newLayoutElements = function() { 
     440        var empty = []; 
     441        empty.layout = {}; 
     442        empty.cursor = {}; 
     443        return empty; 
     444    } 
     445 
    370446     
    371447    /** 
     
    513589        }); 
    514590    } 
    515      
     591 
     592     /** 
     593      * Adds the specified element to the index. 
     594      * 
     595      * @param {string} 
     596      *            index index position to add to. 
     597      * @param {string} 
     598      *            [group] the group part we're adding a layout element to 
     599      * @param {$jquery} 
     600      *            elm element to add 
     601      */ 
     602     ControlElements.prototype.addLayoutIndex = function(index, $element){ 
     603         var elms = this.layoutIndex[index] = this.layoutIndex[index] || ControlElements.newLayoutElements(); 
     604         var group = $element.attr("kauri-group"); 
     605         if(!group) 
     606             group="1"; // TODO 
     607     
     608         var layoutgroup = elms.layout[group] = elms.layout[group] || []; 
     609         layoutgroup.push($element); 
     610     } 
     611 
     612      ControlElements.prototype.clearLayoutIndex = function(index){ 
     613          this.layoutIndex[index] = ControlElements.newLayoutElements(); 
     614      } 
     615 
     616       
     617     /** 
     618      * Gets the specified layout JQuery wrapper element from the index. 
     619      * 
     620      * @param {string} 
     621      *            [index] index to get. <code>undefined</code> will return the whole store. 
     622      * @param {group} 
     623      *            [group] the group layout part to get from the index 
     624      */ 
     625     ControlElements.prototype.getLayoutIndex = function(index, group){ 
     626      
     627         if (index == undefined)  
     628             return this.layoutIndex; 
     629          
     630         var $elm; 
     631         //this.layoutIndex[index] = this.layoutIndex[index] || ControlElements.newLayoutElements(); 
     632 
     633         if(this.layoutIndex[index]) { 
     634              
     635             if(group == undefined) 
     636                 return this.layoutIndex[index].layout; 
     637             else          
     638                 return this.layoutIndex[index].layout[group]; 
     639         }else 
     640             return null; 
     641      } 
     642 
     643      /** 
     644       * Adds the specified element to the cursor index. 
     645       * 
     646       * @param {string} 
     647       *            index index position to add to. 
     648       * @param {$jquery} 
     649       *            elm element to add 
     650       */ 
     651      ControlElements.prototype.addCursorIndex = function(index, $element){ 
     652          var elms = this.layoutIndex[index] = this.layoutIndex[index] || ControlElements.newLayoutElements(); 
     653          elms.cursor = $element; 
     654      } 
     655       
     656      /** 
     657       * Gets the specified layout JQuery wrapper element from the cursor index. 
     658       * 
     659       * @param {string} 
     660       *            [index] index to get. <code>undefined</code> will return the whole store. 
     661       */ 
     662      ControlElements.prototype.getCursorIndex = function(index){ 
     663       
     664          if (index == undefined)  
     665              return this.layoutIndex; 
     666           
     667         return (this.layoutIndex[index]) ? this.layoutIndex[index].cursor : null; 
     668       } 
     669 
     670 
    516671     
    517672    /** 
     
    605760    }; 
    606761     
     762     
     763    /** 
     764     * Holds the control-bound HTML templates per relation 
     765     * @private 
     766     */ 
     767    Control.prototype.groupInLayoutIndex = false; 
     768     
     769     
    607770    /** 
    608771     * Initializes element configurations 
     
    667830         
    668831        var $elements = this._elements[relation]; 
     832         
     833        if(relation == ControlElements.REV_MARK && !$elements) 
     834            $elements =  this._elements["input"]; 
     835         
    669836        return $elements; 
    670837    } 
     
    8701037         
    8711038        var $input = this.getElement(); 
    872         $input.addClass("unfocused"); 
    873         $input.blur(function(){ 
    874             $(this).removeClass("focused").addClass("unfocused"); 
    875         }); 
    876         $input.focus(function(){ 
    877             $(this).addClass("focused").removeClass("unfocused"); 
    878         }); 
     1039        if($input) { 
     1040            $input.addClass("unfocused"); 
     1041            $input.blur(function(){ 
     1042                $(this).removeClass("focused").addClass("unfocused"); 
     1043            }); 
     1044            $input.focus(function(){ 
     1045                $(this).addClass("focused").removeClass("unfocused"); 
     1046            }); 
     1047        } 
    8791048         
    8801049        var $update = this.getUpdateElement(); 
     
    13251494         
    13261495        var mrkElm = this.getElement(ControlElements.REV_MARK); 
    1327         if (msg)  
    1328             mrkElm.removeClass("valid").addClass("invalid"); 
    1329         else  
    1330             mrkElm.removeClass("invalid").addClass("valid"); 
    1331          
     1496         
     1497        if(mrkElm){  
     1498            if (msg)  
     1499                mrkElm.removeClass("valid").addClass("invalid"); 
     1500            else  
     1501                mrkElm.removeClass("invalid").addClass("valid"); 
     1502        } 
    13321503    } 
    13331504     
     
    13641535        return $.concatPath(parentId, id); 
    13651536    } 
    1366      
     1537 
     1538    /** 
     1539    * Gets this controls absolute id. This means including all the ids of possible parent controls 
     1540    * @return absolute id or id-path 
     1541    * @type String 
     1542    */ 
     1543   Control.prototype.getGroupId = function(){ 
     1544    
     1545       var parent = this.getParent(); 
     1546       var parentId = ""; 
     1547       if (parent)  
     1548           parentId = parent.getGroupId(); 
     1549        
     1550       var id = (this.getParent() && this.getParent().groupChildrenInLayoutIndex) ? "#" : this.getId(); 
     1551       return $.concatPath(parentId, id); 
     1552   } 
     1553 
    13671554     
    13681555    // TODO support 'match-patterns' allowing to return arrays of controls on which some jqyery like each() can then execute 
     
    14541641    Control.prototype.enable = function(){ 
    14551642        for (var rel in this._elements) { 
    1456             var el = this._elements[rel]; 
     1643            var el = this.getElement(rel); 
    14571644            if (el.is(":disabled")) { 
    14581645                el.removeAttr("disabled"); 
     
    15691756        input: "<div><span kauri-role='label'/><span kauri-role='input'/><span kauri-role='messages'/></div>", 
    15701757        layout: "<div><span kauri-role='label'/><span kauri-role='input'/><span kauri-role='messages'/></div>", 
     1758        "kauri-layout": "<div><span kauri-role='label'/><span kauri-role='input'/><span kauri-role='messages'/></div>", 
    15711759        container: "<div kauri-role='container'></div>" 
    15721760    }); 
     
    17681956     */ 
    17691957    AbstractContainerControl.prototype.initContainerElements = function(create){ 
    1770      
    1771         var container = ControlElements.lookup(this, ControlElements.REV_CONTAINER); 
    1772         var $container = $(container); 
    1773         if (!container) {  
    1774             var creator = this.getTemplate(ControlElements.REV_CONTAINER); 
    1775             if (creator) { 
    1776                 $container = $(creator).appendTo($(this.getElement("input"))); 
    1777                 this.setElement(ControlElements.REV_CONTAINER, $container); 
    1778             } 
    1779         } 
    1780  
    1781         if (!$container) { // default to complete input space  
    1782             this.setElement(ControlElements.REV_CONTAINER, this.getElement("input")); 
    1783         } 
    1784          
    1785         var layout = ControlElements.lookup(this, ControlElements.REV_LAYOUT); 
    1786         if (!layout) {  
    1787             var creator = this.getTemplate(ControlElements.REV_LAYOUT); 
    1788             if (creator) { 
    1789                 $layout = $(creator).appendTo($container); 
    1790                 this.setElement(ControlElements.REV_LAYOUT, $layout); 
    1791             } 
    1792         } 
    1793  
    1794        /* if (layout) { 
    1795             layout.hide(); 
    1796         }*/ 
     1958         var container = ControlElements.lookup(this, ControlElements.REV_INPUT); 
     1959          
     1960          
     1961         // check if there is a layout attached to this element 
     1962         // if not,  switch the apply the input template from the control and append to the input container 
     1963         var id = this.getAbsoluteId(); 
     1964         if(!this.getForm().getLayoutIndex(id)){ 
     1965             var creator = this.getTemplate(ControlElements.REV_INPUT); 
     1966             if (creator) { 
     1967                 var form = this.getForm(); 
     1968                 var $input = $(creator); 
     1969                 $container = $input.appendTo(container); 
     1970                 this.setElement(ControlElements.REV_INPUT, $input); 
     1971             }     
     1972         } 
     1973          
     1974         var $container = $(container); 
     1975         if (!container) {  
     1976              
     1977         } 
     1978 
     1979         if (!$container) { // default to complete input space  
     1980             this.setElement(ControlElements.REV_INPUT, this.getElement("input")); 
     1981         } 
    17971982    } 
    17981983     
     
    18001985    AbstractContainerControl.prototype.getUpdateElement = function(){ 
    18011986    }; 
     1987     
     1988     
    18021989     
    18031990    /** 
     
    18172004     */ 
    18182005    AbstractContainerControl.prototype._createChildElements = function(id, position) { 
    1819      
    1820         var newIndex = $.concatPath(this.getAbsoluteId(), id); 
    1821         var elements = this.getForm().getElementIndex(newIndex); 
     2006        var absoluteId = this.getAbsoluteId(); 
     2007        var newIndex = $.concatPath(absoluteId, id); 
     2008        var form = this.getForm(); 
     2009        var elements = form.getElementIndex(newIndex); 
    18222010        if (elements && (elements.length > 0 || elements.meta[ControlElements.REV_INPUT]))  
    18232011            return elements; // no need to create new elements 
    1824         var container = this.getElement(ControlElements.REV_CONTAINER); 
    1825         var layout = this.getElement(ControlElements.REV_LAYOUT); 
    1826          
    1827         var newElements 
    1828         if (!(container && layout)) { 
    1829             newElements = this.createChildElements(id, container, layout); 
    1830         } 
    1831         else { 
    1832             // there is a container and there is a layout 
    1833             var childAtPosition = null; 
    1834             if (position != undefined && (typeof position == "number")) { 
    1835                 childAtPosition = container.children(":nth-child(" + (position + 1) + ")"); 
    1836             } 
    1837             var $layout = layout.clone(); 
    1838  
    1839             if (childAtPosition != null && childAtPosition.length == 1) { 
    1840                 newElements = $layout.insertBefore(childAtPosition[0]).show(); 
    1841             } else { 
    1842                 newElements = $layout.appendTo(container).show(); 
    1843             } 
     2012         
     2013        var newElements; 
     2014        var newElementsArray = []; 
     2015 
     2016        var form = this.getForm(); 
     2017        var groupId = this.getGroupId(); 
     2018        var containerId = this.getId(); 
     2019        var $layoutGroups = form.getLayoutIndex(groupId); 
     2020 
     2021         
     2022        var copyIdRef = function(idx, elt){ 
     2023            var $elt = $(elt); 
     2024            if($elt.attr(ControlElements.ATTR_IDREF)) 
     2025                $elt.attr(ControlElements.ATTR_IDREF, $elt.attr(ControlElements.ATTR_IDREF) + "/" +id); 
     2026            else 
     2027                $elt.attr(ControlElements.ATTR_IDREF, id); 
     2028        }; 
     2029         
     2030         
     2031        if(!$layoutGroups) { 
     2032            // get layout from template and where to put cursor?? default append to input element?? 
     2033            var container = this.getElement(ControlElements.REV_INPUT); 
    18442034             
     2035            var $layout = $(this.getTemplate("layout")); 
    18452036             
    1846             //newElements.attr(ControlElements.ATTR_REV, ControlElements.REV_ITEM); 
    1847  
    1848             if(true){ 
    1849                 // hier item index berekenen en in elementindex steken 
    1850                 // daarna gewoon de elemennten indexeren 
    1851                  
    1852                 var idref = id; 
    1853                 if (idref.length == 0 || idref.charAt(0) != '/')  
    1854                     index = newElements.parents("[" + ControlElements.ATTR_INDEX + "]:first").attr(ControlElements.ATTR_INDEX); 
    1855                 if (idref) { 
    1856                     index = $.concatPath(index, idref); 
    1857                 } 
    1858                  
    1859                 this.getForm().addElementIndex(index, ControlElements.REV_ITEM, newElements); 
    1860                  
    1861 /*                 
    1862                 var $wrap = $("<kauri-layout/>"); 
    1863                 $wrap.append(newElements.clone()); 
    1864  
    1865                 $wrap.attr(ControlElements.ATTR_REV, ControlElements.REV_ITEM); 
    1866                 $wrap.attr(ControlElements.ATTR_IDREF, id); 
    1867                 //newElements = $wrap; 
    1868                 var form = this.getForm(); 
    1869                 ControlElements.index($wrap, form, true); 
    1870                 return newElements;*/ 
    1871             } 
    1872  
    1873         } 
    1874          
    1875         newElements.attr(ControlElements.ATTR_IDREF, id); 
    1876         var form = this.getForm(); 
    1877         ControlElements.index(newElements, form, true); // we force re-indexing cause layout-template elements will already be 
    1878         // indexed 
    1879         return newElements; 
     2037            $layout.each(copyIdRef); 
     2038             
     2039            $.each($("[kauri-role]", $layout), copyIdRef); 
     2040             
     2041            newElements = container.append($layout); 
     2042            ControlElements.index($layout, form, true); 
     2043            newElementsArray.push($layout); 
     2044        }else{ 
     2045            // clone each element in layout group 
     2046            $.each($layoutGroups, function(layoutGroupId, eltArray){ 
     2047                $.each(eltArray, function(eltId, elt){ 
     2048                    var $elt = $(elt); 
     2049                    var $layoutClone = $elt.clone(); 
     2050                    $layoutClone.attr("kauri-layout-clone", absoluteId + "(" + groupId + ")"); 
     2051                    // set the id of the newly created row  before the idref 
     2052                    if($layoutClone.attr(ControlElements.ATTR_IDREF)) 
     2053                        $layoutClone.attr(ControlElements.ATTR_IDREF, $layoutClone.attr(ControlElements.ATTR_IDREF) + "/" +id); 
     2054                    else 
     2055                        $layoutClone.attr(ControlElements.ATTR_IDREF, id); 
     2056                    $layoutClone.removeAttr( ControlElements.ATTR_LAYOUT ); 
     2057                    // search for cursor and insert before cursor 
     2058                    var cursorId = groupId + "(" + layoutGroupId + ")" ; 
     2059                    var cursor = form.getCursorIndex(cursorId); 
     2060                    // make sure the clone is visible 
     2061 
     2062                    if(!cursor)  
     2063                        cursor = $elt; 
     2064                    $layoutClone.show(); 
     2065                    newElements = $layoutClone.insertBefore(cursor); 
     2066                    ControlElements.index(newElements, form, true); 
     2067                    newElementsArray.push(newElements); 
     2068                }); 
     2069            }); 
     2070        } 
     2071 
     2072 
     2073        return newElementsArray; 
    18802074    } 
    18812075     
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/form.js

    r1441 r1446  
    142142        $.extend(this, new kf.ControlElements()); 
    143143 
     144        // hide all layout and cursor elements 
     145        var $layoutElts = $("[" + kf.ControlElements.ATTR_LAYOUT + "], [" + kf.ControlElements.ATTR_LAYOUT_CURSOR + "]", space); 
     146        $.each($layoutElts, function(index, element){ 
     147            $(element).hide(); 
     148          } 
     149        ); 
     150 
    144151        space.attr(kf.ControlElements.ATTR_INDEX, '/'); 
    145152        kf.ControlElements.index(space, this); 
     153         
     154         
    146155 
    147156        this.setRootElement(space); 
     
    164173    Form.prototype.getAbsoluteId = function() { 
    165174 
    166         return "/" 
     175        return "/"; 
    167176    }; 
    168177 
     178    Form.prototype.getGroupId = function() { 
     179 
     180        return "/"; 
     181    }; 
     182 
     183     
    169184    Form.prototype.setAllowInvalid = function(allow) { 
    170185 
  • trunk/samples/kauri-forms-sample/src/main/kauri/pages/collection-control.html.xml

    r1439 r1446  
    8686        <label kauri-role="label" kauri-idref="countries">Countries</label> 
    8787 
    88         <table kauri-idref="countries" kauri-type="collection"> 
     88        <table kauri-idref="countries" kauri-type="collection" kauri-item="country"> 
    8989          <thead> 
    9090            <tr> 
     
    9999 
    100100          <tbody kauri-role="container"> 
    101             <tr kauri-role="layout"> 
    102               <td> 
     101            <tr kauri-layout="country"> 
     102             
     103              <td > 
    103104                <input kauri-idref="name" kauri-type="string"/> 
    104105              </td> 
     
    114115                <span class="action copyAction">copy</span> 
    115116              </td> 
     117             
    116118            </tr> 
     119             
    117120          </tbody> 
    118121 
  • trunk/samples/kauri-forms-sample/src/main/kauri/pages/collection-performance.html.xml

    r1439 r1446  
    8787          </thead> 
    8888 
    89           <tbody kauri-role="container"> 
    90             <tr kauri-role="layout"> 
     89          <tbody> 
     90            <tr kauri-layout="/performances"> 
    9191              <td> 
    9292                <input kauri-idref="task" kauri-type="string" size="10"/> 
Note: See TracChangeset for help on using the changeset viewer.