dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11023
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3058: finished separation of vm/js (and validation rules) for dhis-web-maintenance-dataset
------------------------------------------------------------
revno: 3058
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-03-17 13:08:11 +0100
message:
finished separation of vm/js (and validation rules) for dhis-web-maintenance-dataset
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addSection.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editSection.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.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-03-16 16:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-03-17 12:08:11 +0000
@@ -74,5 +74,37 @@
"description": {
"length": [2, 255]
}
+ },
+
+ /* dhis-web-maintenance-dataset */
+ "dataEntry": {
+ "name": {
+ "length": [4, 100]
+ }
+ },
+ "section": {
+ "name": {
+ "length": [2, 160]
+ },
+ "selectedList": {
+
+ }
+ },
+ "dataSet": {
+ "name": {
+ "alphanumericwithbasicpuncspaces": true,
+ "firstletteralphabet": false,
+ "length": [4, 150]
+ },
+ "shortName": {
+ "alphanumericwithbasicpuncspaces": true,
+ "firstletteralphabet": false,
+ "length": [2, 20]
+ },
+ "code": {
+ "alphanumericwithbasicpuncspaces": true,
+ "notOnlyDigits": false,
+ "length": [4, 40]
+ }
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2011-01-27 10:07:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2011-03-17 12:08:11 +0000
@@ -1,15 +1,5 @@
-<script>
- jQuery(document).ready( function()
- {
- validation( 'addDataSetForm', function( form ){ form.submit() }, function() {
- selectAllById('selectedList')
- });
-
- checkValueIsExist( "name", "validateDataSet.action" );
- checkValueIsExist( "shortName", "validateDataSet.action" );
- checkValueIsExist( "code", "validateDataSet.action" );
- });
-
+<script type="text/javascript" src="javascript/addDataSet.js"></script>
+<script type="text/javascript">
var previousName = '';
</script>
@@ -27,22 +17,20 @@
<tbody>
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="name" name="name" onchange="nameChanged()" style="width:20em" maxlength="150"
- class="{validate:{required:true,minlength:4,alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}"/>
- </td>
+ <td><input type="text" id="name" name="name" onchange="nameChanged()" style="width:20em"></td>
</tr>
<tr>
<td><label>$i18n.getString( "short_name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="shortName" name="shortName" style="width:20em" maxlength="20" class="{validate:{required:true,minlength:2,alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}"/></td>
+ <td><input type="text" id="shortName" name="shortName" style="width:20em"></td>
</tr>
<tr>
<td><label>$i18n.getString( "code" )</label></td>
- <td><input type="text" id="code" name="code" style="width:20em" maxlength="40" class="{validate:{minlength:4,alphanumericwithbasicpuncspaces:true,notOnlyDigits:false}}"/></td>
+ <td><input type="text" id="code" name="code" style="width:20em"></td>
</tr>
<tr>
<td><label>$i18n.getString( "frequency" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td>
- <select id="frequencySelect" name="frequencySelect" style="min-width:20em" class="{validate:{required:true}}">
+ <select id="frequencySelect" name="frequencySelect" style="min-width:20em">
#foreach ( $periodType in $periodTypes )
<option value="$periodType.name">$i18n.getString( $periodType.name )</option>
#end
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addSection.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addSection.vm 2011-01-27 10:07:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addSection.vm 2011-03-17 12:08:11 +0000
@@ -1,16 +1,4 @@
-<script>
- jQuery(document).ready( function()
- {
- validation( 'addSectionForm', function( form ){ form.submit() }, function() {
- selectAllById('selectedList')
- });
-
- checkValueIsExist( "sectionName", "validateSection.action", {
- dataSetId: $("#dataSetId").val(),
- name: $("#sectionName").val()
- });
- });
-</script>
+<script type="text/javascript" src="javascript/addSection.js"></script>
<h3>$i18n.getString( "add_section" ) #openHelp( "dataset_sections_edit" )</h3>
@@ -26,7 +14,7 @@
<tbody>
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="sectionName" name="sectionName" style="width:20em" maxlength="160" class="{validate:{required:true,minlength:2}}"/></td>
+ <td><input type="text" id="sectionName" name="sectionName" style="width:20em"></td>
</tr>
<tr>
<td><label>$i18n.getString( "dataset" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
@@ -73,7 +61,7 @@
<input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'selectedList', 'availableList' );"/>
</td>
<td>
- <select id="selectedList" name="selectedList" multiple="multiple" style="min-width:25em;height:20em" class="{validate:{required:true}}" ondblclick="moveSelected( this, document.getElementById( 'availableList' ) )">
+ <select id="selectedList" name="selectedList" multiple="multiple" style="min-width:25em;height:20em" ondblclick="moveSelected( this, document.getElementById( 'availableList' ) )">
</select>
</td>
<td style="width:30px; text-align:center">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2011-03-03 06:16:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2011-03-17 12:08:11 +0000
@@ -1,15 +1,5 @@
-<script>
- jQuery(document).ready( function()
- {
- validation( 'editDataSetForm', function( form ){ form.submit() }, function() {
- selectAllById('selectedList')
- });
-
- checkValueIsExist( "name", "validateDataSet.action", {dataSetId: $("#dataSetId").val()} );
- checkValueIsExist( "shortName", "validateDataSet.action", {dataSetId: $("#dataSetId").val()} );
- checkValueIsExist( "code", "validateDataSet.action", {dataSetId: $("#dataSetId").val()} );
- });
-
+<script type="text/javascript" src="javascript/editDataSet.js"></script>
+<script type="text/javascript">
var previousName = '';
</script>
@@ -27,15 +17,15 @@
<tbody>
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="name" name="name" style="width:20em" value="$!encoder.htmlEncode( $dataSet.name )" maxlength="150" class="{validate:{required:true,minlength:4,alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}"/></td>
+ <td><input type="text" id="name" name="name" style="width:20em" value="$!encoder.htmlEncode( $dataSet.name )"></td>
</tr>
<tr>
<td><label>$i18n.getString( "short_name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="shortName" name="shortName" style="width:20em" value="$!encoder.htmlEncode( $dataSet.shortName )" maxlength="20" class="{validate:{required:true,minlength:2,alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}"/></td>
+ <td><input type="text" id="shortName" name="shortName" style="width:20em" value="$!encoder.htmlEncode( $dataSet.shortName )"></td>
</tr>
<tr>
<td><label>$i18n.getString( "code" )</label></td>
- <td><input type="text" id="code" name="code" style="width:20em" value="$!encoder.htmlEncode( $dataSet.code )" maxlength="40" class="{validate:{minlength:4,alphanumericwithbasicpuncspaces:true,notOnlyDigits:false}}"/></td>
+ <td><input type="text" id="code" name="code" style="width:20em" value="$!encoder.htmlEncode( $dataSet.code )"></td>
</tr>
<tr>
<td><label>$i18n.getString( "frequency" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editSection.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editSection.vm 2011-01-27 10:07:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editSection.vm 2011-03-17 12:08:11 +0000
@@ -1,17 +1,4 @@
-<script>
- jQuery(document).ready( function()
- {
- validation( 'editDataSetForm', function( form ){ form.submit() }, function() {
- selectAllById('selectedList')
- });
-
- checkValueIsExist( "sectionName", "validateSection.action", {
- dataSetId:$("#dataSetId").val(),
- name: $("#sectionName").val(),
- sectionId: $("#sectionId").val()
- });
- });
-</script>
+<script type="text/javascript" src="javascript/editSection.js"></script>
<h3>$i18n.getString( "edit_section" )</h3>
@@ -31,7 +18,7 @@
<tbody>
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="sectionName" name="sectionName" style="width:20em" value= "$section.name" maxlength="160" class="{validate:{required:true,minlength:2}}"/></td>
+ <td><input type="text" id="sectionName" name="sectionName" style="width:20em" value= "$section.name"></td>
</tr>
<tr>
<td><label>$i18n.getString( "dataset" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js 2011-03-17 12:08:11 +0000
@@ -0,0 +1,46 @@
+jQuery( document ).ready( function()
+{
+ var r = getValidationRules();
+
+ var rules = {
+ name : {
+ required : true,
+ alphanumericwithbasicpuncspaces : r.dataSet.name.alphanumericwithbasicpuncspaces,
+ firstletteralphabet : r.dataSet.name.firstletteralphabet,
+ rangelength : r.dataSet.name.length
+ },
+ shortName : {
+ required : true,
+ alphanumericwithbasicpuncspaces : r.dataSet.shortName.alphanumericwithbasicpuncspaces,
+ firstletteralphabet : r.dataSet.shortName.firstletteralphabet,
+ rangelength : r.dataSet.shortName.length
+ },
+ code : {
+ alphanumericwithbasicpuncspaces : r.dataSet.code.alphanumericwithbasicpuncspaces,
+ notOnlyDigits : r.dataSet.code.notOnlyDigits,
+ rangelength : r.dataSet.code.length
+ },
+ frequencySelect : {
+ required : true
+ }
+ };
+
+ validation2( 'addDataSetForm', function( form )
+ {
+ form.submit()
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ selectAllById( 'selectedList' )
+ },
+ 'rules' : rules
+ } );
+
+ jQuery( "#name" ).attr( "maxlength", r.dataSet.name.length[1] );
+ jQuery( "#shortName" ).attr( "maxlength", r.dataSet.shortName.length[1] );
+ jQuery( "#code" ).attr( "maxlength", r.dataSet.code.length[1] );
+
+ checkValueIsExist( "name", "validateDataSet.action" );
+ checkValueIsExist( "shortName", "validateDataSet.action" );
+ checkValueIsExist( "code", "validateDataSet.action" );
+} );
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js 2011-03-17 12:08:11 +0000
@@ -0,0 +1,32 @@
+jQuery( document ).ready( function()
+{
+ var r = getValidationRules();
+
+ var rules = {
+ sectionName : {
+ required : true,
+ rangelength : r.section.name.length
+ },
+ selectedList : {
+ required : true
+ }
+ };
+
+ validation2( 'addSectionForm', function( form )
+ {
+ form.submit()
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ selectAllById( 'selectedList' )
+ },
+ 'rules' : rules
+ } );
+
+ jQuery( "#sectionName" ).attr( "maxlength", r.section.name.length[1] );
+
+ checkValueIsExist( "sectionName", "validateSection.action", {
+ dataSetId : jQuery( "#dataSetId" ).val(),
+ name : jQuery( "#sectionName" ).val()
+ } );
+} );
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js 2011-03-17 12:08:11 +0000
@@ -0,0 +1,53 @@
+jQuery( document ).ready( function()
+{
+ var r = getValidationRules();
+
+ var rules = {
+ name : {
+ required : true,
+ alphanumericwithbasicpuncspaces : r.dataSet.name.alphanumericwithbasicpuncspaces,
+ firstletteralphabet : r.dataSet.name.firstletteralphabet,
+ rangelength : r.dataSet.name.length
+ },
+ shortName : {
+ required : true,
+ alphanumericwithbasicpuncspaces : r.dataSet.shortName.alphanumericwithbasicpuncspaces,
+ firstletteralphabet : r.dataSet.shortName.firstletteralphabet,
+ rangelength : r.dataSet.shortName.length
+ },
+ code : {
+ alphanumericwithbasicpuncspaces : r.dataSet.code.alphanumericwithbasicpuncspaces,
+ notOnlyDigits : r.dataSet.code.notOnlyDigits,
+ rangelength : r.dataSet.code.length
+ },
+ frequencySelect : {
+ required : true
+ }
+ };
+
+ validation2( 'editDataSetForm', function( form )
+ {
+ form.submit()
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ selectAllById( 'selectedList' )
+ },
+ 'rules' : rules
+ } );
+
+ jQuery( "#name" ).attr( "maxlength", r.dataSet.name.length[1] );
+ jQuery( "#shortName" ).attr( "maxlength", r.dataSet.shortName.length[1] );
+ jQuery( "#code" ).attr( "maxlength", r.dataSet.code.length[1] );
+
+ checkValueIsExist( "name", "validateDataSet.action", {
+ dataSetId : jQuery( "#dataSetId" ).val()
+ } );
+ checkValueIsExist( "shortName", "validateDataSet.action", {
+ dataSetId : jQuery( "#dataSetId" ).val()
+ } );
+ checkValueIsExist( "code", "validateDataSet.action", {
+ dataSetId : jQuery( "#dataSetId" ).val()
+ } );
+
+} );
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js 2011-03-17 12:08:11 +0000
@@ -0,0 +1,30 @@
+jQuery( document ).ready( function()
+{
+ var r = getValidationRules();
+
+ var rules = {
+ sectionName : {
+ required : true,
+ rangelength : r.section.name.length
+ }
+ };
+
+ validation2( 'editDataSetForm', function( form )
+ {
+ form.submit()
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ selectAllById( 'selectedList' )
+ },
+ 'rules' : rules
+ } );
+
+ jQuery( "#sectionName" ).attr( "maxlength", r.section.name.length[1] );
+
+ checkValueIsExist( "sectionName", "validateSection.action", {
+ dataSetId : jQuery( "#dataSetId" ).val(),
+ name : jQuery( "#sectionName" ).val(),
+ sectionId : jQuery( "#sectionId" ).val()
+ } );
+} );
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 2011-03-17 12:08:11 +0000
@@ -0,0 +1,122 @@
+jQuery( document ).ready( function()
+{
+ var r = getValidationRules();
+
+ var rules = {
+ nameField : {
+ required : true,
+ rangelength : r.dataEntry.name.length
+ }
+ };
+
+ validation2( 'saveDataEntryForm', function()
+ {
+ autoSave = false;
+ validateDataEntryForm();
+ }, {
+ 'rules' : rules
+ } );
+
+ jQuery( "#nameField" ).attr( "maxlength", r.dataEntry.name.length[1] );
+
+ jQuery( "#dataElementSelection" ).resizable( {
+ minHeight : 210,
+ minWidth : 400,
+ width : 400,
+ alsoResize : "#dataElementList"
+ } );
+
+ jQuery( "#dataElementSelection" ).draggable( {
+ handle : 'h3'
+ } );
+
+ leftBar.hideAnimated();
+
+ select( 1 );
+
+} );
+
+function timedCount()
+{
+ validateDataEntryForm();
+ t = setTimeout( "timedCount()", 20000 );// 1000 -> 1s
+ byId( 'message' ).style.display = 'none';
+}
+
+function select( id )
+{
+ if (selected != null) {
+ jQuery( "#tr" + selected ).removeClass( "selected" );
+ }
+
+ jQuery( "#tr" + id ).addClass( "selected" );
+
+ selected = id;
+}
+
+function insertDataElement()
+{
+ var oEditor = FCKeditorAPI.GetInstance( 'designTextarea' );
+ var viewByValue = getFieldValue( 'viewBySelector' );
+
+ var json = JSON.parse( jQuery( "#json_" + selected ).val() );
+
+ var dataElementId = json.dataElement.id;
+ var dataElementName = json.dataElement.name;
+ var dataElementType = json.dataElement.type;
+ var optionComboName = json.optionCombo.name;
+ var optionComboId = json.optionCombo.id;
+
+ if (viewByValue == "deid")
+ dispName = "[ " + dataElementId;
+ else if (viewByValue == "deshortname")
+ dispName = "[ " + json.dataElement.shortName;
+ else
+ dispName = "[ " + json.dataElement.name;
+
+ var titleValue = "-- " + dataElementId + ". " + dataElementName + " " + optionComboId + ". " + optionComboName
+ + " (" + dataElementType + ") --";
+
+ var displayName = dispName + " - " + optionComboName + " ]";
+ var dataEntryId = "value[" + dataElementId + "].value:value[" + optionComboId + "].value";
+ var boolDataEntryId = "value[" + dataElementId + "].value:value[" + optionComboId + "].value";
+
+ viewByValue = "@@" + viewByValue + "@@";
+
+ var id = "";
+ var html = "";
+
+ if (dataElementType == "bool") {
+ id = boolDataEntryId;
+ html = "<input title=\"" + titleValue + "\" view=\"" + viewByValue + "\" value=\"" + displayName + "\" id=\""
+ + boolDataEntryId + "\" style=\"width:4em;text-align:center\"/>";
+ } else {
+ id = dataEntryId;
+ html = "<input title=\"" + titleValue + "\" view=\"" + viewByValue + "\" value=\"" + displayName + "\" id=\""
+ + dataEntryId + "\" style=\"width:4em;text-align:center\"/>";
+ }
+
+ if (checkExisted( id )) {
+ jQuery( "#message_" ).html( "<b>" + i18n_dataelement_is_inserted + "</b>" );
+ return;
+ } else {
+ jQuery( "#message_" ).html( "" );
+ }
+
+ oEditor.InsertHtml( html );
+
+}
+
+function checkExisted( id )
+{
+ var result = false;
+ var html = FCKeditorAPI.GetInstance( 'designTextarea' ).GetHTML();
+ var input = jQuery( html ).find( "select, :text" );
+ input.each( function( i, item )
+ {
+ if (id == item.id)
+ result = true;
+ } );
+
+ return result;
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2011-03-04 02:22:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2011-03-17 12:08:11 +0000
@@ -1,44 +1,30 @@
+<script type="text/javascript" src="javascript/viewDataEntryForm.js"></script>
<script type="text/javascript">
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "dataentryform_confirm_delete" ) , "'" )';
+ var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'" )';
+ var i18n_dataelement_is_inserted = '$encoder.jsEscape( $i18n.getString( "dataelement_is_inserted" ) , "'" )';
+
var stat = ('$!dataEntryForm') ? "EDIT" : "ADD";
var dataEntryFormId = -1;
- var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "dataentryform_confirm_delete" ) , "'" )';
-
+ var selected = null;
+ var autoSave = '$!autoSave';
+ var t;
+ var timer_is_on=0;
+
#if($!dataEntryForm)
dataEntryFormId = $dataEntryForm.id;
#end
- var autoSave = '$!autoSave';
-
-
- jQuery(document).ready( function(){
- validation( 'saveDataEntryForm', function(){
- autoSave = false;
- validateDataEntryForm();
- } );
-
- jQuery("#dataElementSelection").resizable({
- minHeight:210,
- minWidth:400,
- width:400,
- alsoResize: "#dataElementList"
- });
-
- jQuery("#dataElementSelection").draggable({
- handle:'h3'
- });
-
-
- leftBar.hideAnimated();
-
- select( 1 );
-
- });
-
-
+ if('$autoSave' == 'true'){
+ if (!timer_is_on)
+ {
+ timer_is_on=1;
+ timedCount();
+ }
+ }
</script>
<style>
-
#dataElementSelection {
padding: 0.5em;
position:fixed;
@@ -91,7 +77,7 @@
<tbody>
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="nameField" name="nameField" value='$!dataEntryForm.name' style="width:20em" maxlength="100" class="{validate:{required:true,minlength:4}}"/></td>
+ <td><input type="text" id="nameField" name="nameField" value='$!dataEntryForm.name' style="width:20em"></td>
</tr>
<tr>
<td><label>$i18n.getString( "dataset" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
@@ -175,111 +161,3 @@
</tr>
</table>
</div>
-
-<script>
- var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'" )';
- var i18n_dataelement_is_inserted = '$encoder.jsEscape( $i18n.getString( "dataelement_is_inserted" ) , "'" )';
-
- var t;
- var timer_is_on=0;
-
- if('$autoSave' == 'true'){
- if (!timer_is_on)
- {
- timer_is_on=1;
- timedCount();
- }
- }
-
- function timedCount()
- {
- validateDataEntryForm();
- t=setTimeout("timedCount()", 20000);//1000 -> 1s
- byId( 'message' ).style.display = 'none';
- }
-
-var selected = null;
-
-function select( id )
-{
- if( selected != null )
- {
- jQuery("#tr" + selected ).removeClass( "selected");
- }
-
- jQuery("#tr" + id ).addClass( "selected");
-
- selected = id;
-}
-
-
-function insertDataElement()
-{
- var oEditor = FCKeditorAPI.GetInstance('designTextarea') ;
- var viewByValue = getFieldValue( 'viewBySelector' );
-
- var json = JSON.parse( jQuery("#json_" + selected ).val() );
-
- var dataElementId = json.dataElement.id;
- var dataElementName = json.dataElement.name;
- var dataElementType = json.dataElement.type;
- var optionComboName = json.optionCombo.name;
- var optionComboId = json.optionCombo.id;
-
- if(viewByValue == "deid") dispName = "[ " + dataElementId;
- else if (viewByValue == "deshortname") dispName = "[ " + json.dataElement.shortName;
- else dispName = "[ " + json.dataElement.name;
-
- var titleValue = "-- " + dataElementId + ". "
- + dataElementName + " "
- + optionComboId + ". "
- + optionComboName + " ("
- + dataElementType + ") --";
-
- var displayName = dispName + " - " + optionComboName + " ]";
- var dataEntryId = "value[" + dataElementId + "].value:value[" + optionComboId + "].value";
- var boolDataEntryId = "value[" + dataElementId + "].value:value[" + optionComboId + "].value";
-
- viewByValue = "@@" + viewByValue + "@@";
-
- var id = "";
- var html = "";
-
- if (dataElementType == "bool")
- {
- id = boolDataEntryId;
- html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" id=\""+ boolDataEntryId +"\" style=\"width:4em;text-align:center\"/>";
-
-
- }else
- {
- id = dataEntryId;
- html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" id=\"" + dataEntryId + "\" style=\"width:4em;text-align:center\"/>" ;
- }
-
- if( checkExisted( id ) )
- {
- jQuery( "#message_").html( "<b>" + i18n_dataelement_is_inserted + "</b>" );
- return;
- }else{
- jQuery( "#message_").html("");
- }
-
- oEditor.InsertHtml( html );
-
-}
-
-function checkExisted( id )
-{
- var result = false;
- var html = FCKeditorAPI.GetInstance('designTextarea').GetHTML();
- var input = jQuery( html ).find("select, :text");
- input.each( function(i, item){
- if( id == item.id ) result = true;
- });
-
- return result;
-}
-
-
-</script>