dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37398
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19139: Fixed bug - Validation in Update Program Rules form doesn't work properly; Added 'Hide Section' o...
------------------------------------------------------------
revno: 19139
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-05-12 15:49:50 +0700
message:
Fixed bug - Validation in Update Program Rules form doesn't work properly; Added 'Hide Section' option for Add/Update Program Rule forms.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramRule.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programRule.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programRule.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramRule.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-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2015-04-24 17:41:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2015-05-12 08:49:50 +0000
@@ -538,6 +538,11 @@
add_source_field = Add source field
add_more_action = Add more action
source_type = Source type
-please_enter_action_description = Please enter action description
confirm_delete_program_rule = Are you sure you want to delete program rule?
-edit_program_rule = Edit program rule
\ No newline at end of file
+edit_program_rule = Edit program rule
+please_enter_error_message = Please enter error message
+please_enter_warning_message = Please enter warning message
+please_enter_alert_message_when_hiding_a_field_that_contains_value = Please enter alert message when hiding a field that contains value
+please_enter_alert_message_when_hiding_a_section_that_contains_values = Please enter alert message when hiding a section that contains values
+hide_section = Hide section
+
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramRule.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramRule.vm 2015-04-28 12:14:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramRule.vm 2015-05-12 08:49:50 +0000
@@ -30,8 +30,22 @@
var i18n_show_error = '$encoder.jsEscape( $i18n.getString( "show_error" ) , "'" )';
var i18n_this_field_is_required = '$encoder.jsEscape( $i18n.getString( "this_field_is_required" ) , "'")';
var i18n_name_in_use = '$encoder.jsEscape( $i18n.getString( "name_in_use" ) , "'")';
- var i18n_please_enter_action_description = '$encoder.jsEscape( $i18n.getString( "please_enter_action_description" ) , "'")';
var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_program_rule" ) , "'")';
+ var i18n_please_enter_error_message = '$encoder.jsEscape( $i18n.getString( "please_enter_error_message" ) , "'")';
+ var i18n_please_enter_warning_message = '$encoder.jsEscape( $i18n.getString( "please_enter_warning_message" ) , "'")';
+ var i18n_please_enter_alert_message_when_hiding_a_field = '$encoder.jsEscape( $i18n.getString( "please_enter_alert_message_when_hiding_a_field_that_contains_value" ) , "'")';
+ var i18n_please_enter_alert_message_when_hiding_a_section = '$encoder.jsEscape( $i18n.getString( "please_enter_alert_message_when_hiding_a_section_that_contains_values" ) , "'")';
+ var i18n_hide_section = '$encoder.jsEscape( $i18n.getString( "hide_section" ) , "'" )';
+
+ var sectionSelector = "<select class='actionSections' >";
+ #foreach( $programStage in $program.programStages )
+ #foreach( $section in $programStage.programStageSections )
+ var uid = '$section.uid';
+ var name = '$section.displayName';
+ sectionSelector += "<option value='" + uid + "'>" + name + "</option>";
+ #end
+ #end
+ sectionSelector += "</select>";
</script>
<h3>$i18n.getString( "create_new_program_rule" )</h3>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programRule.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programRule.js 2015-04-29 13:37:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programRule.js 2015-05-12 08:49:50 +0000
@@ -230,22 +230,25 @@
var status = 0;
function validateProgramRule()
{
- status = 1;
+ status = 0;
var valid = true;
$("#actionTB tr").find(".content").each(function(){
if( $(this).val() == "" )
{
+ var message = $(this).closest('tr').find('.actionList option:selected').attr("errorMessage");
$(this).css('background-color', 'pink');
- $(this).attr('placeholder', 'i18n_please_enter_action_description');
+ $(this).attr('placeholder', message);
unLockScreen();
valid = false;
return;
}
- })
+ });
if( valid ) {
+ status = 1;
addProgramRule();
}
+ return valid;
}
function addProgramRule()
@@ -307,6 +310,7 @@
"programRuleActionType": row.find(".actionList").val(),
"programRule":{ "id":programRuleId },
"dataElement":{ "id": row.find(".actionDEs").val() },
+ "programStageSection":{ "id": row.find(".actionSections").val() },
"content": row.find(".content").val()
}
@@ -383,19 +387,34 @@
clazz = "class='listRow'";
}
var row = "<tr " + clazz + ">"
- + "<td><select class='actionList' style='width:100%'>"
- + " <option value='HIDEFIELD'>" + i18n_hide_field + "</option>"
- + " <option value='SHOWWARNING'>" + i18n_show_warning + "</option>"
- + " <option value='SHOWERROR'>" + i18n_show_error + "</option>"
+ + "<td><select class='actionList' style='width:100%' onchange='actionListToggle(this)'>"
+ + " <option value='SHOWERROR' errorMessage='" + i18n_please_enter_error_message + "' >" + i18n_show_error + "</option>"
+ + " <option value='SHOWWARNING' errorMessage='" + i18n_please_enter_warning_message + "' >" + i18n_show_warning + "</option>"
+ + " <option value='HIDEFIELD' errorMessage='" + i18n_please_enter_alert_message_when_hiding_a_field + "' >" + i18n_hide_field + "</option>"
+ + " <option value='HIDESECTION' errorMessage='" + i18n_please_enter_alert_message_when_hiding_a_section + "' >" + i18n_hide_section + "</option>"
+ "</select>"
+ "</td>"
+ "<td><input type='text' class='content' style='width:97%;'/></td>"
- + "<td>" + dataElementSelector + "</td>"
+ + "<td><span class='deCell'>" + dataElementSelector + "</span><span class='sectionCell' style='display:none;'>" + sectionSelector + "</td>"
+ "<td><input class='small-button' type='button' value='-' onclick='javascript:removeActionRow(this)';></td>"
+ "</tr>";
table.append(row);
}
+function actionListToggle(_this)
+{
+ var selected = _this.value;
+ var row = $(_this).closest('tr');
+ if( selected == 'HIDESECTION' ){
+ row.find('.deCell').hide();
+ row.find('.sectionCell').show();
+ }
+ else{
+ row.find('.sectionCell').hide();
+ row.find('.deCell').show();
+ }
+}
+
function removeActionRow(_this)
{
$(_this).closest('tr').remove();
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programRule.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programRule.vm 2015-04-11 13:18:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programRule.vm 2015-05-12 08:49:50 +0000
@@ -35,12 +35,12 @@
</tr>
</table>
- <table class="listTable">
+ <table class="listTable" id='programRuleTB'>
<col>
<thead>
<tr>
<th>$i18n.getString( "name" )</th>
- <th>$i18n.getString( "description" )</th>
+ <th class='{sorter: false}'>$i18n.getString( "description" )</th>
</tr>
</thead>
<tbody id="list">
@@ -74,4 +74,6 @@
<script type="text/javascript">
var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_program_rule" ) , "'" )';
+
+ tableSorter( 'programRuleTB' );
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramRule.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramRule.vm 2015-04-29 13:37:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramRule.vm 2015-05-12 08:49:50 +0000
@@ -4,7 +4,7 @@
{
validation2( 'programRuleForm', function( form )
{
- validateProgramRule();
+ return validateProgramRule();
},{
'beforeValidateHandler' : function()
{
@@ -30,8 +30,22 @@
var i18n_show_error = '$encoder.jsEscape( $i18n.getString( "show_error" ) , "'" )';
var i18n_this_field_is_required = '$encoder.jsEscape( $i18n.getString( "this_field_is_required" ) , "'")';
var i18n_name_in_use = '$encoder.jsEscape( $i18n.getString( "name_in_use" ) , "'")';
- var i18n_please_enter_action_description = '$encoder.jsEscape( $i18n.getString( "please_enter_action_description" ) , "'")';
var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_program_rule" ) , "'")';
+ var i18n_please_enter_error_message = '$encoder.jsEscape( $i18n.getString( "please_enter_error_message" ) , "'")';
+ var i18n_please_enter_warning_message = '$encoder.jsEscape( $i18n.getString( "please_enter_warning_message" ) , "'")';
+ var i18n_please_enter_alert_message_when_hiding_a_field = '$encoder.jsEscape( $i18n.getString( "please_enter_alert_message_when_hiding_a_field_that_contains_value" ) , "'")';
+ var i18n_please_enter_alert_message_when_hiding_a_section = '$encoder.jsEscape( $i18n.getString( "please_enter_alert_message_when_hiding_a_section_that_contains_values" ) , "'")';
+ var i18n_hide_section = '$encoder.jsEscape( $i18n.getString( "hide_section" ) , "'" )';
+
+ var sectionSelector = "<select class='actionSections' >";
+ #foreach( $programStage in $programRule.program.programStages )
+ #foreach( $section in $programStage.programStageSections )
+ var uid = '$section.uid';
+ var name = '$section.displayName';
+ sectionSelector += "<option value='" + uid + "'>" + name + "</option>";
+ #end
+ #end
+ sectionSelector += "</select>";
</script>
<h3>$i18n.getString( "edit_program_rule" )</h3>
@@ -150,17 +164,32 @@
<tr $clazz id="$action.uid">
<td>
- <select class='actionList' style='width:100%'>
- <option value='HIDEFIELD' #if($action.programRuleActionType=='HIDEFIELD') selected #end>$i18n.getString("hide_field")</option>
- <option value='SHOWWARNING' #if($action.programRuleActionType=='SHOWWARNING') selected #end>$i18n.getString("show_warning")</option>
- <option value='SHOWERROR' #if($action.programRuleActionType=='SHOWERROR') selected #end>$i18n.getString("show_error")</option>
+ <select class='actionList' style='width:100%' onchange="actionListToggle(this)">
+ <option value='HIDEFIELD' #if($action.programRuleActionType=='HIDEFIELD') selected #end errorMessage="$i18n.getString('please_enter_error_message')">$i18n.getString("hide_field")</option>
+ <option value='SHOWWARNING' #if($action.programRuleActionType=='SHOWWARNING') selected #end errorMessage="$i18n.getString('please_enter_warning_message')">$i18n.getString("show_warning")</option>
+ <option value='SHOWERROR' #if($action.programRuleActionType=='SHOWERROR') selected #end errorMessage="$i18n.getString('please_enter_alert_message_when_hiding_a_field_that_contains_value')">$i18n.getString("show_error")</option>
+ <option value='HIDESECTION' #if($action.programRuleActionType=='HIDESECTION') selected #end errorMessage="$i18n.getString('please_enter_alert_message_when_hiding_a_section_that_contains_values')">$i18n.getString("hide_section")</option>
</select>
</td>
<td><input type='text' class='content' style='width:97%;' value='$encoder.htmlEncode($action.content)'/></td>
<td>
- <select class='actionDEs' style='width:100%;'>
- <option value="$programRule.dataElement.uid">$encoder.htmlEncode($action.dataElement.displayName)</option>
- </select>
+ <span class="deCell" #if($action.programRuleActionType=='HIDESECTION') style='display:none;' #end>
+ <select class='actionDEs' style='width:100%;'>
+ <option value="$programRule.dataElement.uid">$encoder.htmlEncode($action.dataElement.displayName)</option>
+ </select>
+ </span>
+
+ <span class="sectionCell" #if($action.programRuleActionType!='HIDESECTION') style='display:none;' #end>
+ <select class='actionSections' >
+ #foreach( $programStage in $programRule.program.programStages )
+ #foreach( $section in $programStage.programStageSections )
+ #set( $uid = $section.uid )
+ #set( $name = $section.displayName)
+ <option value="$uid" #if($action.programStageSection.uid==$uid) selected #end >$name</option>
+ #end
+ #end
+ </select>
+ </span>
</td>
<td><input type='button' value='-' class='small-button' onclick='javascript:removeActionRow(this)';></td>
</tr>
@@ -238,3 +267,4 @@
</div>
</form>
+