=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java 2015-07-10 05:22:40 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java 1970-01-01 00:00:00 +0000 @@ -1,125 +0,0 @@ -package org.hisp.dhis.webapi.utils; - -/* - * 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 org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dataelement.DataElementCategoryCombo; -import org.hisp.dhis.dataelement.DataElementCategoryOption; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.hisp.dhis.dxf2.webmessage.WebMessageException; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.HashSet; -import java.util.Set; - -/** - * @author Lars Helge Overland - */ -public class InputUtils -{ - @Autowired - private DataElementCategoryService categoryService; - - @Autowired - private IdentifiableObjectManager idObjectManager; - - /** - * Validates and retrieves the attribute option combo. 409 conflict as status - * code along with a textual message will be set on the response in case of - * invalid input. - * - * @param cc the category combo identifier. - * @param cp the category and option query string. - * @return the attribute option combo identified from the given input, or null - * if the input was invalid. - */ - public DataElementCategoryOptionCombo getAttributeOptionCombo( String cc, String cp ) throws WebMessageException - { - Set opts = ContextUtils.getQueryParamValues( cp ); - - // --------------------------------------------------------------------- - // Attribute category combo validation - // --------------------------------------------------------------------- - - if ( (cc == null && opts != null || (cc != null && opts == null)) ) - { - throw new WebMessageException( WebMessageUtils.conflict( "Both or none of category combination and category options must be present" ) ); - } - - DataElementCategoryCombo categoryCombo = null; - - if ( cc != null && (categoryCombo = idObjectManager.get( DataElementCategoryCombo.class, cc )) == null ) - { - throw new WebMessageException( WebMessageUtils.conflict( "Illegal category combo identifier: " + cc ) ); - } - - // --------------------------------------------------------------------- - // Attribute category options validation - // --------------------------------------------------------------------- - - DataElementCategoryOptionCombo attributeOptionCombo = null; - - if ( opts != null ) - { - Set categoryOptions = new HashSet<>(); - - for ( String uid : opts ) - { - DataElementCategoryOption categoryOption = idObjectManager.get( DataElementCategoryOption.class, uid ); - - if ( categoryOption == null ) - { - throw new WebMessageException( WebMessageUtils.conflict( "Illegal category option identifier: " + uid ) ); - } - - categoryOptions.add( categoryOption ); - } - - attributeOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryCombo, categoryOptions ); - - if ( attributeOptionCombo == null ) - { - throw new WebMessageException( WebMessageUtils.conflict( "Attribute option combo does not exist for given category combo and category options" ) ); - } - } - - if ( attributeOptionCombo == null ) - { - attributeOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); - } - - if ( attributeOptionCombo == null ) - { - throw new WebMessageException( WebMessageUtils.conflict( "Default attribute option combo does not exist" ) ); - } - - return attributeOptionCombo; - } -} === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties 2015-09-26 16:08:33 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties 2015-10-01 10:07:00 +0000 @@ -9,6 +9,7 @@ no_registered_event=There are no registered events. event_registration_error=Error in event registration validation_error=Validation Error +error=Error help=Help click_for_action=Click for more actions details=Details @@ -136,7 +137,7 @@ loading_tree=Loading orgunit tree loading_metadata=Loading meta-data future_date_not_allowed=Future date is not allowed -validation_warnings +validation_warnings=Validation Warnings unsaved_data_exists_proceed=Unsaved data exists. Do you want to proceed? proceed=Proceed lacking_required_authority_to_add_update_event=Lacking required authority to add/update event. @@ -145,4 +146,5 @@ hide_menu=Hide menu extend_menu=Extend menu show_main_menu=Show main menu -close_editing=Close editing \ No newline at end of file +close_editing=Close editing +fill_all_category_options=Please fill all category options. \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-30 07:30:39 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-10-01 10:07:00 +0000 @@ -243,18 +243,19 @@ $scope.getCategoryOptions = function(){ $scope.eventFetched = false; - var optionsReady = false; + $scope.optionsReady = false; $scope.selectedOptions = []; for(var i=0; i<$scope.selectedCategories.length; i++){ if($scope.selectedCategories[i].selectedOption && $scope.selectedCategories[i].selectedOption.id){ - optionsReady = true; - $scope.selectedOptions.push($scope.selectedCategories[i].selectedOption); + $scope.optionsReady = true; + $scope.selectedOptions.push($scope.selectedCategories[i].selectedOption.id); } else{ - optionsReady = false; + $scope.optionsReady = false; + break; } } - if(optionsReady){ + if($scope.optionsReady){ $scope.loadEvents(); } }; @@ -265,16 +266,26 @@ $scope.noteExists = false; $scope.dhis2Events = []; $scope.eventLength = 0; + $scope.eventFetched = false; + + var attributeCategoryUrl = {cc: $scope.selectedProgram.categoryCombo.id, default: $scope.selectedProgram.categoryCombo.isDefault, cp: ""}; + if(!$scope.selectedProgram.categoryCombo.isDefault){ + if($scope.selectedOptions.length !== $scope.selectedCategories.length){ + var dialogOptions = { + headerText: 'error', + bodyText: 'fill_all_category_options' + }; - $scope.eventFetched = false; + DialogService.showDialog({}, dialogOptions); + return false; + } + attributeCategoryUrl.cp = $scope.selectedOptions.join(';'); + } - if( $scope.selectedProgram && - $scope.selectedProgram.programStages && - $scope.selectedProgram.programStages[0] && - $scope.selectedProgram.programStages[0].id){ + if( $scope.selectedProgram && $scope.selectedProgramStage && $scope.selectedProgramStage.id){ //Load events for the selected program stage and orgunit - DHIS2EventFactory.getByStage($scope.selectedOrgUnit.id, $scope.selectedProgramStage.id, $scope.pager, true ).then(function(data){ + DHIS2EventFactory.getByStage($scope.selectedOrgUnit.id, $scope.selectedProgramStage.id, attributeCategoryUrl, $scope.pager, true ).then(function(data){ if(data.events){ $scope.eventLength = data.events.length; @@ -591,7 +602,22 @@ longitude: $scope.currentEvent.coordinate.longitude ? $scope.currentEvent.coordinate.longitude : ''}; } - //send the new event to server + if(!$scope.selectedProgram.categoryCombo.isDefault){ + if($scope.selectedOptions.length !== $scope.selectedCategories.length){ + var dialogOptions = { + headerText: 'error', + bodyText: 'fill_all_category_options' + }; + + DialogService.showDialog({}, dialogOptions); + return false; + } + + //dhis2Event.attributeCc = $scope.selectedProgram.categoryCombo.id; + dhis2Event.attributeCategoryOptions = $scope.selectedOptions.join(';'); + } + + //send the new event to server DHIS2EventFactory.create(dhis2Event).then(function(data) { if (data.response.importSummaries[0].status === 'ERROR') { var dialogOptions = { === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2015-09-25 13:33:59 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2015-10-01 10:07:00 +0000 @@ -249,10 +249,14 @@ .factory('DHIS2EventFactory', function($http, $q, ECStorageService, $rootScope) { return { - getByStage: function(orgUnit, programStage, pager, paging){ + getByStage: function(orgUnit, programStage, attributeCategoryUrl, pager, paging){ var url = '../api/events.json?' + 'orgUnit=' + orgUnit + '&programStage=' + programStage; + if(attributeCategoryUrl && !attributeCategoryUrl.default){ + url = url + '&attributeCc=' + attributeCategoryUrl.cc + '&attributeCos=' + attributeCategoryUrl.cp; + } + if(paging){ var pgSize = pager ? pager.pageSize : 50; var pg = pager ? pager.page : 1; === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2015-09-22 16:33:27 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2015-10-01 10:07:00 +0000 @@ -97,6 +97,7 @@ border: 1px solid #c2c2c2; border-radius: 5px; padding: 12px; + margin-left: -15px; margin-bottom: 20px; } === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html 2015-09-24 15:28:23 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html 2015-10-01 10:07:00 +0000 @@ -68,7 +68,7 @@ -
+