=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm 2011-01-22 20:56:30 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm 2011-05-16 14:21:57 +0000 @@ -7,4 +7,8 @@ "default": "$coc.isDefault()" }#if( $velocityCount < $size ),#end #end -] } +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm 2011-05-16 14:21:57 +0000 @@ -6,4 +6,8 @@ "name": "$!encoder.jsonEncode( ${dataElementGroup.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-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementOperands.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementOperands.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementOperands.vm 2011-05-16 14:21:57 +0000 @@ -0,0 +1,21 @@ +#set( $size = $operands.size() ) +{ "operands": [ +#foreach( $operand in $operands ) + { + "operandName": "$!{operand.operandName}", + "dataElement": { + "id": "$!{operand.dataElement.id}", + "name": "$!{operand.dataElement.name}", + "type": "$!{operand.dataElement.type}" + }, + "categoryOptionCombo": { + "id": "$!{operand.categoryOptionCombo.id}", + "name": "$!{operand.categoryOptionCombo.name}" + } + }#if( $velocityCount < $size ),#end +#end +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm 2011-05-16 14:21:57 +0000 @@ -12,4 +12,8 @@ "zeroIsSignificant": "$!{dataElement.zeroIsSignificant}" }#if( $velocityCount < $size ),#end #end -] } +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm 2011-05-16 14:21:57 +0000 @@ -8,4 +8,8 @@ "periodTypeId": "$!{dataSet.periodTypeId}" }#if( $velocityCount < $size ),#end #end -] } \ No newline at end of file +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroups.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroups.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroups.vm 2011-05-16 14:21:57 +0000 @@ -6,4 +6,8 @@ "name": "$!encoder.jsonEncode( ${indicatorGroup.name} )" }#if( $velocityCount < $size ),#end #end -] } \ No newline at end of file +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicators.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicators.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicators.vm 2011-05-16 14:21:57 +0000 @@ -11,4 +11,8 @@ "indicatorTypeId": $!{indicator.indicatorType.id} }#if( $velocityCount < $size ),#end #end -] } \ No newline at end of file +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm 2011-05-16 14:21:57 +0000 @@ -6,4 +6,8 @@ "name": "$!encoder.jsonEncode( ${group.name} )" }#if( $velocityCount < $size ),#end #end -] } +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm 2011-05-16 14:21:57 +0000 @@ -6,4 +6,8 @@ "level": "$level.level" }#if( $velocityCount < $size ),#end #end -] } +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm 2010-12-12 19:49:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnits.vm 2011-05-16 14:21:57 +0000 @@ -9,5 +9,8 @@ "hasChildrenWithCoordinates": $!{unit.hasChildrenWithCoordinates()} }#if( $velocityCount < $size ),#end #end -] } - \ No newline at end of file +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 2011-05-16 14:21:57 +0000 @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2004-2010, 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. + */ + +/* + * @author mortenoh + */ + +(function($) { + var templates = { + button: "", + option: "", + option_selected: "", + wrapper: "
", + pagesize_input: "", + filter_input: "", + select_page: "" + } + + var methods = { + load: function(select_id) { + var $select = $("#" + select_id); + var settings = $select.data("settings"); + var params = settings.params; + + var id = $select.attr("id"); + var wrapper_id = id + "_wrapper"; + $wrapper = $("#" + wrapper_id); + var select_page_id = id + "_select_page"; + var $select_page = $("#" + select_page_id); + var next_button_id = id + "_next_button"; + var $next_button = $("#" + next_button_id); + var previous_button_id = id + "_previous_button"; + var $previous_button = $("#" + previous_button_id); + var filter_input_id = id + "_filter_input"; + var pagesize_input_id = id + "_pagesize_input"; + var $pagesize_input = $("#" + pagesize_input_id); + + $.getJSON(settings.url, $.param( settings.params ), function(json) { + $select.empty(); + $select_page.empty(); + + params.currentPage = json.paging.currentPage; + params.numberOfPages = json.paging.numberOfPages; + params.pageSize = json.paging.pageSize; + params.startPage = json.paging.startPage; + + settings.handler($select, json); + + for(var j=1; j<=params.numberOfPages; j++) { + if(params.currentPage == j) { + $select_page.append( $.tmpl(templates.option_selected, {"text": j}) ); + } else { + $select_page.append( $.tmpl(templates.option, {"text": j}) ); + } + } + + $("#" + pagesize_input_id).val( params.pageSize ); + + $previous_button.removeAttr("disabled"); + $next_button.removeAttr("disabled"); + + if(params.currentPage == params.startPage) { + $previous_button.attr("disabled", "disabled"); + } + + if(params.currentPage == params.numberOfPages) { + $next_button.attr("disabled", "disabled"); + } + + settings.params = params; + $select.data("settings", settings); + }); + }, + init: function(options) { + var settings = { } + var params = { } + + $.extend(settings, options); + $.extend(params, options.params); + params.usePaging = true; + + var $select = $(this); + var id = $(this).attr("id"); + var wrapper_id = id + "_wrapper"; + var select_page_id = id + "_select_page"; + var next_button_id = id + "_next_button"; + var previous_button_id = id + "_previous_button"; + var filter_input_id = id + "_filter_input"; + var pagesize_input_id = id + "_pagesize_input"; + + $select.wrap( $.tmpl(templates.wrapper, { "id": wrapper_id }) ); + $wrapper = $("#" + wrapper_id); + + $wrapper.append( $.tmpl(templates.select_page, { "id": select_page_id }) ) + $select_page = $("#" + select_page_id); + + $wrapper.append( $.tmpl(templates.button, { "id": previous_button_id, "text":"previous" }) ); + $previous_button = $("#" + previous_button_id); + + $wrapper.append( $.tmpl(templates.button, { "id": next_button_id, "text":"next" }) ); + $next_button = $("#" + next_button_id); + + $wrapper.append( $.tmpl(templates.pagesize_input, { "id": pagesize_input_id }) ); + $pagesize_input = $("#" + pagesize_input_id); + + settings.params = params; + $select.data("settings", settings); + methods.load("" + id); + + $next_button.click(function() { + params.currentPage = +params.currentPage + 1; + settings.params = params; + $select.data("settings", settings); + + methods.load("" + id); + }); + + $previous_button.click(function() { + params.currentPage = +params.currentPage - 1; + settings.params = params; + $select.data("settings", settings); + + methods.load("" + id); + }); + + $select_page.change(function() { + params.currentPage = +$(this).find(":selected").val(); + settings.params = params; + $select.data("settings", settings); + + methods.load("" + id); + }); + + $pagesize_input.change(function() { + params.pageSize = +$(this).val(); + params.currentPage = 1; + settings.params = params; + $select.data("settings", settings); + + methods.load("" + id); + }); + } + } + + $.fn.dhisPaging = function(method) { + if(methods[method]) { + return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); + } else if (typeof method === 'object' || !method) { + return methods.init.apply(this, arguments); + } else { + $.error('Method ' + method + ' does not exist on jQuery.dhisPaging' ); + } + }; +})(jQuery); === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementOperandsAction.java 2011-05-16 14:21:57 +0000 @@ -0,0 +1,129 @@ +package org.hisp.dhis.commons.action; + +/* + * Copyright (c) 2004-2010, 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.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementOperand; +import org.hisp.dhis.dataelement.comparator.DataElementOperandNameComparator; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.paging.ActionPagingSupport; + +/** + * @author mortenoh + */ +public class GetDataElementOperandsAction + extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private DataElementCategoryService dataElementCategoryService; + + public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService ) + { + this.dataElementCategoryService = dataElementCategoryService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer dataSetId; + + public void setDataSetId( Integer dataSetId ) + { + this.dataSetId = dataSetId; + } + + private String key; + + public void setKey( String key ) + { + this.key = key; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + public List operands; + + public List getOperands() + { + return operands; + } + + private DataSet dataSet; + + public DataSet getDataSet() + { + return dataSet; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + if ( dataSetId != null ) + { + dataSet = dataSetService.getDataSet( dataSetId ); + + operands = new ArrayList( dataElementCategoryService.getFullOperands( dataSet + .getDataElements() ) ); + } + else + { + operands = new ArrayList(); + } + + Collections.sort( operands, new DataElementOperandNameComparator() ); + + if ( usePaging ) + { + this.paging = createPaging( operands.size() ); + + operands = operands.subList( paging.getStartPos(), paging.getEndPos() ); + } + + 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 2011-05-13 12:34:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-05-16 14:21:57 +0000 @@ -398,6 +398,11 @@ + + + + + === 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 2011-05-10 08:07:40 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-05-16 14:21:57 +0000 @@ -538,6 +538,12 @@ plainTextError + + + /dhis-web-commons/ajax/jsonDataElementOperands.vm + plainTextError + + /dhis-web-commons/ajax/jsonOperands.vm === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2011-05-12 23:33:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2011-05-16 14:21:57 +0000 @@ -1,3 +1,4 @@ +