dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32687
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16664: Apply web-api for getting attributes by the selected program or attributes with displayedInList a...
------------------------------------------------------------
revno: 16664
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-09 14:13:50 +0700
message:
Apply web-api for getting attributes by the selected program or attributes with displayedInList as true in Find/Add Instance form.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
--
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-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-07-18 11:34:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-09-09 07:13:50 +0000
@@ -562,10 +562,6 @@
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
- <bean id="org.hisp.dhis.caseentry.action.trackedentity.GetAttributesByProgramAction"
- class="org.hisp.dhis.caseentry.action.trackedentity.GetAttributesByProgramAction" scope="prototype">
- </bean>
-
<bean id="org.hisp.dhis.caseentry.action.trackedentity.GetVisitScheduleAttributesAction"
class="org.hisp.dhis.caseentry.action.trackedentity.GetVisitScheduleAttributesAction" scope="prototype">
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2014-07-11 05:28:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2014-09-09 07:13:50 +0000
@@ -626,13 +626,6 @@
<param name="page">/dhis-web-caseentry/attributeFormDiv.vm</param>
<param name="requiredAuthorities">F_TRACKED_ENTITY_INSTANCE_ADD</param>
</action>
-
- <action name="getAttributesByProgram"
- class="org.hisp.dhis.caseentry.action.trackedentity.GetAttributesByProgramAction">
- <result name="success" type="velocity-json">
- /dhis-web-caseentry/jsonProgramAttributes.vm
- </result>
- </action>
<action name="getVisitScheduleAttributes"
class="org.hisp.dhis.caseentry.action.trackedentity.GetVisitScheduleAttributesAction">
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2014-07-18 04:16:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2014-09-09 07:13:50 +0000
@@ -358,39 +358,73 @@
} else {
hideById('enrollmentSelectTR');
}
-
- $.postJSON("getAttributesByProgram.action", {
- id : program,
- entityInstanceId : getFieldValue('entityInstanceId')
- }, function(json) {
- removeAttributeOption('advSearchBox0');
- var attributeList = jQuery('#searchObjectId');
- jQuery('input[name=clearSearchBtn]').each(function() {
- jQuery(this).click();
- });
-
- clearListById('searchObjectId');
- clearListById('attributeIds');
- for ( var i in json.attributes) {
- jQuery('#searchObjectId').append(
- '<option value="' + json.attributes[i].id + '" >'
- + json.attributes[i].name + '</option>');
-
- if(json.attributes[i].displayed=='true'){
- jQuery('#attributeIds').append(
- '<option value="' + json.attributes[i].id
- + '" valueType="' + json.attributes[i].valueType + '"></option>');
- }
- }
-
- if (getFieldValue('program') != '') {
- jQuery('#searchObjectId').append(
- '<option value="programDate" >' + i18n_enrollment_date
- + '</option>');
- }
-
- addAttributeOption();
- });
+
+ if( program!=""){
+ $.get("../api/programs/" + program + ".json?fields=programTrackedEntityAttributes", {}
+ , function(json) {
+ removeAttributeOption('advSearchBox0');
+ var attributeList = jQuery('#searchObjectId');
+ jQuery('input[name=clearSearchBtn]').each(function() {
+ jQuery(this).click();
+ });
+
+ clearListById('searchObjectId');
+ clearListById('attributeIds');
+ for ( var i in json.programTrackedEntityAttributes) {
+ var progamAttribute = json.programTrackedEntityAttributes[i];
+ var attribute = progamAttribute.trackedEntityAttribute;
+ jQuery('#searchObjectId').append(
+ '<option value="' + attribute.id + '" >'
+ + attribute.name + '</option>');
+
+ if(json.programTrackedEntityAttributes[i].displayed=='true'){
+ jQuery('#attributeIds').append(
+ '<option value="' + attribute.id
+ + '" valueType="' + attribute.valueType + '"></option>');
+ }
+ }
+
+ if (getFieldValue('program') != '') {
+ jQuery('#searchObjectId').append(
+ '<option value="programDate" >' + i18n_enrollment_date
+ + '</option>');
+ }
+
+ addAttributeOption();
+ });
+ }
+ else
+ {
+ $.get("../api/trackedEntityAttributes.json?fields=id,name&filter=displayInListNoProgram:eq:true", {}
+ , function(json) {
+ removeAttributeOption('advSearchBox0');
+ var attributeList = jQuery('#searchObjectId');
+ jQuery('input[name=clearSearchBtn]').each(function() {
+ jQuery(this).click();
+ });
+
+ clearListById('searchObjectId');
+ clearListById('attributeIds');
+ for ( var i in json.trackedEntityAttributes) {
+ var attribute = json.trackedEntityAttributes[i];
+ jQuery('#searchObjectId').append(
+ '<option value="' + attribute.id + '" >' + attribute.name + '</option>');
+
+ jQuery('#attributeIds').append(
+ '<option value="' + attribute.id
+ + '" valueType="' + attribute.valueType + '"></option>');
+ }
+
+ if (getFieldValue('program') != '') {
+ jQuery('#searchObjectId').append(
+ '<option value="programDate" >' + i18n_enrollment_date
+ + '</option>');
+ }
+
+ addAttributeOption();
+ });
+ }
+
}
function enableRadioButton(programId) {