dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39260
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19897: update data-entry module to use valueType instead of type/numberType/textType
------------------------------------------------------------
revno: 19897
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-08-31 13:34:36 +0700
message:
update data-entry module to use valueType instead of type/numberType/textType
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2015-07-10 05:22:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2015-08-31 06:34:36 +0000
@@ -150,14 +150,14 @@
function saveVal( dataElementId, optionComboId, fieldId, feedbackId )
{
- var fieldIds = fieldId.split( "-" );
-
- feedbackId = '#' + ( feedbackId || fieldId );
-
- if ( fieldIds.length > 3 )
- {
- dhis2.de.currentOrganisationUnitId = fieldIds[0];
- }
+ var fieldIds = fieldId.split( "-" );
+
+ feedbackId = '#' + ( feedbackId || fieldId );
+
+ if ( fieldIds.length > 3 )
+ {
+ dhis2.de.currentOrganisationUnitId = fieldIds[0];
+ }
fieldId = '#' + fieldId;
@@ -169,43 +169,44 @@
var periodId = $( '#selectedPeriodId' ).val();
- var warning = undefined;
+ var warning = undefined;
- var existing = !!( dhis2.de.currentExistingValue && dhis2.de.currentExistingValue != '' );
+ var existing = !!( dhis2.de.currentExistingValue && dhis2.de.currentExistingValue != '' );
if ( value )
{
- if ( type == 'string' || type == 'int' || type == 'number' || type == 'posInt' || type == 'negInt' || type == 'zeroPositiveInt' || type == 'unitInterval' || type == 'percentage' )
+ if ( type == 'TEXT' || type == 'NUMBER' || type == 'INTEGER' || type == 'INTEGER_POSITIVE' || type == 'INTEGER_NEGATIVE'
+ || type == 'INTEGER_ZERO_OR_POSITIVE' || type == 'UNIT_INTERVAL' || type == 'PERCENTAGE' )
{
if ( value.length > dhis2.de.cst.valueMaxLength )
{
return dhis2.de.alertField( fieldId, i18n_value_too_long + '\n\n' + dataElementName );
}
- if ( type == 'int' && !dhis2.validation.isInt( value ) )
+ if ( type == 'NUMBER' && !dhis2.validation.isNumber( value ) )
+ {
+ return dhis2.de.alertField( fieldId, i18n_value_must_number + '\n\n' + dataElementName );
+ }
+ if ( type == 'INTEGER' && !dhis2.validation.isInt( value ) )
{
return dhis2.de.alertField( fieldId, i18n_value_must_integer + '\n\n' + dataElementName );
}
- if ( type == 'number' && !dhis2.validation.isNumber( value ) )
- {
- return dhis2.de.alertField( fieldId, i18n_value_must_number + '\n\n' + dataElementName );
- }
- if ( type == 'posInt' && !dhis2.validation.isPositiveInt( value ) )
+ if ( type == 'INTEGER_POSITIVE' && !dhis2.validation.isPositiveInt( value ) )
{
return dhis2.de.alertField( fieldId, i18n_value_must_positive_integer + '\n\n' + dataElementName );
}
- if ( type == 'negInt' && !dhis2.validation.isNegativeInt( value ) )
+ if ( type == 'INTEGER_NEGATIVE' && !dhis2.validation.isNegativeInt( value ) )
{
return dhis2.de.alertField( fieldId, i18n_value_must_negative_integer + '\n\n' + dataElementName );
}
- if ( type == 'zeroPositiveInt' && !dhis2.validation.isZeroOrPositiveInt( value ) )
+ if ( type == 'INTEGER_ZERO_OR_POSITIVE' && !dhis2.validation.isZeroOrPositiveInt( value ) )
{
return dhis2.de.alertField( fieldId, i18n_value_must_zero_or_positive_integer + '\n\n' + dataElementName );
}
- if ( type == 'unitInterval' && !dhis2.validation.isUnitInterval( value ) )
+ if ( type == 'UNIT_INTERVAL' && !dhis2.validation.isUnitInterval( value ) )
{
return dhis2.de.alertField( fieldId, i18n_value_must_unit_interval + '\n\n' + dataElementName );
}
- if ( type == 'percentage' && !dhis2.validation.isPercentage( value ) )
+ if ( type == 'PERCENTAGE' && !dhis2.validation.isPercentage( value ) )
{
return dhis2.de.alertField( fieldId, i18n_value_must_percentage + '\n\n' + dataElementName );
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-07-10 05:22:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-08-31 06:34:36 +0000
@@ -84,7 +84,7 @@
// Constants
-dhis2.de.cst.defaultType = 'int';
+dhis2.de.cst.defaultType = 'INTEGER';
dhis2.de.cst.defaultName = '[unknown]';
dhis2.de.cst.dropDownMaxItems = 30;
dhis2.de.cst.formulaPattern = /#\{.+?\}/g;
@@ -284,11 +284,11 @@
}
} );
} );
-}
+};
dhis2.de.loadMetaData = function()
{
- var def = $.Deferred();
+ var def = $.Deferred();
$.ajax( {
url: 'getMetaData.action',
@@ -483,7 +483,7 @@
}
} );
} )( dataValuesArray );
-}
+};
dhis2.de.addEventListeners = function()
{
@@ -492,8 +492,7 @@
var id = $( this ).attr( 'id' );
// If entry field is a date picker, remove old target field, and change id
-
- if ( /-dp$/.test( id ) )
+ if ( /-dp$/.test( id ) )
{
var dpTargetId = id.substring( 0, id.length - 3 );
$( '#' + dpTargetId ).remove();
@@ -533,10 +532,9 @@
keyPress( event, this );
} );
- if ( type == 'date' )
+ if ( type == 'DATE' )
{
// Fake event, needed for valueBlur / valueFocus when using date-picker
-
var fakeEvent = {
target: {
id: id + '-dp'
@@ -553,8 +551,8 @@
onShow: function() {
valueFocus(fakeEvent);
},
- minDate: null,
- maxDate: null
+ minDate: null,
+ maxDate: null
} );
}
} );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2015-07-10 05:22:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2015-08-31 06:34:36 +0000
@@ -48,7 +48,7 @@
url: '../api/dataValues',
data: dataValue,
dataType: 'json',
- type: 'post',
+ type: 'POST',
success: handleSuccess,
error: handleError
} );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 2015-08-25 07:19:18 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 2015-08-31 06:34:36 +0000
@@ -13,7 +13,7 @@
"dataElements": {
#set( $size = $dataElements.size() )
#foreach( $dataElement in $dataElements )
-"${dataElement.uid}":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )"#if( $velocityCount < $size ),#end
+"${dataElement.uid}":"${dataElement.getValueType()}"#if( $velocityCount < $size ),#end
#end },
"optionSets": {