dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29494
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14915: Approval, in list of category option groups/approval items, including a none option in the situat...
------------------------------------------------------------
revno: 14915
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-20 17:54:16 +0200
message:
Approval, in list of category option groups/approval items, including a none option in the situation where there are approval levels both with and without group sets for the given org unit level
modified:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
--
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-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java 2014-04-03 19:02:51 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataapproval/action/GetCategoryOptionGroupsAction.java 2014-04-20 15:54:16 +0000
@@ -39,6 +39,7 @@
import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
@@ -58,6 +59,13 @@
@Autowired
private DataElementCategoryService categoryService;
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -105,7 +113,9 @@
categoryOptionGroups = new ArrayList<CategoryOptionGroup>( categoryService.getAllCategoryOptionGroups() );
- FilterUtils.filter( categoryOptionGroups, new CategoryOptionGroupGroupSetFilter( groupSets ) );
+ FilterUtils.filter( categoryOptionGroups, new CategoryOptionGroupGroupSetFilter( groupSets ) );
+
+ addNoneGroupIfNoGroupSet( approvalLevels, categoryOptionGroups );
}
return SUCCESS;
@@ -114,7 +124,31 @@
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
-
+
+ /**
+ * Adds a category option group with name "none" if the given list of approval
+ * levels is not empty and contains at least one level without a category
+ * option group set associated with it.
+ */
+ private void addNoneGroupIfNoGroupSet( List<DataApprovalLevel> approvalLevels, List<CategoryOptionGroup> categoryOptionGroups )
+ {
+ boolean hasNoGroupSet = false;
+
+ for ( DataApprovalLevel level : approvalLevels )
+ {
+ if ( level != null && !level.hasCategoryOptionGroupSet() )
+ {
+ hasNoGroupSet = true;
+ }
+ }
+
+ if ( !approvalLevels.isEmpty() && hasNoGroupSet )
+ {
+ CategoryOptionGroup cog = new CategoryOptionGroup( "[ " + i18n.getString( "none") + " ]" );
+ categoryOptionGroups.add( 0, cog );
+ }
+ }
+
/**
* Returns the category option group sets associated with the given list of
* data approval levels.
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2014-04-03 19:02:51 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2014-04-20 15:54:16 +0000
@@ -180,7 +180,6 @@
get_report_as_jrxml=Download as JRXML
select_category_combo=Select category combination
sort_order=Sort order
-none=None
ascending=Low to high
descending=High to low
top_limit=Top limit