dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24406
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11957: Validate length of the message without params less or equals to 160.
------------------------------------------------------------
revno: 11957
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-09-07 17:25:07 +0700
message:
Validate length of the message without params less or equals to 160.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.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-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-09-07 09:08:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-09-07 10:25:07 +0000
@@ -463,3 +463,4 @@
health_worker_assigned_to_person = Health worker assigned to person
all_users_at_orgunit = All users at organisation unit
send_base_on = Send base on
+characters_without_params = Characters without params
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2013-09-07 09:28:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2013-09-07 10:25:07 +0000
@@ -331,4 +331,5 @@
var i18n_complete_program = '$encoder.jsEscape( $i18n.getString( "complete_program" ) , "'")';
var i18n_program_enrollment = '$encoder.jsEscape( $i18n.getString( "program_enrollment" ) , "'")';
var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
+ var i18n_characters_without_params = '$encoder.jsEscape( $i18n.getString( "characters_without_params" ) , "'")';
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-09-07 09:08:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-09-07 10:25:07 +0000
@@ -218,7 +218,8 @@
var i18n_days_scheduled = '$encoder.jsEscape( $i18n.getString( "days_scheduled" ) , "'")';
var i18n_complete_event = '$encoder.jsEscape( $i18n.getString( "complete_event" ) , "'")';
var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
-
+ var i18n_characters_without_params = '$encoder.jsEscape( $i18n.getString( "characters_without_params" ) , "'")';
+
var programStageList = new Array();
#foreach($programStage in $program.programStages)
programStageList.push("$programStage.displayName");
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js 2013-09-07 09:08:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js 2013-09-07 10:25:07 +0000
@@ -274,7 +274,6 @@
function generateTemplateMessageForm()
{
var rowId = jQuery('.daysAllowedSendMessage').length + 1;
-
var contend = '<tr name="tr' + rowId + '" class="listAlternateRow" >'
+ '<td colspan="2">' + i18n_reminder + ' ' + rowId + '<a href="javascript:removeTemplateMessageForm('+ rowId +')"> ( '+ i18n_remove_reminder + ' )</a></td>'
+ '</tr>'
@@ -335,7 +334,11 @@
+ '</tr>'
+ '<tr name="tr' + rowId + '">'
+ '<td><label>' + i18n_message + '</label></td>'
- + '<td><textarea id="templateMessage' + rowId + '" name="templateMessage' + rowId + '" style="width:320px" class="templateMessage {validate:{required:true, rangelength:[3,160]}}"></textarea></td>'
+ + '<td><textarea onkeypress="getMessageLength( ' + rowId + ');" id="templateMessage' + rowId + '" name="templateMessage' + rowId + '" style="width:320px" class="templateMessage {validate:{required:true}}"></textarea></td>'
+ + '</tr>'
+ + '<tr>'
+ + '<td></td>'
+ + '<td id="messageLengthTD' + rowId + '"></td>'
+ '</tr>';
jQuery('#programStageMessage').append( contend );
@@ -363,6 +366,7 @@
{
var templateMessage = paramValue;
insertTextCommon('templateMessage' + rowId, templateMessage);
+ getMessageLength(rowId );
}
function whenToSendOnChange(index)
@@ -376,4 +380,29 @@
disable('dateToCompare' + index );
disable('daysAllowedSendMessage' + index );
}
+}
+
+function getMessageLength(rowId)
+{
+ var message = getFieldValue( 'templateMessage' + rowId );
+ var length = 0;
+ var idx = message.indexOf('{');
+ while( idx >=0 ){
+ length += message.substr(0,idx).length;
+ var end = message.indexOf('}');
+ if(end>=0){
+ message = message.substr(end + 1, message.length);
+ idx = message.indexOf('{');
+ }
+ }
+ length += message.length;
+ setInnerHTML('messageLengthTD' + rowId, length + " " + i18n_characters_without_params);
+ if( length>=160 )
+ {
+ jQuery('#templateMessage' + rowId ).attr('maxlength', 160);
+ }
+ else
+ {
+ jQuery('#templateMessage' + rowId ).removeAttr('maxlength');
+ }
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2013-09-07 09:08:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2013-09-07 10:25:07 +0000
@@ -357,7 +357,11 @@
+ '</tr>'
+ '<tr name="tr' + rowId + '">'
+ '<td><label>' + i18n_message + '</label></td>'
- + '<td><textarea id="templateMessage' + rowId + '" name="templateMessage' + rowId + '" style="width:320px" class="templateMessage {validate:{required:true, rangelength:[3,160]}}"></textarea></td>'
+ + '<td><textarea id="templateMessage' + rowId + '" name="templateMessage' + rowId + '" style="width:320px" class="templateMessage {validate:{required:true}}"></textarea></td>'
+ + '</tr>'
+ + '<tr>'
+ + '<td></td>'
+ + '<td id="messageLengthTD' + rowId + '"></td>'
+ '</tr>';
jQuery('#programStageMessage').append( contend );
@@ -398,4 +402,30 @@
if ( value == 5) {
showById( 'tr'+id );
}
-};
\ No newline at end of file
+};
+
+
+function getMessageLength(rowId)
+{
+ var message = getFieldValue( 'templateMessage' + rowId );
+ var length = 0;
+ var idx = message.indexOf('{');
+ while( idx >=0 ){
+ length += message.substr(0,idx).length;
+ var end = message.indexOf('}');
+ if(end>=0){
+ message = message.substr(end + 1, message.length);
+ idx = message.indexOf('{');
+ }
+ }
+ length += message.length;
+ setInnerHTML('messageLengthTD' + rowId, length + " " + i18n_characters_without_params);
+ if( length>=160 )
+ {
+ jQuery('#templateMessage' + rowId ).attr('maxlength', 160);
+ }
+ else
+ {
+ jQuery('#templateMessage' + rowId ).removeAttr('maxlength');
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2013-09-07 09:28:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2013-09-07 10:25:07 +0000
@@ -9,14 +9,10 @@
showHideUserGroup();
validation( 'updateProgramForm', function( form ){
- if( duplicate==true)
- return false;
- else{
- enable('dateOfEnrollmentDescription');
- enable('dateOfIncidentDescription');
- form.submit();
- }
- }, function(){
+ enable('dateOfEnrollmentDescription');
+ enable('dateOfIncidentDescription');
+ form.submit();
+ }, function(){
var daysAllowedSendMessages = jQuery( "#daysAllowedSendMessages" );
daysAllowedSendMessages.empty();
@@ -400,7 +396,11 @@
</tr>
<tr name="tr$index">
<td><label>$i18n.getString( "message" )</label></td>
- <td><textarea id="templateMessage$index" name="templateMessage$index" style="width:320px" class="templateMessage {validate:{required:true, rangelength:[3,160]}}">$reminder.templateMessage</textarea></td>
+ <td><textarea onkeypress="getMessageLength($index)" id="templateMessage$index" name="templateMessage$index" style="width:320px" class="templateMessage {validate:{required:true, rangelength:[3,160]}}">$reminder.templateMessage</textarea></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td id='messageLengthTD$index'></td>
</tr>
#end
</tbody>
@@ -449,6 +449,7 @@
var i18n_program_enrollment = '$encoder.jsEscape( $i18n.getString( "program_enrollment" ) , "'")';
var i18n_complete_program_stage = '$encoder.jsEscape( $i18n.getString( "complete_program_stage" ) , "'")';
var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
+ var i18n_characters_without_params = '$encoder.jsEscape( $i18n.getString( "characters_without_params" ) , "'")';
programOnChange();
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-09-07 09:28:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-09-07 10:25:07 +0000
@@ -265,7 +265,11 @@
</tr>
<tr name="tr$index">
<td><label>$i18n.getString( "message" )</label></td>
- <td><textarea id="templateMessage$index" name="templateMessage$index" style="width:320px" class="templateMessage {validate:{required:true, rangelength:[3,160]}}">$reminder.templateMessage</textarea></td>
+ <td><textarea id="templateMessage$index" onkeypress="getMessageLength($index)" name="templateMessage$index" style="width:320px" class="templateMessage {validate:{required:true, rangelength:[3,160]}}">$reminder.templateMessage</textarea></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td id='messageLengthTD$index'></td>
</tr>
#end
</tbody>
@@ -312,4 +316,5 @@
var i18n_complete_event = '$encoder.jsEscape( $i18n.getString( "complete_event" ) , "'")';
var i18n_program_stage_name = '$encoder.jsEscape( $i18n.getString( "program_stage_name" ) , "'" )';
var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
+ var i18n_characters_without_params = '$encoder.jsEscape( $i18n.getString( "characters_without_params" ) , "'")';
</script>
\ No newline at end of file