Changeset 643


Ignore:
Timestamp:
2008-09-26 13:15:59 (5 years ago)
Author:
paul
Message:

Fix for issue #78 the CaseControl? which displays a certain child control based on the value of a selector.
Also there is a fix for issue #79 on the enabled/disabled state for controls
Controls can be be made hidden & visible
Did some documenting in Control.js

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

Legend:

Unmodified
Added
Removed
  • trunk/modules/kauri-forms/kauri-forms-framework/src/assembler/kauri-forms-assembler.xml

    r560 r643  
    2525        <include>collection.js</include> 
    2626        <include>composite.js</include> 
     27        <include>case.js</include> 
    2728 
    2829        <include>date.js</include> 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/js/control.js

    r624 r643  
    2121 
    2222    /** 
    23      * ControlElements declares the constants and helper methods and instances to handle the control to HTML binding operations of 
     23     * @class ControlElements declares the constants and helper methods and instances to handle the control to HTML binding operations of 
    2424     * indexing and finding HTML elements bound to the controls. 
    2525     * <p> 
     
    4141    } 
    4242 
    43  
     43    /** 
     44    * Html attribute name used for specifying an index 
     45    * @static 
     46    * @final 
     47    */ 
    4448    ControlElements.ATTR_INDEX = "kauri-index"; 
     49     
     50    /** 
     51    * Html attribute name used for specifying the control id 
     52    * @static 
     53    * @final 
     54    */ 
    4555    ControlElements.ATTR_IDREF = "kauri-idref"; 
     56     
     57    /** 
     58    * Html attribute name used for specifying the relation. Rev is short for reverse index 
     59    * @static 
     60    * @final 
     61    */ 
    4662    ControlElements.ATTR_REV = "kauri-rev"; 
     63     
     64    /** 
     65    * Specifies that the element has a messages relation with the control 
     66    * @static 
     67    * @final 
     68    */ 
    4769    ControlElements.REV_MESSAGES = "messages"; 
     70     
     71    /** 
     72    * Specifies that the element has a label relation with the control 
     73    * @static 
     74    * @final 
     75    */ 
    4876    ControlElements.REV_LABEL = "label"; 
     77     
     78    /** 
     79    * Specifies that the element has an input relation with the control. If no relation is specified this is used by default 
     80    * @static 
     81    * @final 
     82    */ 
    4983    ControlElements.REV_INPUT = "input"; 
     84     
     85    /** 
     86    * Specifies that the element has a mark relation with the control.  
     87    * <b>TODO:</b> What does this mark thing do anyway? 
     88    * @static 
     89    * @final 
     90    */ 
    5091    ControlElements.REV_MARK = "mark"; 
     92     
     93    /** 
     94    * Specifies that the element is a container for the control 
     95    * @static 
     96    * @final 
     97    */ 
    5198    ControlElements.REV_CONTAINER = "container"; 
     99     
     100    /** 
     101    * Specifies that the element should be used as a layout or template for child elements 
     102    * @static 
     103    * @final 
     104    */ 
    52105    ControlElements.REV_LAYOUT = "layout"; 
     106     
     107    /** 
     108    * Specifies that the element is a child item of the control 
     109    * @static 
     110    * @final 
     111    */ 
    53112    ControlElements.REV_ITEM = "item"; 
     113     
     114    /** 
     115    * Specifies that the element is used for refreshing data 
     116    * @static 
     117    * @final 
     118    */ 
    54119    ControlElements.REV_REFRESH = "refresh"; 
    55120 
     
    58123     * Indexes the passed 'space' of HTML elements. Indexing in this context means resolving the various relative kauri-rev 
    59124     * attributes into absolute kauri-index attributes while keeping the pre-indexed references in the passed elementsIndex. 
     125     * @param {HTMLElement} space Which html element should be used as the start of indexing, all the child elements of the space will be indexed 
     126     * @param {ControlElements} store Where the index should be stored 
     127     * @param {Boolean} forceReIndexing Index even if the space has already been indexed 
     128     * @static 
    60129     */ 
    61130    ControlElements.index = function( space, store, forceReIndexing) { 
     
    104173     * Finds the element assigned to the identified control for a specific kauri-form-relation (functional role), and creates it if 
    105174     * not found. 
    106      *  
     175     * @param {Control} control 
     176     * @param {String} relation What relation the element has with the control (input, message, ...) 
     177     * @param {Boolean} create Flag that indicates if an element should be created if not found 
    107178     * @final 
    108179     * @static 
     
    166237    /** 
    167238     * Regular expression to parse index-entries. 
    168      *  
     239     * @type Pattern 
    169240     * @static 
    170241     * @final 
     
    174245    /** 
    175246     * Splits the index-expressions in index and relation parts. 
    176      *  
     247     * @param {String} index 
     248     * @return An Object with an index and a relation 
     249     * @type Object 
    177250     * @static 
    178251     * @final 
     
    191264    /** 
    192265     * Builds a new array with 'meta' property to store the associated relation-elements 
    193      *  
     266     * @return an empty array 
     267     * @type Array 
    194268     * @static 
    195269     * @final 
     
    204278 
    205279    /** 
    206      *  
     280     * Generates a jQuery selector based on the given relationship 
     281     * @param {String} relation The relationship the element has with the control 
     282     * @return A selector to be used by jQuery to select certain elements 
     283     * @type String 
     284     * @static 
     285     * @final 
    207286     */ 
    208287    ControlElements.revSelector = function( relation) { 
     
    235314     *  
    236315     * @return whatever the idfn or relfn functions return. 
     316     * @private 
    237317     */ 
    238318    ControlElements.prototype._operateIndex = function( index, relation, idfn, relfn) { 
     
    259339     * @param {string} 
    260340     *            [relation] relation-part to clear. <code>undefined</code> will force extra parsing of the index looking for a 
    261      *            relation part. <code>false</code> will skip index-parsing and clear the array. 
     341     *            relation part. <code>false</code> will skip index-parsing and clear the array.      
    262342     */ 
    263343    ControlElements.prototype.clearElementIndex = function( index, relation) { 
     
    340420 
    341421    /** 
    342      * Control performs the actual DOM manipulations and event passing for an actual input-control on the form. Pure UI formatting 
     422     * @class Control performs the actual DOM manipulations and event passing for an actual input-control on the form. Pure UI formatting 
    343423     * effects (in fact any non data-bound interaction) are not handled by these controls. 
    344424     *  
     
    363443    /** 
    364444     * Initializes all aspects of the control in a well defined sequence. 
    365      *  
     445     * @param {Object} conf Control configuration      
    366446     * @final should not be overridden 
    367447     */ 
     
    380460    /** 
    381461     * Initializes the 'type' from the configuration object passed in (if that didn't happen yet). 
    382      *  
     462     * @param {Object} conf Control configuration 
    383463     * @final should not be overridden 
    384464     */ 
     
    396476    /** 
    397477     * Creates the type from the config if that is still needed. 
    398      *  
     478     * @param {Object} conf Control configuration 
    399479     * @final should not be overridden 
    400480     */ 
     
    408488 
    409489 
    410     /** Holds the control-bound HTML elements per relation */ 
     490    /** 
     491    * Holds the control-bound HTML elements per relation 
     492    * @private  
     493    */ 
    411494    Control.prototype._elements; 
    412495 
    413     /** Holds the configuration parameters for finding/creation control bound HTML elements per relation */ 
     496    /**  
     497    * Holds the configuration parameters for finding/creation control bound HTML elements per relation 
     498    * @type Object  
     499    */ 
    414500    Control.prototype.elements = { 
    415501        messages : { 
     
    419505    }; 
    420506 
     507    /** 
     508    * Initializes element configurations 
     509    */ 
    421510    Control.prototype.initElementConfigs = function() { 
    422511 
    423512    } 
    424513 
     514    /** 
     515    * Gets an element configuration attribute based on it's relationship with the control 
     516    * @param {String} relation The elements relationship with the control 
     517    * @param {String} attribute Attribute name 
     518    * @return The sought after attribute 
     519    * @type Object 
     520    * @final 
     521    * @private 
     522    */ 
    425523    Control.prototype._getElementConfig = function( relation, attribute) { 
    426524 
     
    431529    } 
    432530 
     531    /** 
     532    * Gets the element selector for an element with the specified relationship 
     533    * @param {String} relation The elements relationship with the control 
     534    * @return The element selector 
     535    * @type String 
     536    */ 
    433537    Control.prototype.getElementSelector = function( relation) { 
    434538 
     
    436540    } 
    437541     
     542    /** 
     543    * Gets the create statement for an element with the specified relationship 
     544    * @param {String} relation The elements relationship with the control 
     545    * @return The create statement 
     546    * @type String 
     547    */ 
    438548    Control.prototype.getCreateElement = function( relation) { 
    439549 
     
    441551    } 
    442552     
     553    /** 
     554    * Sets a html element (jQuery wrapped) for a specific relationship 
     555    * @param {String} relation The elements relationship with the control 
     556    * @param {jQuery} $elm Html element, jQuery wrapped 
     557    */ 
    443558    Control.prototype.setElement = function( relation, $elm) { 
    444559 
     
    448563    } 
    449564     
     565    /** 
     566    * Gets a html element (jQuery) for a specific relationship 
     567    * @param {String} relation The elements relationship with the control 
     568    * @return The html element 
     569    * @type jQuery 
     570    */ 
    450571    Control.prototype.getElement = function( relation) { 
    451572 
     
    537658    /** 
    538659     * Perform control specific HTML element-binding on containment elements 
    539      *  
     660     * @param {Boolean} create Create the elements if they don't exist yet 
    540661     * @see #_initElements(create) 
    541662     */ 
     
    546667    /** 
    547668     * Initialize options (lists of possible values) for the control. 
     669     * @param {Boolean} create Create the option elements if they don't exist yet 
    548670     */ 
    549671    Control.prototype.initOptions = function(create) { 
     
    576698    /** 
    577699     * Perform control specific HTML updating of options 
     700     * @param {Array} values Option values 
     701     * @param {Array} labels Option labels 
    578702     */ 
    579703    Control.prototype.updateOptions = function( values, labels) { 
     
    586710    /** 
    587711     * Perform control specific HTML element-binding. 
    588      *  
     712     * @param {Boolean} create Creates the elements if they don't exist yet 
    589713     * @see #_initElements(create) 
    590714     */ 
     
    593717    } 
    594718 
    595  
     719    /** 
     720    * Initializes validation i.e. sets validation listeners 
     721    */ 
    596722    Control.prototype.initValidation = function() { 
    597723 
     
    599725    }; 
    600726 
    601     /** The input-element which change() event should trigger the update sequence. Undefinef disables update. */ 
     727    /**  
     728    * The input-element which change() event should trigger the update sequence. Undefinef disables update. 
     729    * @return The update element 
     730    * @type jQuery  
     731    */ 
    602732    Control.prototype.getUpdateElement = function() { 
    603733 
     
    681811     * formatting and validation is to be applied. 
    682812     */ 
    683     Control.prototype.update = function() { 
    684  
     813    Control.prototype.update = function() {             
    685814        var userVal = this.getUserValue(); 
    686815        this.updateUserValue(userVal); 
     
    702831    } 
    703832 
     833    /** 
     834    * Specifies that the value state is not yet known 
     835    * @static 
     836    * @final 
     837    */ 
    704838    Control.STATE_INIT = undefined; 
     839     
     840    /** 
     841    * Specifies that the value stored in the control has been deemed valid 
     842    * @static 
     843    * @final 
     844    */ 
    705845    Control.STATE_VALID = "valid"; 
     846     
     847    /** 
     848    * Specifies that the value stored in the control has been deemed invalid 
     849    * @static 
     850    * @final 
     851    */ 
    706852    Control.STATE_INVALID = "invalid"; 
     853     
     854    /** 
     855    * Specifies that validation is in progress 
     856    * @static 
     857    * @final 
     858    */ 
    707859    Control.STATE_IN_PROGRESS = "in-progress"; 
    708  
     860     
     861    /** 
     862    * Specifies that the control is hidded 
     863    * @static 
     864    * @final 
     865    */ 
     866    Control.STATE_HIDDEN = "hidden"; 
     867     
     868    /** 
     869    * Specifies that the control is visible 
     870    * @static 
     871    * @final 
     872    */ 
     873    Control.STATE_VISIBLE = "visible"; 
     874     
     875    /** 
     876    * Specifies that the control is enabled 
     877    * @static 
     878    * @final 
     879    */ 
     880    Control.STATE_ENABLED = "enabled"; 
     881     
     882    /** 
     883    * Specifies that the control has been disabled 
     884    * @static 
     885    * @final 
     886    */ 
     887    Control.STATE_DISABLED = "disabled"; 
     888 
     889    /** 
     890    * The controls value state. This is used to find out if the contained value is valid or not and all states in between 
     891    */ 
    709892    Control.prototype.valueState = Control.STATE_INIT; 
     893     
     894    /** 
     895    * The controls view state, is it visible or not 
     896    */  
     897    Control.prototype.viewState = Control.STATE_VISIBLE; 
     898     
     899    /** 
     900    * Can a control be manipulated or not, enabled/disabled. 
     901    */ 
     902    Control.prototype.operationalState = Control.STATE_ENABLED; 
    710903 
    711904    /** 
    712905     * Sets the user-value and triggers formatting and validating as would actual editing. 
     906     * @param {Object} userValue  
     907     * @param {Boolean} noValidation Should validation be done or not 
    713908     */ 
    714909    Control.prototype.updateUserValue = function( userValue, noValidation) { 
     
    724919    } 
    725920 
     921    /** 
     922    * Handles errors produced by funky values 
     923    * @param {Error} e The error object  
     924    */ 
    726925    Control.prototype.handleValueError = function( e) { 
    727926 
     
    731930    } 
    732931 
    733     Control.prototype.isValid = function(forceValidation) { 
    734  
     932    /** 
     933    * Checks if the control is valid 
     934    * @param {Boolean} forceValidation Force the validation if the control has been changed or not 
     935    * @return Is the control valid or not 
     936    * @type Boolean 
     937    */ 
     938    Control.prototype.isValid = function(forceValidation) {             
    735939        forceValidation = forceValidation || false; 
    736940         
     
    741945    } 
    742946 
     947    /** 
     948    * Sets the controls value 
     949    * @param {Object} value 
     950    * @param {Boolean} noValidation Should validation be done after setting the value?     
     951    */ 
    743952    Control.prototype.setValue = function( value, noValidation) { 
    744  
    745953        noValidation = noValidation || false; 
    746954         
     
    761969    }; 
    762970 
     971    /** 
     972    * Gets the controls value 
     973    * @return The value 
     974    * @type Object 
     975    */ 
    763976    Control.prototype.getValue = function() { 
    764977 
     
    766979    }; 
    767980 
     981    /** 
     982    * Gets the controls wirevalue. The wirevalue is the value formatted in a manner that can be communicated to other services 
     983    * @return the wire value 
     984    * @type Object 
     985    */ 
    768986    Control.prototype.getWireValue = function() { 
    769987 
     
    781999    } 
    7821000 
     1001    /** 
     1002    * Sets the wire value 
     1003    * @param {Object} wireValue 
     1004    */ 
    7831005    Control.prototype.setWireValue = function( wireValue) { 
    7841006 
     
    7931015 
    7941016    /** 
     1017     * Sets the original value of a control 
     1018     * @param {Object} value the original value 
    7951019     * @private Not meant to be called externally, is called internally as a side effect of setWireValue. 
    7961020     */ 
     
    8001024    } 
    8011025 
     1026    /** 
     1027    * Checks if a control has changes 
     1028    * @return if a controls has changes or not 
     1029    * @type Boolean 
     1030    */ 
    8021031    Control.prototype.hasChanges = function() { 
    8031032 
     
    8051034    } 
    8061035 
     1036    /** 
     1037    * Checks if the provided value equals the value currently stored in the control 
     1038    * @param {Object} thatValue The value to check against 
     1039    * @return equals or not 
     1040    * @type Boolean 
     1041    */ 
    8071042    Control.prototype.valueEquals = function( thatValue) { 
    8081043 
     
    8131048    } 
    8141049 
     1050    /** 
     1051    * Validates the provided value using the configured validators 
     1052    * @param  {Object} value     
     1053    */ 
    8151054    Control.prototype.newValidation = function( value) { 
    816      
    8171055        if (this.getType().validators.length == 0) { 
    8181056            // if there are no validators then we must assume that the control is valid 
     
    8251063    } 
    8261064 
     1065    /** 
     1066    * Gets the validation data 
     1067    * @return 
     1068    * @type Object 
     1069    */     
    8271070    Control.prototype.getValidationData = function() { 
    8281071        return {control: this, options: this.getOptionValues()}; 
    8291072    } 
    8301073     
     1074    /** 
     1075    * Retrieve the controls options values 
     1076    * @return an array of values 
     1077    * @type Array 
     1078    */ 
    8311079    Control.prototype.getOptionValues = function() { 
    8321080        if (this.options == undefined || this.options.getValues == undefined) 
     
    8351083    } 
    8361084     
     1085    /** 
     1086    * What to do when a validation is successful 
     1087    */ 
    8371088    Control.prototype.validationSuccess = function() { 
    8381089 
    8391090    } 
    8401091 
     1092    /** 
     1093    * Things to do before the validation begins 
     1094    */ 
    8411095    Control.prototype.validationStart = function() { 
    8421096 
     
    8451099    } 
    8461100 
     1101    /** 
     1102    * Things to do when a validation is complete 
     1103    */ 
    8471104    Control.prototype.validationComplete = function() { 
    8481105 
     
    8631120    } 
    8641121 
     1122    /** 
     1123    * What to do when a validation fails 
     1124    * @param {String} message What is displayed as a validation failed message 
     1125    */ 
    8651126    Control.prototype.validationFail = function( message) { 
    8661127 
     
    8681129    } 
    8691130 
     1131    /** 
     1132    * Sets a message in the controls message element, if there is any 
     1133    * @param {String} msg Message to be displayed 
     1134    */ 
    8701135    Control.prototype.setMessage = function( msg) { 
    871  
     1136         
    8721137        var msgElm = this.getElement("messages"); 
    8731138        if (msgElm) { 
     
    8841149    } 
    8851150 
     1151    /** 
     1152    * Clears the controls message 
     1153    */ 
    8861154    Control.prototype.clearMessage = function() { 
    887  
     1155         
    8881156        this.setMessage(""); 
    8891157    } 
    8901158 
    891  
     1159    /** 
     1160    * Gives a string representation of the control 
     1161    * @return a string representation of the control 
     1162    * @type String 
     1163    */ 
    8921164    Control.prototype.toString = function() { 
    8931165 
     
    8951167    }; 
    8961168 
    897  
     1169    /** 
     1170    * Gets this controls absolute id. This means including all the ids of possible parent controls 
     1171    * @return absolute id or id-path 
     1172    * @type String 
     1173    */ 
    8981174    Control.prototype.getAbsoluteId = function() { 
    8991175 
     
    9081184 
    9091185    // TODO support 'match-patterns' allowing to return arrays of controls on which some jqyery like each() can then execute 
    910  
     1186    /** 
     1187    * Finds a control by checking it's path. This path can be a string representation or an array of path segments. 
     1188    * @param {Object} arg {String} path or an {Array} of path segments   
     1189    * @return A control 
     1190    * @type Control 
     1191    */ 
    9111192    Control.prototype.findControl = function() { 
    9121193 
     
    9221203    } 
    9231204 
     1205    /** 
     1206    * Finds a control using a string representation of a path 
     1207    * @param {String} path  
     1208    * @return A control 
     1209    * @type Control 
     1210    */    
    9241211    Control.prototype._findControlByPath = function( path) { 
    9251212 
     
    9291216    } 
    9301217 
     1218    /** 
     1219    * Finds a control using an array of path segments 
     1220    * @param {Array} path segments  
     1221    * @return A control 
     1222    * @type Control 
     1223    */  
    9311224    Control.prototype._findControlBySegments = function( segments) { 
    9321225 
     
    9471240            return target; 
    9481241    } 
    949  
    950     /** 
     1242     
     1243    /** 
     1244    * Hides all elements in the control 
     1245    */ 
     1246    Control.prototype.hide = function () { 
     1247        for (var rel in this._elements) { 
     1248            this._elements[rel].hide(); 
     1249        } 
     1250        this.viewState = Control.STATE_HIDDEN; 
     1251    } 
     1252     
     1253    /** 
     1254    * Makes control and all elements in the control visible 
     1255    */ 
     1256    Control.prototype.show = function () { 
     1257        for (var rel in this._elements) { 
     1258            this._elements[rel].show(); 
     1259        } 
     1260        this.viewState = Control.STATE_VISIBLE; 
     1261    } 
     1262         
     1263    /** 
     1264    * Enables the control for writing 
     1265    */ 
     1266    Control.prototype.enable = function () { 
     1267        for (var rel in this._elements) { 
     1268            var el = this._elements[rel]; 
     1269            if (el.is(":disabled")) { 
     1270                el.removeAttr("disabled"); 
     1271            } 
     1272            el.removeClass("disabled"); 
     1273        } 
     1274        this.operationalState = Control.STATE_ENABLED; 
     1275    } 
     1276     
     1277    /** 
     1278    * Disables the control 
     1279    */ 
     1280    Control.prototype.disable = function () { 
     1281        for (var rel in this._elements) { 
     1282            var el = this._elements[rel]; 
     1283            if (el.is(":enabled")) { 
     1284                el.attr("disabled", "disabled"); 
     1285            } 
     1286            el.addClass("disabled");              
     1287        } 
     1288        this.operationalState = Control.STATE_DISABLED; 
     1289    } 
     1290 
     1291    /* 
    9511292     * GETTERS & SETTERS 
    9521293     */ 
    9531294 
     1295    /** 
     1296    * Gets the controls id 
     1297    * @return the id 
     1298    * @type String 
     1299    */ 
    9541300    Control.prototype.getId = function() { 
    9551301 
     
    9571303    } 
    9581304 
     1305    /** 
     1306    * Get the controls form control 
     1307    * @return a form object 
     1308    * @type Form 
     1309    */ 
    9591310    Control.prototype.getForm = function() { 
    9601311 
     
    9621313    } 
    9631314 
     1315    /** 
     1316    * Sets the controls field type 
     1317    * @param {FieldType} type The Field type to be used for this control     
     1318    */ 
    9641319    Control.prototype.setType = function( type) { 
    9651320 
     
    9671322    }; 
    9681323 
     1324    /** 
     1325    * Gets the controls field type 
     1326    * @return the controls type 
     1327    * @type FieldType 
     1328    */     
    9691329    Control.prototype.getType = function() { 
    9701330 
     
    9721332    } 
    9731333 
     1334    /**  
     1335    * Gets the controls parent 
     1336    * @return the parent control 
     1337    * @type Control 
     1338    */ 
    9741339    Control.prototype.getParent = function() { 
    9751340 
     
    9791344    $.inherit(AbstractContainerControl, Control); 
    9801345 
     1346    /** 
     1347    * @class The base class to be used by all other container controls 
     1348    * @extends Control 
     1349    * @constructor 
     1350    * @param {String} id. Control Id 
     1351    * @param {Form} form. The form that should contain this control 
     1352    * @param {Object} conf. The configuration     
     1353    */ 
    9811354    function AbstractContainerControl( id, form, conf) { 
    9821355 
     
    9841357    } 
    9851358 
     1359    /** 
     1360    * Creates a blank value 
     1361    * @return a blank value 
     1362    * @type Object 
     1363    */  
    9861364    AbstractContainerControl.prototype.newBlankValue = function() { 
    9871365 
     
    9891367    }; 
    9901368 
    991     //** Indicates initValue was called from parent already, and should be called on children from now on. 
     1369    /**  
     1370    * Indicates initValue was called from parent already, and should be called on children from now on. 
     1371    * @type boolean 
     1372    */ 
    9921373    AbstractContainerControl.prototype.childInitValue = false; 
    9931374     
    994     /** Holds the configuration parameters for finding/creation control bound HTML elements per relation */ 
     1375    /**  
     1376    * Holds the configuration parameters for finding/creation control bound HTML elements per relation 
     1377    * @type object  
     1378    */ 
    9951379    AbstractContainerControl.prototype.elements = {}; 
    9961380    $.extend(AbstractContainerControl.prototype.elements, Control.prototype.elements); 
     
    10041388    }); 
    10051389 
     1390    /** 
     1391    * Gets the values from all children  
     1392    * @param {String} getMethodName Getter method name <ul><li>getUserValue</li><li>getWireValue</li></ul> 
     1393    * @return an array containing the values found in the this controls child controls  
     1394    * @type Array 
     1395    * @private 
     1396    */ 
    10061397    AbstractContainerControl.prototype.getValueLoop = function( getMethodName) { 
    10071398 
     
    10091400 
    10101401        var children = this.getChildren(); 
    1011  
     1402         
    10121403        // loop trough all contained elements ('rows or members'), and get their value 
    10131404        for ( var i in children) { 
     
    10181409    } 
    10191410 
     1411    /** 
     1412    * Sets the values for all of this controls children 
     1413    * @param {String} setMethodName The setters method name <ul><li>setUserValue</li><li>setWireValue</li></ul> 
     1414    * @param {Array} value The values should be ordered in the same order as the children 
     1415    * @private 
     1416    */ 
    10201417    AbstractContainerControl.prototype.setValueLoop = function( setMethodName, value) { 
    10211418 
    10221419        // ignore childUpdates 
    10231420        var restore = this.updateValue; 
    1024         this.updateValue = function(){}; 
     1421        this.updateValue = function( childControl ){}; 
    10251422         
    10261423        // loop trough all contained elements ('rows or members'), and set their value 
     
    10371434    } 
    10381435 
     1436    /** 
     1437    * Gets the values of all child controls in user format 
     1438    * @return an array of values found in the child controls. These values are in user format 
     1439    * @type Array 
     1440    */ 
    10391441    AbstractContainerControl.prototype.getUserValue = function() { 
    10401442 
    10411443        return this.getValueLoop("getUserValue"); 
    10421444    } 
    1043  
     1445     
     1446    /** 
     1447    * Sets the values for all of this controls children. The value is expected to be in user format     
     1448    * @param {Array} value The values should be ordered in the same order as the children 
     1449    */ 
    10441450    AbstractContainerControl.prototype.setUserValue = function( value) { 
    10451451 
     
    10471453    } 
    10481454 
     1455    /** 
     1456    * Gets the values from all children 
     1457    * @return an array containing the values found in the this controls child controls  
     1458    * @type Array 
     1459    * @private 
     1460    */ 
    10491461    AbstractContainerControl.prototype.getValue = function() { 
    10501462 
     
    10521464    } 
    10531465 
     1466    /** 
     1467    * Sets the values for all of this controls children     
     1468    * @param {Array} value The values should be ordered in the same order as the children 
     1469    * @private 
     1470    */ 
    10541471    AbstractContainerControl.prototype.setValue = function( value) { 
    10551472 
     
    10581475    } 
    10591476 
     1477    /** 
     1478    * Gets the values from all children.     
     1479    * @return an array containing the values found in the this controls child controls. The values returned will be in wire format  
     1480    * @type Array     
     1481    */ 
    10601482    AbstractContainerControl.prototype.getWireValue = function() { 
    10611483 
    10621484        return this.getValueLoop("getWireValue"); 
    10631485    } 
    1064  
     1486    /** 
     1487    * Sets the values for all of this controls children. The value is expected to be in wire format     
     1488    * @param {Array} value The values should be ordered in the same order as the children     
     1489    */ 
    10651490    AbstractContainerControl.prototype.setWireValue = function( value) { 
    10661491 
     
    10681493    } 
    10691494 
     1495    /** 
     1496    * Sets the original value of the control (This doesn't do anything) 
     1497    * @param {Object} value     
     1498    */ 
    10701499    AbstractContainerControl.prototype.setOriginalValue = function( value) { 
    10711500 
    10721501    } 
    10731502 
     1503    /** 
     1504    * Checks if there are any changes in the child controls 
     1505    * @return  
     1506    * @type boolean 
     1507    */ 
    10741508    AbstractContainerControl.prototype.hasChanges = function() { 
    10751509 
     
    10821516    } 
    10831517 
     1518    /** 
     1519    * Always returns false 
     1520    * @param {object} thatValue 
     1521    */ 
    10841522    AbstractContainerControl.prototype.valueEquals = function( thatValue) { 
    10851523 
     
    10881526 
    10891527 
     1528    /** 
     1529    * Doesn't do anything 
     1530    */ 
    10901531    AbstractContainerControl.prototype.clearChildValues = function() { 
    10911532 
    10921533    }; 
    10931534 
     1535    /** 
     1536    * Gets all child controls 
     1537    * @return object containing all the children 
     1538    * @type Object 
     1539    */ 
    10941540    AbstractContainerControl.prototype.getChildren = function() { 
    10951541 
     
    10971543    } 
    10981544 
     1545    /** 
     1546    * Gets a child by it's ID 
     1547    * @param {String} id 
     1548    * @return the child 
     1549    * @type Control 
     1550    */ 
    10991551    AbstractContainerControl.prototype.getChild = function( id) { 
    11001552 
     
    11021554    } 
    11031555 
     1556    /** 
     1557    * Initializes typical container elements 
     1558    * @param {Boolean} create If true it will create the container elements if the don't already exist 
     1559    * @private 
     1560    */ 
    11041561    AbstractContainerControl.prototype.initContainerElements = function( create) { 
    11051562 
     
    11091566        } 
    11101567        var layout = ControlElements.lookup(this, ControlElements.REV_LAYOUT, create); 
    1111         if (layout) { 
     1568        if (layout) {             
    11121569            layout.hide(); 
    11131570        } 
     
    11191576 
    11201577    /** 
     1578     * the item selector 
    11211579     * @final 
    11221580     */ 
     
    11261584     * Creates the HTML elements for hosting a new child-id by cloning the "layout" section into the "container" section This will 
    11271585     * also register the newly created elements into the 
    1128      *  
     1586     * @param {String} id Id to be used to the newly created child 
     1587     * @return the new control elements 
     1588     * @type jQuery 
    11291589     * @final 
    11301590     */ 
     
    11511611    } 
    11521612 
     1613    /** 
     1614    * Creates a new control based on type but doesn't add it to the list of children 
     1615    * @param {String} id The id of the new child control 
     1616    * @param {FieldType} type The childs field type 
     1617    * @return the child control 
     1618    * @type Control  
     1619    */ 
    11531620    AbstractContainerControl.prototype.createChildControl = function( id, type) { 
    11541621 
     
    11861653        return childControl; 
    11871654    } 
    1188  
     1655     
     1656    /** 
     1657    * Places a the child control in the list of this controls children 
     1658    * @param {String} id  
     1659    * @param {Control} childControl 
     1660    */ 
    11891661    AbstractContainerControl.prototype.putChild = function( id, childControl) { 
    11901662 
     
    11921664    } 
    11931665     
     1666    /** 
     1667    * Runs validation on this control and acknowledges a change in value 
     1668    * @param {Control} childControl     
     1669    */ 
    11941670    AbstractContainerControl.prototype.updateValue = function(childControl) { 
    11951671        this.newValidation(this.getValue()); 
     
    11971673    } 
    11981674 
     1675    /** 
     1676    * Checks if this control and all it's child controls are valid 
     1677    * @param {Boolean} forceValidation Does the validation if changes have been made or not 
     1678    */ 
    11991679    AbstractContainerControl.prototype.isValid = function(forceValidation) { 
    12001680        var valid = this["<super.call>"]("isValid", [forceValidation]); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/js/testPage.html

    r606 r643  
    3030  <script type="text/javascript" src="../../main/kauri/js/collection.js" ></script> 
    3131  <script type="text/javascript" src="../../main/kauri/js/composite.js" ></script> 
     32  <script type="text/javascript" src="../../main/kauri/js/case.js" ></script> 
    3233  <script type="text/javascript" src="../../main/kauri/js/date.js" ></script> 
    3334  <script type="text/javascript" src="../../main/kauri/js/form.js" ></script> 
     
    5859  <script type="text/javascript" src="test-composite.js" ></script> 
    5960  <script type="text/javascript" src="test-collection.js" ></script> 
     61  <script type="text/javascript" src="test-case.js" ></script> 
    6062  <script type="text/javascript" src="test-form.js" ></script> 
    6163  <script type="text/javascript" src="test-date.js" ></script> 
     64   
     65  <link rev="stylesheet" src="../../main/kauri/public/css/datepicker.css"/> 
    6266   
    6367</head> 
Note: See TracChangeset for help on using the changeset viewer.