------------------------------------------------------------ revno: 18632 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Thu 2015-03-19 18:14:12 +0700 message: metadata attributes for PS implemented added: dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java modified: dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/ShowAddUpdateTrackedEntityAction.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/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-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2015-03-14 07:57:45 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2015-03-19 11:14:12 +0000 @@ -28,10 +28,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.attribute.Attribute; +import org.hisp.dhis.attribute.AttributeService; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.ProgramIndicator; @@ -39,16 +38,21 @@ import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.program.ProgramStageService; +import org.hisp.dhis.system.util.AttributeUtils; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; import org.springframework.beans.factory.annotation.Autowired; -import com.opensymphony.xwork2.Action; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Abyot Asalefew Gizaw + * @version $Id$ * @modified Tran Thanh Tri - * @version $Id$ */ public class GetProgramStageAction implements Action @@ -63,9 +67,9 @@ { this.programStageService = programStageService; } - + private UserGroupService userGroupService; - + public void setUserGroupService( UserGroupService userGroupService ) { this.userGroupService = userGroupService; @@ -77,10 +81,13 @@ { this.periodService = periodService; } - + @Autowired private ProgramIndicatorService programIndicatorService; - + + @Autowired + private AttributeService attributeService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -110,7 +117,7 @@ { return programStageDataElements; } - + private List<UserGroup> userGroups; public List<UserGroup> getUserGroups() @@ -136,7 +143,21 @@ { return periodTypes; } - + + private List<Attribute> attributes; + + public List<Attribute> getAttributes() + { + return attributes; + } + + private Map<Integer, String> attributeValues = new HashMap<>(); + + public Map<Integer, String> getAttributeValues() + { + return attributeValues; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -145,17 +166,25 @@ public String execute() throws Exception { + programStage = programStageService.getProgramStage( id ); + + if ( programStage == null ) + { + return INPUT; + } + periodTypes = periodService.getAllPeriodTypes(); - - programStage = programStageService.getProgramStage( id ); programStageDataElements = programStage.getProgramStageDataElements(); - + userGroups = new ArrayList<>( userGroupService.getAllUserGroups() ); - + programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( programStage.getProgram() ) ); programIndicators.removeAll( programStage.getProgramIndicators() ); - + + attributeValues = AttributeUtils.getAttributeValueMap( programStage.getAttributeValues() ); + attributes = new ArrayList<>( attributeService.getProgramStageAttributes() ); + return SUCCESS; } } === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/ShowAddProgramStageAction.java 2015-03-19 11:14:12 +0000 @@ -0,0 +1,199 @@ +package org.hisp.dhis.trackedentity.action.programstage; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.attribute.Attribute; +import org.hisp.dhis.attribute.AttributeService; +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.constant.Constant; +import org.hisp.dhis.constant.ConstantService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.organisationunit.OrganisationUnitLevel; +import org.hisp.dhis.oust.manager.SelectionTreeManager; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.user.UserGroup; +import org.hisp.dhis.user.UserGroupService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Morten Olav Hansen <morte...@gmail.com> + */ +public class ShowAddProgramStageAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private ProgramService programService; + + @Autowired + private SelectionTreeManager selectionTreeManager; + + @Autowired + private UserGroupService userGroupService; + + @Autowired + private PeriodService periodService; + + @Autowired + private ProgramIndicatorService programIndicatorService; + + @Autowired + private ConstantService constantService; + + @Autowired + private AttributeService attributeService; + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private int id; + + public int getId() + { + return id; + } + + public void setId( int id ) + { + this.id = id; + } + + private Program program; + + public Program getProgram() + { + return program; + } + + private List<OrganisationUnitLevel> levels; + + public List<OrganisationUnitLevel> getLevels() + { + return levels; + } + + private List<OrganisationUnitGroup> groups; + + public List<OrganisationUnitGroup> getGroups() + { + return groups; + } + + private Integer level; + + public Integer getLevel() + { + return level; + } + + public void setLevel( Integer level ) + { + this.level = level; + } + + private List<UserGroup> userGroups; + + public List<UserGroup> getUserGroups() + { + return userGroups; + } + + private List<ProgramIndicator> programIndicators; + + public List<ProgramIndicator> getProgramIndicators() + { + return programIndicators; + } + + private List<Constant> constants; + + public List<Constant> getConstants() + { + return constants; + } + + private List<PeriodType> periodTypes = new ArrayList<>(); + + public List<PeriodType> getPeriodTypes() + { + return periodTypes; + } + + private List<Attribute> attributes; + + public List<Attribute> getAttributes() + { + return attributes; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + periodTypes = periodService.getAllPeriodTypes(); + + program = programService.getProgram( id ); + + selectionTreeManager.setSelectedOrganisationUnits( program.getOrganisationUnits() ); + + userGroups = new ArrayList<>( userGroupService.getAllUserGroups() ); + + programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( program ) ); + + Collections.sort( programIndicators, IdentifiableObjectNameComparator.INSTANCE ); + + constants = new ArrayList<>( constantService.getAllConstants() ); + + Collections.sort( constants, IdentifiableObjectNameComparator.INSTANCE ); + + attributes = new ArrayList<>( attributeService.getProgramStageAttributes() ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/ShowAddUpdateTrackedEntityAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/ShowAddUpdateTrackedEntityAction.java 2015-03-19 09:11:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/ShowAddUpdateTrackedEntityAction.java 2015-03-19 11:14:12 +0000 @@ -107,5 +107,4 @@ return SUCCESS; } - } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2015-03-19 09:29:29 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2015-03-19 11:14:12 +0000 @@ -250,6 +250,9 @@ <!-- ProgramStage --> + <bean id="org.hisp.dhis.trackedentity.action.programstage.ShowAddProgramStageAction" + class="org.hisp.dhis.trackedentity.action.programstage.ShowAddProgramStageAction" /> + <bean id="org.hisp.dhis.trackedentity.action.programstage.AddProgramStageAction" class="org.hisp.dhis.trackedentity.action.programstage.AddProgramStageAction" === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2015-03-19 09:29:29 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2015-03-19 11:14:12 +0000 @@ -300,7 +300,7 @@ </action> <action name="showAddProgramStageForm" - class="org.hisp.dhis.trackedentity.action.program.GetProgramAction"> + class="org.hisp.dhis.trackedentity.action.programstage.ShowAddProgramStageAction"> <result name="input" type="velocity-xml"> /dhis-web-commons/ajax/xmlResponseInput.vm </result> === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm 2015-03-16 08:11:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm 2015-03-19 11:14:12 +0000 @@ -1,4 +1,3 @@ -<script type="text/javascript" src="javascript/addProgramStageForm.js"></script> <script> var program_stage_SMS_reminder_form ="<select type='text' id='userGroup$index' name='userGroup$index' class='userGroup'>"; #foreach( $group in $userGroups ) @@ -7,6 +6,95 @@ program_stage_SMS_reminder_form +="</select>"; </script> +<script> + $(document).ready(function() { + validation2('addProgramStageForm', function( form ) { + form.submit(); + }, { + 'beforeValidateHandler': function() { + #tblDynamicAttributesJavascript() + + selectAllById('selectedIndicators'); + + var selectedDataElementsValidator = jQuery("#selectedDataElementsValidator"); + selectedDataElementsValidator.empty(); + + var compulsories = jQuery("#compulsories"); + compulsories.empty(); + + var displayInReports = jQuery("#displayInReports"); + displayInReports.empty(); + + var daysAllowedSendMessages = jQuery("#daysAllowedSendMessages"); + daysAllowedSendMessages.empty(); + + var allowFutureDates = jQuery("#allowFutureDates"); + allowFutureDates.empty(); + + var templateMessages = jQuery("#templateMessages"); + templateMessages.empty(); + + var allowProvidedElsewhere = jQuery("#allowProvidedElsewhere"); + allowProvidedElsewhere.empty(); + + var sendTo = jQuery("#sendTo"); + sendTo.empty(); + + var whenToSend = jQuery("#whenToSend"); + whenToSend.empty(); + + var userGroup = jQuery("#userGroup"); + userGroup.empty(); + + var messageType = jQuery("#messageType"); + messageType.empty(); + + jQuery("#selectedList").find("tr").each(function( i, item ) { + + selectedDataElementsValidator.append("<option value='" + item.id + "' selected='true'>" + item.id + "</option>"); + + var compulsory = jQuery(item).find("input[name='compulsory']:first"); + var checked = compulsory.attr('checked') ? true : false; + compulsories.append("<option value='" + checked + "' selected='true'>" + checked + "</option>"); + + var allowProvided = jQuery(item).find("input[name='allowProvided']:first"); + checked = allowProvided.attr('checked') ? true : false; + allowProvidedElsewhere.append("<option value='" + checked + "' selected='true'>" + checked + "</option>"); + + var displayInReport = jQuery(item).find("input[name='displayInReport']:first"); + checked = displayInReport.attr('checked') ? true : false; + displayInReports.append("<option value='" + checked + "' selected='true'><" + checked + "/option>"); + + var allowFutureDate = jQuery(item).find("input[name='allowFutureDate']:first"); + checked = allowFutureDate.attr('checked') ? true : false; + allowFutureDates.append("<option value='" + checked + "' selected='true'>" + checked + "</option>"); + }); + jQuery(".daysAllowedSendMessage").each(function( i, item ) { + var days = (jQuery(item).attr('realvalue') == undefined) ? 0 : jQuery(item).attr('realvalue'); + daysAllowedSendMessages.append("<option value='" + days + "' selected='true'>" + days + "</option>"); + }); + jQuery(".templateMessage").each(function( i, item ) { + templateMessages.append("<option value='" + item.value + "' selected='true'>" + item.value + "</option>"); + }); + jQuery(".sendTo").each(function( i, item ) { + sendTo.append("<option value='" + item.value + "' selected='true'>" + item.value + "</option>"); + }); + jQuery(".whenToSend").each(function( i, item ) { + whenToSend.append("<option value='" + item.value + "' selected='true'>" + item.value + "</option>"); + }); + jQuery(".messageType").each(function( i, item ) { + messageType.append("<option value='" + item.value + "' selected='true'>" + item.value + "</option>"); + }); + jQuery(".userGroup").each(function( i, item ) { + userGroup.append("<option value='" + item.value + "' selected='true'>" + item.value + "</option>"); + }); + }, + 'rules': getValidationRules("programStage") + }); + }); +</script> +<script type="text/javascript" src="javascript/addProgramStageForm.js"></script> + <h3>$i18n.getString( "create_new_program_stage" ) #openHelp( "program_stage_information" )</h3> <h4>$program.displayName</h4> @@ -161,7 +249,9 @@ </table> -<table id="programStageMembersArea"> +#tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } ) + +<table id="programStageMembersArea"> <colgroup> <col style="width:550px;"/> <col/> === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js 2015-03-16 08:11:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js 2015-03-19 11:14:12 +0000 @@ -1,108 +1,23 @@ var duplicate = false; -jQuery( document ).ready( function() -{ - validation2( 'addProgramStageForm', function( form ) - { - form.submit(); - },{ - 'beforeValidateHandler' : function() - { - selectAllById('selectedIndicators'); - - var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); - selectedDataElementsValidator.empty(); - - var compulsories = jQuery( "#compulsories" ); - compulsories.empty(); - - var displayInReports = jQuery( "#displayInReports" ); - displayInReports.empty(); - - var daysAllowedSendMessages = jQuery( "#daysAllowedSendMessages" ); - daysAllowedSendMessages.empty(); - - var allowFutureDates = jQuery( "#allowFutureDates" ); - allowFutureDates.empty(); - - var templateMessages = jQuery( "#templateMessages" ); - templateMessages.empty(); - - var allowProvidedElsewhere = jQuery( "#allowProvidedElsewhere" ); - allowProvidedElsewhere.empty(); - - var sendTo = jQuery( "#sendTo" ); - sendTo.empty(); - - var whenToSend = jQuery( "#whenToSend" ); - whenToSend.empty(); - - var userGroup = jQuery( "#userGroup" ); - userGroup.empty(); - - var messageType = jQuery( "#messageType" ); - messageType.empty(); - - jQuery("#selectedList").find("tr").each( function( i, item ){ - - selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" ); - - var compulsory = jQuery( item ).find( "input[name='compulsory']:first"); - var checked = compulsory.attr('checked') ? true : false; - compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); - - var allowProvided = jQuery( item ).find( "input[name='allowProvided']:first"); - checked = allowProvided.attr('checked') ? true : false; - allowProvidedElsewhere.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); - - var displayInReport = jQuery( item ).find( "input[name='displayInReport']:first"); - checked = displayInReport.attr('checked') ? true : false; - displayInReports.append( "<option value='" + checked + "' selected='true'><" + checked + "/option>" ); - - var allowFutureDate = jQuery( item ).find( "input[name='allowFutureDate']:first"); - checked = allowFutureDate.attr('checked') ? true : false; - allowFutureDates.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); - }); - jQuery(".daysAllowedSendMessage").each( function( i, item ){ - var days = (jQuery(item).attr('realvalue')==undefined) ? 0 : jQuery(item).attr('realvalue'); - daysAllowedSendMessages.append( "<option value='" + days + "' selected='true'>" + days + "</option>" ); - }); - jQuery(".templateMessage").each( function( i, item ){ - templateMessages.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".sendTo").each( function( i, item ){ - sendTo.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".whenToSend").each( function( i, item ){ - whenToSend.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".messageType").each( function( i, item ){ - messageType.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".userGroup").each( function( i, item ){ - userGroup.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - }, - 'rules' : getValidationRules( "programStage" ) - }); - - jQuery("#availableList").dhisAjaxSelect({ - source: "../dhis-web-commons-ajax-json/getDataElements.action?domain=patient", - iterator: "dataElements", - connectedTo: 'selectedDataElementsValidator', - handler: function(item) { - var option = jQuery("<option />"); - option.text( item.name ); - option.attr( "value", item.id ); - - if( item.optionSet == "true"){ - option.attr( "valuetype", "optionset" ); - } - else{ - option.attr( "valuetype", item.type ); - } - return option; - } - }); - - checkValueIsExist( "name", "validateProgramStage.action",{id: getFieldValue('programId')}); +jQuery(document).ready(function() { + jQuery("#availableList").dhisAjaxSelect({ + source: "../dhis-web-commons-ajax-json/getDataElements.action?domain=patient", + iterator: "dataElements", + connectedTo: 'selectedDataElementsValidator', + handler: function( item ) { + var option = jQuery("<option />"); + option.text(item.name); + option.attr("value", item.id); + + if( item.optionSet == "true" ) { + option.attr("valuetype", "optionset"); + } + else { + option.attr("valuetype", item.type); + } + return option; + } + }); + + checkValueIsExist("name", "validateProgramStage.action", {id: getFieldValue('programId')}); }); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js 2015-03-16 08:11:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js 2015-03-19 11:14:12 +0000 @@ -2,105 +2,7 @@ jQuery( document ).ready( function() { showHideUserGroup(); - - validation2( 'updateProgramStageForm', function( form ) - { - form.submit(); - },{ - 'beforeValidateHandler' : function() - { - selectAllById('selectedIndicators'); - - var periodType = byId('periodTypeName').value; - if( periodType != ''){ - setFieldValue('standardInterval',''); - } - - - /*var customStandardInterval = byId('customStandardInterval').checked; - if( customStandardInterval ){ - setFieldValue('periodTypeName',''); - } - else{ - setFieldValue('standardInterval',''); - }*/ - - var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); - selectedDataElementsValidator.empty(); - - var compulsories = jQuery( "#compulsories" ); - compulsories.empty(); - - var displayInReports = jQuery( "#displayInReports" ); - displayInReports.empty(); - - var daysAllowedSendMessages = jQuery( "#daysAllowedSendMessages" ); - daysAllowedSendMessages.empty(); - - var allowFutureDates = jQuery( "#allowFutureDates" ); - allowFutureDates.empty(); - - var templateMessages = jQuery( "#templateMessages" ); - templateMessages.empty(); - - var allowProvidedElsewhere = jQuery( "#allowProvidedElsewhere" ); - allowProvidedElsewhere.empty(); - - var sendTo = jQuery( "#sendTo" ); - sendTo.empty(); - - var whenToSend = jQuery( "#whenToSend" ); - whenToSend.empty(); - - var userGroup = jQuery( "#userGroup" ); - userGroup.empty(); - - var messageType = jQuery( "#messageType" ); - messageType.empty(); - jQuery("#selectedList").find("tr").each( function( i, item ){ - - selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" ); - - var compulsory = jQuery( item ).find( "input[name='compulsory']:first"); - var checked = compulsory.attr('checked') ? true : false; - compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); - - var allowProvided = jQuery( item ).find( "input[name='allowProvided']:first"); - checked = allowProvided.attr('checked') ? true : false; - allowProvidedElsewhere.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); - - var displayInReport = jQuery( item ).find( "input[name='displayInReport']:first"); - checked = displayInReport.attr('checked') ? true : false; - displayInReports.append( "<option value='" + checked + "' selected='true'><" + checked + "/option>" ); - - var allowFutureDate = jQuery( item ).find( "input[name='allowFutureDate']:first"); - checked = allowFutureDate.attr('checked') ? true : false; - allowFutureDates.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); - }); - jQuery(".daysAllowedSendMessage").each( function( i, item ){ - var days = (jQuery(item).attr('realvalue')==undefined) ? 0 : jQuery(item).attr('realvalue'); - daysAllowedSendMessages.append( "<option value='" + days + "' selected='true'>" + days + "</option>" ); - }); - jQuery(".templateMessage").each( function( i, item ){ - templateMessages.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".sendTo").each( function( i, item ){ - sendTo.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".whenToSend").each( function( i, item ){ - whenToSend.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".messageType").each( function( i, item ){ - messageType.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - jQuery(".userGroup").each( function( i, item ){ - userGroup.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); - }); - }, - 'rules' : getValidationRules( "programStage" ) - }); - checkValueIsExist( "name", "validateProgramStage.action", {id:getFieldValue('programId'), programStageId:getFieldValue('id')}); jQuery("#availableList").dhisAjaxSelect({ === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm 2015-03-16 08:11:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm 2015-03-19 11:14:12 +0000 @@ -1,4 +1,3 @@ -<script type="text/javascript" src="javascript/updateProgramStageForm.js"></script> <script> var i18n_characters_without_params = '$encoder.jsEscape( $i18n.getString( "characters_without_params" ) , "'")'; var program_stage_SMS_reminder_form ="<select type='text' id='userGroup$index' name='userGroup$index' class='userGroup'>"; @@ -8,6 +7,110 @@ program_stage_SMS_reminder_form +="</select>"; </script> +<script> + jQuery(document).ready(function() { + validation2( 'updateProgramStageForm', function( form ) + { + form.submit(); + },{ + 'beforeValidateHandler' : function() + { + #tblDynamicAttributesJavascript() + + selectAllById('selectedIndicators'); + + var periodType = byId('periodTypeName').value; + if( periodType != ''){ + setFieldValue('standardInterval',''); + } + + /*var customStandardInterval = byId('customStandardInterval').checked; + if( customStandardInterval ){ + setFieldValue('periodTypeName',''); + } + else{ + setFieldValue('standardInterval',''); + }*/ + + var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); + selectedDataElementsValidator.empty(); + + var compulsories = jQuery( "#compulsories" ); + compulsories.empty(); + + var displayInReports = jQuery( "#displayInReports" ); + displayInReports.empty(); + + var daysAllowedSendMessages = jQuery( "#daysAllowedSendMessages" ); + daysAllowedSendMessages.empty(); + + var allowFutureDates = jQuery( "#allowFutureDates" ); + allowFutureDates.empty(); + + var templateMessages = jQuery( "#templateMessages" ); + templateMessages.empty(); + + var allowProvidedElsewhere = jQuery( "#allowProvidedElsewhere" ); + allowProvidedElsewhere.empty(); + + var sendTo = jQuery( "#sendTo" ); + sendTo.empty(); + + var whenToSend = jQuery( "#whenToSend" ); + whenToSend.empty(); + + var userGroup = jQuery( "#userGroup" ); + userGroup.empty(); + + var messageType = jQuery( "#messageType" ); + messageType.empty(); + + jQuery("#selectedList").find("tr").each( function( i, item ){ + + selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" ); + + var compulsory = jQuery( item ).find( "input[name='compulsory']:first"); + var checked = compulsory.attr('checked') ? true : false; + compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); + + var allowProvided = jQuery( item ).find( "input[name='allowProvided']:first"); + checked = allowProvided.attr('checked') ? true : false; + allowProvidedElsewhere.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); + + var displayInReport = jQuery( item ).find( "input[name='displayInReport']:first"); + checked = displayInReport.attr('checked') ? true : false; + displayInReports.append( "<option value='" + checked + "' selected='true'><" + checked + "/option>" ); + + var allowFutureDate = jQuery( item ).find( "input[name='allowFutureDate']:first"); + checked = allowFutureDate.attr('checked') ? true : false; + allowFutureDates.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" ); + }); + jQuery(".daysAllowedSendMessage").each( function( i, item ){ + var days = (jQuery(item).attr('realvalue')==undefined) ? 0 : jQuery(item).attr('realvalue'); + daysAllowedSendMessages.append( "<option value='" + days + "' selected='true'>" + days + "</option>" ); + }); + jQuery(".templateMessage").each( function( i, item ){ + templateMessages.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); + }); + jQuery(".sendTo").each( function( i, item ){ + sendTo.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); + }); + jQuery(".whenToSend").each( function( i, item ){ + whenToSend.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); + }); + jQuery(".messageType").each( function( i, item ){ + messageType.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); + }); + jQuery(".userGroup").each( function( i, item ){ + userGroup.append( "<option value='" + item.value + "' selected='true'>" + item.value + "</option>" ); + }); + }, + 'rules' : getValidationRules( "programStage" ) + }); + }); +</script> +<script type="text/javascript" src="javascript/updateProgramStageForm.js"></script> + <h3>$i18n.getString( "edit_program_stage" ) #openHelp( "program_stage_information" )</h3> <h4>$encoder.htmlEncode($programStage.program.displayName)</h4> @@ -171,6 +274,8 @@ <tr><td> </td><td> </td></tr> </table> + #tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } ) + <table id="programStageMembersArea"> <colgroup> <col style="width:550px;"/> @@ -295,18 +400,16 @@ </tr> </table> - <p> - <input type="submit" value="$i18n.getString( 'update' )" style="width:10em"> - <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStage.action?id=$programStage.program.id'" style="width:10em"/> - </p> +<p> + <input type="submit" value="$i18n.getString( 'update' )" style="width:10em"> + <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStage.action?id=$programStage.program.id'" style="width:10em"/> +</p> </form> <script type="text/javascript"> - var attrOptions = ""; #foreach($programAttribute in $programStage.program.programAttributes) attrOptions+="<option value={attributeid=$programAttribute.attribute.uid}>$programAttribute.attribute.displayName</option>"; #end - </script> \ No newline at end of file
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp