=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml 2013-02-07 10:25:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml 2013-02-22 11:39:14 +0000 @@ -25,7 +25,7 @@ + foreign-key="fk_category_categoryoptionid" /> === removed file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOption.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOption.vm 2011-09-27 17:05:48 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOption.vm 1970-01-01 00:00:00 +0000 @@ -1,6 +0,0 @@ -{ "dataElementCategoryOption": - { - "id": "$!{dataElementCategoryOption.id}", - "name": "$encoder.jsonEncode( $!{dataElementCategoryOption.name} )" - } -} \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementCategoryOptions.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementCategoryOptions.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementCategoryOptions.vm 2013-02-22 11:39:14 +0000 @@ -0,0 +1,13 @@ +#set( $size = $categoryOptions.size() ) +{ "dataElementCategoryOptions": [ +#foreach( $categoryOption in $categoryOptions ) + { + "id": ${categoryOption.id} , + "name": "$!encoder.jsonEncode( ${categoryOption.name} )" + }#if( $velocityCount < $size ),#end +#end +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionsAction.java 2013-02-22 11:39:14 +0000 @@ -0,0 +1,73 @@ +package org.hisp.dhis.commons.action; + +/* + * Copyright (c) 2004-2012, 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 java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + */ +public class GetCategoryOptionsAction + implements Action +{ + @Autowired + private DataElementCategoryService categoryService; + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private List categoryOptions; + + public List getCategoryOptions() + { + return categoryOptions; + } + + // ------------------------------------------------------------------------- + // Action + // ------------------------------------------------------------------------- + + public String execute() + { + categoryOptions = new ArrayList( categoryService.getAllDataElementCategoryOptions() ); + + Collections.sort( categoryOptions, IdentifiableObjectNameComparator.INSTANCE ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2013-02-19 09:57:46 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2013-02-22 11:39:14 +0000 @@ -317,6 +317,8 @@ scope="prototype"> + + === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2013-01-03 12:43:44 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2013-02-22 11:39:14 +0000 @@ -614,6 +614,13 @@ plainTextError + + + /dhis-web-commons/ajax/jsonDataElementCategoryOptions.vm + + plainTextError + + /dhis-web-commons/ajax/jsonDataSet.vm === modified file 'dhis-2/dhis-web/dhis-web-commons/src/test/java/org/hisp/dhis/ouwt/manager/OrganisationUnitSelectionManagerTest.java' --- dhis-2/dhis-web/dhis-web-commons/src/test/java/org/hisp/dhis/ouwt/manager/OrganisationUnitSelectionManagerTest.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/test/java/org/hisp/dhis/ouwt/manager/OrganisationUnitSelectionManagerTest.java 2013-02-22 11:39:14 +0000 @@ -37,7 +37,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.junit.Test; -import static junit.framework.Assert.*; +import static org.junit.Assert.*; /** * @author Torgeir Lorange Ostby === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryAction.java 2013-02-22 11:39:14 +0000 @@ -80,11 +80,11 @@ this.conceptId = conceptId; } - private List categoryOptionNames = new ArrayList(); + private List selectedList = new ArrayList(); - public void setCategoryOptionNames( List categoryOptionNames ) + public void setSelectedList( List selectedList ) { - this.categoryOptionNames = categoryOptionNames; + this.selectedList = selectedList; } // ------------------------------------------------------------------------- @@ -97,13 +97,16 @@ dataElementCategory.setName( name ); dataElementCategory.setConcept( conceptService.getConcept( conceptId ) ); - for ( String categoryOptionName : categoryOptionNames ) + List options = new ArrayList(); + + for ( String id : selectedList ) { - DataElementCategoryOption categoryOption = new DataElementCategoryOption( categoryOptionName ); - dataElementCategoryService.addDataElementCategoryOption( categoryOption ); - dataElementCategory.getCategoryOptions().add( categoryOption ); + DataElementCategoryOption categoryOption = dataElementCategoryService.getDataElementCategoryOption( Integer.parseInt( id ) ); + options.add( categoryOption ); } + dataElementCategory.setCategoryOptions( options ); + dataElementCategoryService.addDataElementCategory( dataElementCategory ); return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryAction.java 2012-01-25 17:11:43 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryAction.java 2013-02-22 11:39:14 +0000 @@ -100,7 +100,7 @@ public String execute() { dataElementCategory = dataElementCategoryService.getDataElementCategory( id ); - + concepts = new ArrayList( conceptService.getAllConcepts() ); Collections.sort( concepts, IdentifiableObjectNameComparator.INSTANCE ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryAction.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryAction.java 2013-02-22 11:39:14 +0000 @@ -87,11 +87,11 @@ this.conceptId = conceptId; } - private List categoryOptions = new ArrayList(); + private List selectedList = new ArrayList(); - public void setCategoryOptions( List categoryOptions ) + public void setSelectedList( List selectedList ) { - this.categoryOptions = categoryOptions; + this.selectedList = selectedList; } // ------------------------------------------------------------------------- @@ -104,13 +104,9 @@ dataElementCategory.setName( name ); dataElementCategory.setConcept( conceptService.getConcept( conceptId ) ); - // --------------------------------------------------------------------- - // CategoryOptions can only be sorted on update - // --------------------------------------------------------------------- - List options = new ArrayList(); - for ( String id : categoryOptions ) + for ( String id : selectedList ) { options.add( dataElementCategoryService.getDataElementCategoryOption( Integer.parseInt( id ) ) ); } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2013-02-22 08:14:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties 2013-02-22 11:39:14 +0000 @@ -198,8 +198,10 @@ legend_set=Legend set skip_total_in_reports=Skip category total in reports translation_label_formName = Form name -data_element_category_option = Data element category option +data_element_category_option = Data Element Category Option intro_data_element_category_option=Create, modify, view and delete data element category options. Category Option are fine-grained break-downs of catagory. data_element_category_option_management = Data element category option management create_new_data_element_category_option=Create new data element category option -edit_data_element_category_option=Edit data element category option \ No newline at end of file +edit_data_element_category_option=Edit data element category option +available_category_options=Available category options +selected_category_options=Selected category options \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js 2011-09-28 13:39:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/category.js 2013-02-22 11:39:14 +0000 @@ -3,131 +3,3 @@ { removeItem( categoryId, categoryName, i18n_confirm_delete, 'removeDataElementCategory.action' ); } - -function addCategoryOption() -{ - var value = $( '#categoryOptionName' ).val(); - - if ( value.length == 0 ) - { - markInvalid( 'categoryOptionName', i18n_specify_category_option_name ); - } - else if ( listContainsById( 'categoryOptionNames', value ) ) - { - markInvalid( 'categoryOptionName', i18n_category_option_name_already_exists ); - } - else - { - jQuery.postJSON( 'validateDataElementCategoryOption.action', { name:value }, function( json ) - { - if ( json.response == 'success' ) - { - addOptionById( 'categoryOptionNames', value, value ); - setFieldValue( 'categoryOptionName', '' ); - } - else - { - markInvalid( 'categoryOptionName', i18n_category_option_name_already_exists ); - } - } ); - } -} - -function addCategoryOptionToExistingCategory() -{ - var name = $( '#categoryOptionName' ).val(); - var id = $( '#id' ).val(); - - if ( name.length == 0 ) - { - markInvalid( 'categoryOptionName', i18n_specify_category_option_name ); - } - else if ( listContainsById( 'categoryOptions', name, true ) ) - { - markInvalid( 'categoryOptionName', i18n_category_option_name_already_exists ); - } - else - { - jQuery.postJSON( 'validateDataElementCategoryOption.action', { name:name, id:id }, function( json ) - { - if ( json.response == 'success' ) - { - saveCategoryOption( id, name ); - } - else - { - markInvalid( 'categoryOptionName', i18n_category_option_name_already_exists ); - } - } ); - } -} - -function removeCategoryOption() -{ - var id = $( '#categoryOptions :selected' ).val(); - var name = $( '#categoryOptions :selected' ).text(); - - if ( id != null ) - { - removeItem( id, name, i18n_confirm_delete, 'removeDataElementCategoryOption.action' ); - removeSelectedOption( 'categoryOptions' ); - } -} - -function updateCategoryOption() -{ - var name = $( '#categoryOptionName' ).val(); - var id = $( '#categoryOptions :selected' ).val(); - - if ( name.length == 0 ) - { - markInvalid( 'categoryOptionName', i18n_specify_category_option_name ); - } - else if ( listContainsById( 'categoryOptions', name, true ) ) - { - markInvalid( 'categoryOptionName', i18n_category_option_name_already_exists ); - } - else - { - jQuery.postJSON( 'validateDataElementCategoryOption.action', { name:name, id:id }, function( json ) - { - if ( json.response == 'success' ) - { - updateCategoryOptionName(); - } - else - { - markInvalid( 'categoryOptionName', i18n_category_option_name_already_exists ); - } - } ); - } -} - -function getSelectedCategoryOption() -{ - var name = $( '#categoryOptions :selected' ).text(); - $( '#categoryOptionName' ).val( name ); -} - -function updateCategoryOptionName() -{ - var id = $( '#categoryOptions :selected' ).val(); - var name = $( '#categoryOptionName' ).val(); - - var url = 'updateDataElementCategoryOption.action?id=' + id + '&name=' + name; - - $.postUTF8( url, {}, function() - { - $( '#categoryOptions :selected' ).text( name ); - } ); -} - -function saveCategoryOption( id, name ) -{ - var url = 'addDataElementCategoryOption.action'; - - $.postJSON( url, { categoryId:id, name:name }, function( json ) - { - addOptionById( 'categoryOptions', json.dataElementCategoryOption.id, name ); - } ); -} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm 2011-09-27 12:16:53 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm 2013-02-22 11:39:14 +0000 @@ -1,7 +1,24 @@