dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21069
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9876: Updated category UI for selecting category options
------------------------------------------------------------
revno: 9876
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-02-22 12:39:14 +0100
message:
Updated category UI for selecting category options
removed:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOption.vm
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementCategoryOptions.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionsAction.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml
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/dhis-web-commons.xml
dhis-2/dhis-web/dhis-web-commons/src/test/java/org/hisp/dhis/ouwt/manager/OrganisationUnitSelectionManagerTest.java
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/GetDataElementCategoryAction.java
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/resources/org/hisp/dhis/dd/i18n_module.properties
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/multidimensional/addDataElementCategoryForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryOptionForm.vm
--
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-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 @@
<key column="categoryid" foreign-key="fk_categories_categoryoptions_categoryid" />
<list-index column="sort_order" base="1" />
<many-to-many class="org.hisp.dhis.dataelement.DataElementCategoryOption" column="categoryoptionid"
- foreign-key="fk_category_categoryoptionid" unique="true" />
+ foreign-key="fk_category_categoryoptionid" />
</list>
</class>
=== 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<DataElementCategoryOption> categoryOptions;
+
+ public List<DataElementCategoryOption> getCategoryOptions()
+ {
+ return categoryOptions;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ categoryOptions = new ArrayList<DataElementCategoryOption>( 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">
</bean>
+ <bean id="org.hisp.dhis.commons.action.GetCategoryOptionsAction" class="org.hisp.dhis.commons.action.GetCategoryOptionsAction" scope="prototype"/>
+
<bean id="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction" class="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction"
scope="prototype">
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
=== 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 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="getDataElementCategoryOptions" class="org.hisp.dhis.commons.action.GetCategoryOptionsAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonDataElementCategoryOptions.vm
+ </result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<action name="getDataSet" class="org.hisp.dhis.commons.action.GetDataSetAction">
<result name="success" type="velocity-json">
/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<String> categoryOptionNames = new ArrayList<String>();
+ private List<String> selectedList = new ArrayList<String>();
- public void setCategoryOptionNames( List<String> categoryOptionNames )
+ public void setSelectedList( List<String> selectedList )
{
- this.categoryOptionNames = categoryOptionNames;
+ this.selectedList = selectedList;
}
// -------------------------------------------------------------------------
@@ -97,13 +97,16 @@
dataElementCategory.setName( name );
dataElementCategory.setConcept( conceptService.getConcept( conceptId ) );
- for ( String categoryOptionName : categoryOptionNames )
+ List<DataElementCategoryOption> options = new ArrayList<DataElementCategoryOption>();
+
+ 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<Concept>( 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<String> categoryOptions = new ArrayList<String>();
+ private List<String> selectedList = new ArrayList<String>();
- public void setCategoryOptions( List<String> categoryOptions )
+ public void setSelectedList( List<String> 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<DataElementCategoryOption> options = new ArrayList<DataElementCategoryOption>();
- 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 @@
<script type="text/javascript">
jQuery(document).ready( function() {
+ jQuery("#availableList").dhisAjaxSelect({
+ source: "../dhis-web-commons-ajax-json/getDataElementCategoryOptions.action",
+ iterator: 'dataElementCategoryOptions',
+ sortSelected: false,
+ connectedTo: 'selectedList',
+ handler: function(item) {
+ var option = jQuery("<option />");
+ option.text( item.name );
+ option.attr( "value", item.id );
+
+ return option;
+ }
+ });
+
validation2( 'addDataElementCategoryForm', function( form ){ form.submit() }, {
- 'beforeValidateHandler': function() { listValidator( 'memberValidator', 'categoryOptionNames' ); },
+ 'beforeValidateHandler': function() {
+ jQuery("#selectedList option").each(function() { jQuery(this).attr("selected", "true"); });
+ listValidator( 'memberValidator', 'categoryOptionNames' );
+ },
'rules': getValidationRules("dateElementCategory")
});
@@ -39,49 +56,53 @@
<tr>
<td colspan="4" style="height:15px"></td>
</tr>
- <tr>
- <th colspan="4">$i18n.getString( "category_options" )
- <select id="memberValidator" style="display:none"/></th>
- </tr>
- <tr>
- <td><label>$i18n.getString( "name" )</label></td>
- <td colspan="3"><input type="text" id="categoryOptionName" name="categoryOptionName" style="width:25em"/></td>
- </tr>
- <tr>
- <td></td>
- <td colspan="3">
- <input type="button" value="$i18n.getString( 'add_category_option' )" onclick="addCategoryOption()" style="width:200px"/>
- </td>
- </tr>
- <tr>
- <td></td>
- <td>
- <table>
- <tr>
- <td>
- <select multiple size="10" id="categoryOptionNames" name="categoryOptionNames" style="width:300px">
- </select>
- </td>
- <td>
- <a href="javascript:moveUpSelectedOption( 'categoryOptionNames' )"><img src="../images/move_up.png"/></a><br/><br/>
- <a href="javascript:moveDownSelectedOption( 'categoryOptionNames' )"><img src="../images/move_down.png"/></a><br/><br/>
- <a href="javascript:removeSelectedOption( 'categoryOptionNames' )"><img src="../images/delete.png"/></a>
- </td>
- </tr>
- </table>
- </td>
-
- <td style="width:30px; text-align:center"> </td>
- </tr>
- <tr>
- <td colspan="4" style="height:15px"></td>
- </tr>
- <tr>
- <td></td>
- <td colspan="3">
- <input type="submit" value="$i18n.getString( 'add' )" style="width:100px">
- <input type="button" onclick="window.location.href='category.action'" value="$i18n.getString( 'cancel' )" style="width:100px"/></p>
- </td>
- </tr>
+ </table>
+
+ <table id="dataElementCategoryOptionSelectionArea">
+ <colgroup>
+ <col style="width: 500px;"/>
+ <col/>
+ <col style="width: 500px;"/>
+ <col/>
+ </colgroup>
+
+ <thead>
+ <tr>
+ <th>$i18n.getString( "available_category_options" )</th>
+ <th></th>
+ <th>$i18n.getString( "selected_category_options" )</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <tr>
+ <td>
+ <select id="availableList" name="availableList" multiple="multiple" style="height: 200px; width: 100%;"></select>
+ </td>
+
+ <td style="text-align:center">
+ <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableList' );"/><br/>
+ <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedList' );"/><br/>
+ <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableList' );"/><br/>
+ <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedList' );"/>
+ </td>
+
+ <td>
+ <select id="selectedList" name="selectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;"></select>
+ </td>
+
+ <td>
+ <a onclick="moveUpSelectedOption('selectedList')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
+ <a onclick="moveDownSelectedOption('selectedList')" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_down' )"/></a>
+ </td>
+ </tr>
+
+ </tbody>
</table>
+
+ <p>
+ <input type="submit" value="$i18n.getString( 'add' )" style="width:100px">
+ <input type="button" onclick="window.location.href='category.action'" value="$i18n.getString( 'cancel' )" style="width:100px"/>
+ </p>
+
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm 2011-09-27 18:03:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm 2013-02-22 11:39:14 +0000
@@ -1,7 +1,25 @@
<script type="text/javascript">
jQuery(document).ready( function() {
- validation2( 'editDataElementCategoryForm', function( form ){ form.submit()}, {
- 'beforeValidateHandler': function() { listValidator( 'memberValidator', 'categoryOptions' ); },
+ jQuery("#availableList").dhisAjaxSelect({
+ source: "../dhis-web-commons-ajax-json/getDataElementCategoryOptions.action",
+ iterator: 'dataElementCategoryOptions',
+ sortSelected: false,
+ connectedTo: 'selectedList',
+ handler: function(item) {
+ var option = jQuery("<option />");
+ option.text( item.name );
+ option.attr( "value", item.id );
+
+ return option;
+ }
+ });
+
+ validation2( 'editDataElementCategoryForm', function( form ){ form.submit()},
+ {
+ 'beforeValidateHandler': function() {
+ jQuery("#selectedList option").each(function() { jQuery(this).attr("selected", "true"); });
+ listValidator( 'memberValidator', 'categoryOptions' );
+ },
'rules': getValidationRules("dateElementCategory")
});
@@ -46,52 +64,60 @@
<tr>
<td colspan="4" style="height:15px"></td>
</tr>
- <tr>
- <th colspan="4">$i18n.getString( "category_options" )
- <select id="memberValidator" style="display:none"/></th>
- </tr>
- <tr>
- <td><label>$i18n.getString( "selected_name" )</label></td>
- <td colspan="3"><input type="text" id="categoryOptionName" name="categoryOptionName" style="width:25em"/></td>
- <td></td>
- </tr>
- <tr>
- <td></td>
- <td colspan="3">
- <input type="button" value="$i18n.getString( 'add_category_option' )" onclick="addCategoryOptionToExistingCategory();" style="width:150px"/>
- <input type="button" value="$i18n.getString( 'update_category_option' )" onclick="updateCategoryOption();" style="width:150px"/>
- </td>
- </tr>
- <tr>
- <td></td>
- <td>
- <table>
- <tr>
- <td>
- <select multiple size="10" id="categoryOptions" name="categoryOptions" style="width:300px" onclick="getSelectedCategoryOption();">
- #foreach( $categoryOption in $dataElementCategory.categoryOptions )
- <option value="$categoryOption.id">$encoder.htmlEncode( $categoryOption.name )</option>
- #end
- </select>
- </td>
- <td style="width:30px; text-align:center">
- <a href="javascript:moveUpSelectedOption( 'categoryOptions' )"><img src="../images/move_up.png"/></a><br/><br/>
- <a href="javascript:moveDownSelectedOption( 'categoryOptions' )"><img src="../images/move_down.png"/></a><br/><br/>
- <a href="javascript:removeCategoryOption()"><img src="../images/delete.png"/></a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan="4" style="height:15px"></td>
- </tr>
- <tr>
- <td></td>
- <td colspan="3">
- <input type="submit" value="$i18n.getString( 'save' )" style="width:100px"/>
- <input type="button" onclick="window.location.href='category.action'" value="$i18n.getString( 'cancel' )" style="width:100px"/></p>
- </td>
- </tr>
- </table>
+ </table>
+
+
+ <table id="dataElementCategoryOptionSelectionArea">
+ <colgroup>
+ <col style="width: 500px;"/>
+ <col/>
+ <col style="width: 500px;"/>
+ <col/>
+ </colgroup>
+
+ <thead>
+ <tr>
+ <th>$i18n.getString( "available_category_options" )</th>
+ <th></th>
+ <th>$i18n.getString( "selected_category_options" )</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <tr>
+ <td>
+ <select id="availableList" name="availableList" multiple="multiple" style="height: 200px; width: 100%;"></select>
+ </td>
+ </td>
+
+ <td style="text-align:center">
+ <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableList' );"/><br/>
+ <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedList' );"/><br/>
+ <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableList' );"/><br/>
+ <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedList' );"/>
+ </td>
+
+ <td>
+ <select id="selectedList" name="selectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;">
+ #foreach ( $categoryOption in $dataElementCategory.categoryOptions )
+ <option value="$categoryOption.id">$encoder.htmlEncode( $categoryOption.name )</option>
+ #end
+ </select>
+ </td>
+
+ <td>
+ <a onclick="moveUpSelectedOption('selectedList')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
+ <a onclick="moveDownSelectedOption('selectedList')" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_down' )"/></a>
+ </td>
+
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:100px"/>
+ <input type="button" onclick="window.location.href='category.action'" value="$i18n.getString( 'cancel' )" style="width:100px"/></p>
+ </p>
+
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryOptionForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryOptionForm.vm 2013-02-22 08:14:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryOptionForm.vm 2013-02-22 11:39:14 +0000
@@ -1,11 +1,11 @@
<script type="text/javascript">
- jQuery(document).ready( function() {
- validation2( 'editDataElementCategoryOptionForm', function( form ){ form.submit()}, {
+ jQuery(document).ready( function() {
+ validation2( 'editDataElementCategoryOptionForm', function( form ){ form.submit()}, {
'beforeValidateHandler': function() { listValidator( 'memberValidator', 'categoryOptions' ); },
'rules': getValidationRules("dateElementCategoryOption")
});
- checkValueIsExist( "name", "validateDataElementCategoryOption.action", {id: $dataElementCategoryOption.id} );
+ checkValueIsExist( "name", "validateDataElementCategoryOption.action", {id: $dataElementCategoryOption.id} );
checkValueIsExist( "code", "validateDataElementCategoryOption.action", {id: $dataElementCategoryOption.code} );
});