dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14007
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4606: wip, started adding macros for dynamic attributes (ui)
------------------------------------------------------------
revno: 4606
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-09-16 17:55:47 +0200
message:
wip, started adding macros for dynamic attributes (ui)
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-09-12 04:02:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-09-16 15:55:47 +0000
@@ -400,14 +400,14 @@
"attribute" : {
"name" : {
"required" : true,
- "rangelength" : [ 3, 230 ],
+ "rangelength" : [ 2, 230 ],
"alphanumericwithbasicpuncspaces" : true
}
},
"attributeOption" : {
"name" : {
"required" : true,
- "rangelength" : [ 3, 230 ],
+ "rangelength" : [ 2, 230 ],
"alphanumericwithbasicpuncspaces" : true
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2011-04-04 16:47:24 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2011-09-16 15:55:47 +0000
@@ -126,3 +126,124 @@
</div>
</form>
#end
+
+#* Helpers for building attribute forms. Note that these will have dynamic validation rules applied to them. *#
+
+#macro( trHeader $text )
+<tr>
+ <th colspan="2">$text</th>
+</tr>
+#end
+
+#macro( trTextInput $text $name )
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <input type="text" id="$name" name="$name" style="width: 240px;" />
+ </td>
+</tr>
+#end
+
+#macro( trBooleanSelectInput $text $name )
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <select style="width: 244px;" id="$name" name="$name">
+ <option>Yes</option>
+ <option>No</option>
+ </select>
+ </td>
+</tr>
+#end
+
+#macro( trDateInput $text $name )
+<script type="text/javascript">
+jQuery(function() {
+ jQuery("#$name").datepicker();
+});
+</script>
+
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <input type="text" id="$name" name="$name" style="width: 240px;" />
+ </td>
+</tr>
+#end
+
+#macro( trDecimalInput $text $name )
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <input type="text" id="$name" name="$name" style="width: 240px;" />
+ </td>
+</tr>
+#end
+
+#macro( trIntegerInput $text $name )
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <input type="text" id="$name" name="$name" style="width: 240px;" />
+ </td>
+</tr>
+#end
+
+#macro( trPositiveIntegerInput $text $name )
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <input type="text" id="$name" name="$name" style="width: 240px;" />
+ </td>
+</tr>
+#end
+
+#macro( trNegativeIntegerInput $text $name )
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <input type="text" id="$name" name="$name" style="width: 240px;" />
+ </td>
+</tr>
+#end
+
+#macro( trMultipleSelectInput $text $name $choices )
+<tr>
+ <td style="width: 200px;">$text</td>
+ <td>
+ <select style="width: 244px;" id="$name" name="$name">
+ #foreach( $choice in $choices )
+ <option>$choice</option>
+ #end
+ </select>
+ </td>
+</tr>
+#end
+
+#macro( tblDynamicAttributes $attributes )
+<div id="dynamicAttributesContainer" style="margin-top: 20px;">
+<table>
+ #trHeader( "Dynamic Attributes" )
+
+ #foreach( $attribute in $attributes )
+ #if( $attribute.valueType == "string" )
+ #trTextInput( $attribute.name "text" )
+ #elseif( $attribute.valueType == "bool" )
+ #trBooleanSelectInput( $attribute.name "booleanAttribute" )
+ #elseif( $attribute.valueType == "date" )
+ #trDateInput( $attribute.name "dateAttribute" )
+ #elseif( $attribute.valueType == "decimal" )
+ #trDecimalInput( $attribute.name "decimalAttribute" )
+ #elseif( $attribute.valueType == "integer" )
+ #trIntegerInput( $attribute.name "integerAttribute" )
+ #elseif( $attribute.valueType == "positive_integer" )
+ #trPositiveIntegerInput( $attribute.name "positiveIntegerAttribute" )
+ #elseif( $attribute.valueType == "negative_integer" )
+ #trNegativeIntegerInput( $attribute.name "negativeIntegerAttribute" )
+ #elseif( $attribute.valueType == "multiple_choice" )
+ #trMultipleSelectInput( $attribute.name "multipleSelectAttribute" [ "One", "Two", "Three" ] )
+ #end
+ #end
+</table>
+</div>
+#end
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2011-09-08 19:22:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2011-09-16 15:55:47 +0000
@@ -71,10 +71,10 @@
<option value="string">$i18n.getString( "text" )</option>
<option value="bool">$i18n.getString( "yes_no" )</option>
<option value="date">$i18n.getString( "date" )</option>
- <option value="number">$i18n.getString( "number" )</option>
- <option value="int" >$i18n.getString( "int" )</option>
- <option value="positiveNumber">$i18n.getString( "positiveNumber" )</option>
- <option value="negativeNumber">$i18n.getString( "negativeNumber" )</option>
+ <option value="decimal">$i18n.getString( "decimal" )</option>
+ <option value="integer" >$i18n.getString( "integer" )</option>
+ <option value="positive_integer">$i18n.getString( "positive_integer" )</option>
+ <option value="negative_integer">$i18n.getString( "negative_integer" )</option>
<option value="multiple_choice">$i18n.getString( "multiple_choice" )</option>
</select>
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm 2011-09-08 19:22:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm 2011-09-16 15:55:47 +0000
@@ -72,10 +72,10 @@
<option value="string" #if( $attribute.valueType == 'string') selected="selected" #end>$i18n.getString( "text" )</option>
<option value="bool" #if( $attribute.valueType == 'bool') selected="selected" #end>$i18n.getString( "yes_no" )</option>
<option value="date" #if( $attribute.valueType == 'date') selected="selected" #end>$i18n.getString( "date" )</option>
- <option value="number" #if( $attribute.valueType == 'number') selected="selected" #end>$i18n.getString( "number" )</option>
- <option value="int" #if( $attribute.valueType == 'int') selected="selected" #end>$i18n.getString( "int" )</option>
- <option value="positiveNumber" #if( $attribute.valueType == 'positiveNumber') selected="selected" #end>$i18n.getString( "positiveNumber" )</option>
- <option value="negativeNumber" #if( $attribute.valueType == 'negativeNumber') selected="selected" #end>$i18n.getString( "negativeNumber" )</option>
+ <option value="decimal" #if( $attribute.valueType == 'decimal') selected="selected" #end>$i18n.getString( "decimal" )</option>
+ <option value="integer" #if( $attribute.valueType == 'integer') selected="selected" #end>$i18n.getString( "integer" )</option>
+ <option value="positive_integer" #if( $attribute.valueType == 'positive_integer') selected="selected" #end>$i18n.getString( "positive_integer" )</option>
+ <option value="negative_integer" #if( $attribute.valueType == 'negative_integer') selected="selected" #end>$i18n.getString( "negative_integer" )</option>
<option value="multiple_choice" #if( $attribute.valueType == 'multiple_choice') selected="selected" #end>$i18n.getString( "multiple_choice" )</option>
</select>
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm 2011-09-16 13:47:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm 2011-09-16 15:55:47 +0000
@@ -144,15 +144,7 @@
</div>
-<table>
- <tr>
- <th style="width:450px">Dynamic Attributes</th>
- </tr>
- <tr>
- <td>Text</td>
- <td><input /></td>
- </tr>
-</table>
+#tblDynamicAttributes( $attributes )
<p>
<input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/>