dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29192
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14714: use new selection plugin in add/edit dataSet
------------------------------------------------------------
revno: 14714
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-07 14:19:13 +0700
message:
use new selection plugin in add/edit dataSet
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.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-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js 2014-04-07 02:58:35 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.selected.js 2014-04-07 07:19:13 +0000
@@ -7,40 +7,40 @@
!(function( $, window, document, undefined ) {
var methods = {
create: function( options ) {
- var settings = {};
- $.extend(settings, $.fn.selected.defaults, options);
+ var context = {};
+ $.extend(context, $.fn.selected.defaults, options);
- if( settings.target === undefined ) {
+ if( context.target === undefined ) {
$.error('selected: Missing options.target, please add your target box either as a jqEl or as a query.');
- } else if( settings.url === undefined ) {
+ } else if( context.url === undefined ) {
$.error('selected: Missing options.url, please give URL of where to find the source data.');
- } else if( !$.isFunction(settings.handler) ) {
+ } else if( !$.isFunction(context.handler) ) {
$.error('selected: Invalid options.handler.');
}
// pass-through if jqEl, query if string
- settings.source = this;
- settings.target = $(settings.target);
- settings.search = $(settings.search);
+ context.source = this;
+ context.target = $(context.target);
+ context.search = $(context.search);
- if( !(settings.source instanceof $) ) {
+ if( !(context.source instanceof $) ) {
$.error('selected: Invalid source.');
- } else if( !(settings.target instanceof $) ) {
+ } else if( !(context.target instanceof $) ) {
$.error('selected: Invalid target.');
}
- settings.source.data('selected', settings);
- settings.target.data('selected', settings);
-
- settings.page = 1;
- settings.defaultProgressiveLoader(settings);
-
- settings.source.on('dblclick', 'option', settings.defaultSourceDblClickHandler);
- settings.target.on('dblclick', 'option', settings.defaultTargetDblClickHandler);
- settings.source.on('scroll', settings.makeScrollHandler(settings));
-
- if( settings.search instanceof $ ) {
- settings.search.on('keypress', settings.makeSearchHandler(settings));
+ context.source.data('selected', context);
+ context.target.data('selected', context);
+
+ context.page = 1;
+ context.defaultProgressiveLoader(context);
+
+ context.source.on('dblclick', 'option', context.defaultSourceDblClickHandler);
+ context.target.on('dblclick', 'option', context.defaultTargetDblClickHandler);
+ context.source.on('scroll', context.makeScrollHandler(context));
+
+ if( context.search instanceof $ ) {
+ context.search.on('keypress', context.makeSearchHandler(context));
}
}
};
@@ -93,62 +93,64 @@
$this.removeAttr('selected');
$selected.source.append($this);
},
- makeSearchHandler: function( settings ) {
+ makeSearchHandler: function( context ) {
return function( e ) {
if( e.keyCode == 13 ) {
- settings.defaultProgressiveLoader(settings, $(this).val());
+ context.page = 1;
+ context.like = $(this).val();
+ context.defaultProgressiveLoader(context);
e.preventDefault();
}
}
},
- makeScrollHandler: function( settings ) {
+ makeScrollHandler: function( context ) {
return function( e ) {
- if( settings.source[0].offsetHeight + settings.source.scrollTop() >= settings.source[0].scrollHeight ) {
- settings.defaultProgressiveLoader(settings);
+ if( context.source[0].offsetHeight + context.source.scrollTop() >= context.source[0].scrollHeight ) {
+ context.defaultProgressiveLoader(context);
}
}
},
- defaultProgressiveLoader: function( settings, search ) {
- if( settings.page === undefined ) {
+ defaultProgressiveLoader: function( context ) {
+ if( context.page === undefined ) {
return;
}
var request = {
- url: settings.url,
+ url: context.url,
data: {
paging: true,
pageSize: 50,
- page: settings.page
+ page: context.page
},
dataType: 'json'
};
- if( search !== undefined && search.length > 0 ) {
- request.data.filter = 'name:like:' + search;
+ if( context.like !== undefined && context.like.length > 0 ) {
+ request.data.filter = 'name:like:' + context.like;
}
return $.ajax(request).done(function( data ) {
if( data.pager.page == 1 ) {
- settings.source.children().remove();
- }
-
- settings.page++;
-
- if( settings.page > data.pager.pageCount ) {
- delete settings.page;
- }
-
- if( data[settings.iterator] === undefined ) {
- $.error('selected: Invalid iterator for source url: ' + settings.iterator);
- }
-
- $.each(data[settings.iterator], function( idx ) {
- if( settings.target.find('option[value=' + this.id + ']').length == 0 ) {
- settings.source.append(settings.handler(this));
+ context.source.children().remove();
+ }
+
+ context.page++;
+
+ if( context.page > data.pager.pageCount ) {
+ delete context.page;
+ }
+
+ if( data[context.iterator] === undefined ) {
+ $.error('selected: Invalid iterator for source url: ' + context.iterator);
+ }
+
+ $.each(data[context.iterator], function( idx ) {
+ if( context.target.find('option[value=' + this.id + ']').length == 0 ) {
+ context.source.append(context.handler(this));
}
});
}).fail(function() {
- settings.source.children().remove();
+ context.source.children().remove();
});
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2014-04-06 12:57:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2014-04-07 07:19:13 +0000
@@ -438,7 +438,7 @@
</thead>
<tbody>
<tr>
- <td><input id="${args.prefix}AvailableSearch}" type="text" placeholder=" Search.." style="width: 100%; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;" /></td>
+ <td><input id="${args.prefix}AvailableSearch" type="text" placeholder=" Search.." style="width: 100%; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;" /></td>
<td></td>
<td></td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java 2014-04-07 07:19:13 +0000
@@ -28,8 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.collect.Lists;
import com.opensymphony.xwork2.Action;
-
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
@@ -44,7 +44,6 @@
import org.hisp.dhis.user.UserGroupService;
import org.hisp.dhis.user.UserService;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -53,7 +52,6 @@
/**
* @author Kristian
- * @version $Id: AddDataSetAction.java 6255 2008-11-10 16:01:24Z larshelg $
*/
public class AddDataSetAction
implements Action
@@ -82,7 +80,7 @@
{
this.indicatorService = indicatorService;
}
-
+
private DataElementCategoryService categoryService;
public void setCategoryService( DataElementCategoryService categoryService )
@@ -219,9 +217,9 @@
{
this.validCompleteOnly = validCompleteOnly;
}
-
+
private boolean noValueRequiresComment;
-
+
public void setNoValueRequiresComment( boolean noValueRequiresComment )
{
this.noValueRequiresComment = noValueRequiresComment;
@@ -255,22 +253,22 @@
this.renderHorizontally = renderHorizontally;
}
- private Collection<String> dataElementsSelectedList = new HashSet<String>();
+ private List<String> deSelected = Lists.newArrayList();
- public void setDataElementsSelectedList( Collection<String> dataElementsSelectedList )
+ public void setDeSelected( List<String> deSelected )
{
- this.dataElementsSelectedList = dataElementsSelectedList;
+ this.deSelected = deSelected;
}
- private Collection<String> indicatorsSelectedList = new HashSet<String>();
+ private List<String> inSelected = Lists.newArrayList();
- public void setIndicatorsSelectedList( Collection<String> indicatorsSelectedList )
+ public void setInSelected( List<String> inSelected )
{
- this.indicatorsSelectedList = indicatorsSelectedList;
+ this.inSelected = inSelected;
}
private Integer categoryComboId;
-
+
public void setCategoryComboId( Integer categoryComboId )
{
this.categoryComboId = categoryComboId;
@@ -315,23 +313,23 @@
dataSet.setTimelyDays( timelyDays );
dataSet.setSkipAggregation( skipAggregation );
- for ( String id : dataElementsSelectedList )
+ for ( String id : deSelected )
{
- dataSet.addDataElement( dataElementService.getDataElement( Integer.parseInt( id ) ) );
+ dataSet.addDataElement( dataElementService.getDataElement( id ) );
}
Set<Indicator> indicators = new HashSet<Indicator>();
- for ( String id : indicatorsSelectedList )
+ for ( String id : inSelected )
{
- indicators.add( indicatorService.getIndicator( Integer.parseInt( id ) ) );
+ indicators.add( indicatorService.getIndicator( id ) );
}
if ( categoryComboId != null )
{
dataSet.setCategoryCombo( categoryService.getDataElementCategoryCombo( categoryComboId ) );
}
-
+
dataSet.setDescription( description );
dataSet.setVersion( 1 );
dataSet.setMobile( false );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2014-04-07 07:19:13 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.collect.Lists;
import com.opensymphony.xwork2.Action;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataelement.DataElement;
@@ -46,7 +47,6 @@
import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.user.UserGroupService;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -56,7 +56,6 @@
/**
* @author Kristian
- * @version $Id: UpdateDataSetAction.java 6255 2008-11-10 16:01:24Z larshelg $
*/
public class UpdateDataSetAction
implements Action
@@ -238,7 +237,7 @@
}
private boolean noValueRequiresComment;
-
+
public void setNoValueRequiresComment( boolean noValueRequiresComment )
{
this.noValueRequiresComment = noValueRequiresComment;
@@ -272,22 +271,22 @@
this.renderHorizontally = renderHorizontally;
}
- private Collection<String> dataElementsSelectedList = new HashSet<String>();
+ private List<String> deSelected = Lists.newArrayList();
- public void setDataElementsSelectedList( Collection<String> dataElementsSelectedList )
+ public void setDeSelected( List<String> deSelected )
{
- this.dataElementsSelectedList = dataElementsSelectedList;
+ this.deSelected = deSelected;
}
- private Collection<String> indicatorsSelectedList = new HashSet<String>();
+ private List<String> inSelected = Lists.newArrayList();
- public void setIndicatorsSelectedList( Collection<String> indicatorsSelectedList )
+ public void setInSelected( List<String> inSelected )
{
- this.indicatorsSelectedList = indicatorsSelectedList;
+ this.inSelected = inSelected;
}
private Integer categoryComboId;
-
+
public void setCategoryComboId( Integer categoryComboId )
{
this.categoryComboId = categoryComboId;
@@ -326,16 +325,16 @@
MapLegendSet legendSet = mappingService.getMapLegendSet( selectedLegendSetId );
- for ( String id : dataElementsSelectedList )
+ for ( String id : deSelected )
{
- dataElements.add( dataElementService.getDataElement( Integer.parseInt( id ) ) );
+ dataElements.add( dataElementService.getDataElement( id ) );
}
Set<Indicator> indicators = new HashSet<Indicator>();
- for ( String id : indicatorsSelectedList )
+ for ( String id : inSelected )
{
- indicators.add( indicatorService.getIndicator( Integer.parseInt( id ) ) );
+ indicators.add( indicatorService.getIndicator( id ) );
}
PeriodType periodType = periodService.getPeriodTypeByName( frequencySelect );
@@ -346,7 +345,7 @@
dataSet.setTimelyDays( timelyDays );
dataSet.setSkipAggregation( skipAggregation );
- if ( !( equalsNullSafe( name, dataSet.getName() ) &&
+ if ( !(equalsNullSafe( name, dataSet.getName() ) &&
periodType.equals( dataSet.getPeriodType() ) &&
dataElements.equals( dataSet.getDataElements() ) &&
indicators.equals( dataSet.getIndicators() ) &&
@@ -379,7 +378,7 @@
{
dataSet.setCategoryCombo( categoryService.getDataElementCategoryCombo( categoryComboId ) );
}
-
+
if ( jsonAttributeValues != null )
{
AttributeUtils.updateAttributeValuesFromJson( dataSet.getAttributeValues(), jsonAttributeValues,
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2014-01-23 11:54:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2014-04-07 07:19:13 +0000
@@ -1,62 +1,34 @@
<script type="text/javascript">
- jQuery(function() {
- validation2('addDataSetForm', function(form) {
- form.submit();
- }, {
- 'beforeValidateHandler' : function() {
- $("#dataElementsSelectedList").find("option").attr("selected", "selected");
- $("#indicatorsSelectedList").find("option").attr("selected", "selected");
- #tblDynamicAttributesJavascript()
- },
- 'rules' : getValidationRules("dataSet")
- });
-
- checkValueIsExist("code", "validateDataSet.action");
-
- jQuery("#availableDataElementsList").dhisAjaxSelect({
- source: "../dhis-web-commons-ajax-json/getDataElements.action?domain=aggregate",
- iterator: "dataElements",
- connectedTo: 'dataElementsSelectedList',
- handler: function(item) {
- var option = jQuery("<option data-id='" + item.groups + "' />");
- option.text( item.name );
- option.attr( "value", item.id );
-
- return option;
- },
- filter: {
- source: "../dhis-web-commons-ajax-json/getDataElementGroups.action",
- label: 'dataelement group',
- iterator: "dataElementGroups",
- handler: function(item) {
- return "<option data-key='id' data-value='" + item.id + "'>" + item.name + "</option>";
- }
- }
- });
-
- jQuery("#availableIndicatorsList").dhisAjaxSelect({
- source: "../dhis-web-commons-ajax-json/getIndicators.action",
- iterator: "indicators",
- connectedTo: 'indicatorsSelectedList',
- handler: function(item) {
- var option = jQuery("<option data-id='" + item.groups + "' />");
- option.text( item.name );
- option.attr( "value", item.id );
-
- return option;
- },
- filter: {
- source: "../dhis-web-commons-ajax-json/getIndicatorGroups.action",
- iterator: "indicatorGroups",
- label: 'indicator group',
- handler: function(item) {
- return "<option data-key='id' data-value='" + item.id + "'>" + item.name + "</option>";
- }
- }
- });
- });
-
- var previousName = '';
+ jQuery(function() {
+ validation2('addDataSetForm', function( form ) {
+ form.submit();
+ }, {
+ 'beforeValidateHandler': function() {
+ $("#deSelected").find("option").attr("selected", "selected");
+ $("#inSelected").find("option").attr("selected", "selected");
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules': getValidationRules("dataSet")
+ });
+
+ checkValueIsExist("code", "validateDataSet.action");
+
+ $('#deAvailable').selected({
+ url: '../api/dataElements.json',
+ target: $('#deSelected'),
+ search: $('#deAvailableSearch'),
+ iterator: 'dataElements'
+ });
+
+ $('#inAvailable').selected({
+ url: '../api/indicators.json',
+ target: $('#inSelected'),
+ search: $('#inAvailableSearch'),
+ iterator: 'indicators'
+ });
+ });
+
+ var previousName = '';
</script>
<h3>$i18n.getString( "add_dataset" )</h3>
@@ -266,79 +238,25 @@
</thead>
</table>
- <table id="dataElementSelectionArea">
- <colgroup>
- <col style="width: 500px;"/>
- <col/>
- <col style="width: 500px;"/>
- </colgroup>
- <thead>
- <tr>
- <th>$i18n.getString( "available_data_elements" )</th>
- <th>$i18n.getString( "filter" )</th>
- <th>$i18n.getString( "selected_data_elements" )</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>
- <select id="availableDataElementsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
- </td>
- <td>
- <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableDataElementsList' );"/><br/>
- <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'dataElementsSelectedList' );"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableDataElementsList' );"/><br/>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'dataElementsSelectedList' );"/>
- </td>
- <td>
- <select id="dataElementsSelectedList" name="dataElementsSelectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 45px;"></select>
- </td>
- </tr>
- </tbody>
- </table>
-
- <br/>
-
- <table id="indicatorSelectionArea">
- <colgroup>
- <col style="width: 500px;"/>
- <col/>
- <col style="width: 500px;"/>
- </colgroup>
-
- <thead>
- <tr>
- <th>$i18n.getString( "available_indicators" )</th>
- <th>$i18n.getString( "filter" )</th>
- <th>$i18n.getString( "selected_indicators" )</th>
- </tr>
- </thead>
-
- <tbody>
- <tr>
- <td>
- <select id="availableIndicatorsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
- </td>
-
- <td>
- <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableIndicatorsList' );"/><br/>
- <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'indicatorsSelectedList' );"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableIndicatorsList' );"/><br/>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'indicatorsSelectedList' );"/>
- </td>
-
- <td>
- <select id="indicatorsSelectedList" name="indicatorsSelectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 45px;"></select>
- </td>
- </tr>
-
- <tr>
- <td colspan="3">
- <input type="submit" value="$i18n.getString( 'save' )" style="width:120px" />
- <input type="button" onclick="dhis2.commons.redirectCurrentPage( 'dataSet.action' )" value="$i18n.getString( 'cancel' )" style="width:120px" />
- </td>
- </tr>
-
- </tbody>
- </table>
+#jqSelected({
+ "prefix": "de",
+ "i18n_available": "available_data_elements",
+ "i18n_selected": "selected_data_elements"
+})
+
+#jqSelected({
+ "prefix": "in",
+ "i18n_available": "available_indicators",
+ "i18n_selected": "selected_indicators"
+})
+
+<table>
+<tr>
+ <td colspan="3">
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:120px" />
+ <input type="button" onclick="dhis2.commons.redirectCurrentPage( 'dataSet.action' )" value="$i18n.getString( 'cancel' )" style="width:120px" />
+ </td>
+</tr>
+</table>
+
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2014-01-23 11:54:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2014-04-07 07:19:13 +0000
@@ -1,66 +1,38 @@
<script type="text/javascript">
- jQuery(function() {
- validation2('editDataSetForm', function(form) {
- form.submit();
- }, {
- 'beforeValidateHandler' : function() {
- $("#dataElementsSelectedList").find("option").attr("selected", "selected");
- $("#indicatorsSelectedList").find("option").attr("selected", "selected");
- #tblDynamicAttributesJavascript()
- },
- 'rules' : getValidationRules("dataSet")
- });
-
- checkValueIsExist("code", "validateDataSet.action", {
- dataSetId : function() {
- return jQuery("#dataSetId").val();
- }
- });
-
- jQuery("#availableDataElementsList").dhisAjaxSelect({
- source: "../dhis-web-commons-ajax-json/getDataElements.action?domain=aggregate",
- iterator: "dataElements",
- connectedTo: 'dataElementsSelectedList',
- handler: function(item) {
- var option = jQuery("<option data-id='" + item.groups + "' />");
- option.text( item.name );
- option.attr( "value", item.id );
-
- return option;
- },
- filter: {
- source: "../dhis-web-commons-ajax-json/getDataElementGroups.action",
- label: 'dataelement group',
- iterator: "dataElementGroups",
- handler: function(item) {
- return "<option data-key='id' data-value='" + item.id + "'>" + item.name + "</option>";
- }
- }
- });
-
- jQuery("#availableIndicatorsList").dhisAjaxSelect({
- source: "../dhis-web-commons-ajax-json/getIndicators.action",
- iterator: "indicators",
- connectedTo: 'indicatorsSelectedList',
- handler: function(item) {
- var option = jQuery("<option data-id='" + item.groups + "' />");
- option.text( item.name );
- option.attr( "value", item.id );
-
- return option;
- },
- filter: {
- source: "../dhis-web-commons-ajax-json/getIndicatorGroups.action",
- iterator: "indicatorGroups",
- label: 'indicator group',
- handler: function(item) {
- return "<option data-key='id' data-value='" + item.id + "'>" + item.name + "</option>";
- }
- }
- });
- });
-
- var previousName = '';
+ jQuery(function() {
+ validation2('editDataSetForm', function( form ) {
+ form.submit();
+ }, {
+ 'beforeValidateHandler': function() {
+ $("#deSelected").find("option").attr("selected", "selected");
+ $("#inSelected").find("option").attr("selected", "selected");
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules': getValidationRules("dataSet")
+ });
+
+ checkValueIsExist("code", "validateDataSet.action", {
+ dataSetId: function() {
+ return jQuery("#dataSetId").val();
+ }
+ });
+
+ $('#deAvailable').selected({
+ url: '../api/dataElements.json',
+ target: $('#deSelected'),
+ search: $('#deAvailableSearch'),
+ iterator: 'dataElements'
+ });
+
+ $('#inAvailable').selected({
+ url: '../api/indicators.json',
+ target: $('#inSelected'),
+ search: $('#inAvailableSearch'),
+ iterator: 'indicators'
+ });
+ });
+
+ var previousName = '';
</script>
<h3>$i18n.getString( "edit_dataset" )</h3>
@@ -158,7 +130,7 @@
<option value="true"#if( $dataSet.skipAggregation == true ) selected="selected"#end>$i18n.getString( "yes" )</option>
</select>
</td>
- </tr>
+ </tr>
</tbody>
</table>
@@ -237,7 +209,7 @@
<option value="true"#if( $dataSet.dataElementDecoration == true ) selected="selected"#end>$i18n.getString( "yes" )</option>
</select>
</td>
- </tr>
+ </tr>
<tr>
<td><label for="renderAsTabs">$i18n.getString( "render_as_tabs" )</label></td>
<td>
@@ -269,87 +241,26 @@
</thead>
</table>
- <table id="dataElementSelectionArea">
- <colgroup>
- <col style="width: 500px;"/>
- <col/>
- <col style="width: 500px;"/>
- </colgroup>
- <thead>
- <tr>
- <th>$i18n.getString( "available_data_elements" )</th>
- <th>$i18n.getString( "filter" )</th>
- <th>$i18n.getString( "selected_data_elements" )</th>
- </tr>
- </thead>
- <tbody>
-
- <tr>
- <td>
- <select id="availableDataElementsList" name="availableDataElementsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
- </td>
-
- <td>
- <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableDataElementsList' );"/><br/>
- <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'dataElementsSelectedList' );"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableDataElementsList' );"/><br/>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'dataElementsSelectedList' );"/>
- </td>
-
- <td>
- <select id="dataElementsSelectedList" name="dataElementsSelectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 45px;">
- #foreach ( $availableDataElement in $dataElements )
- <option value="$availableDataElement.id">$encoder.htmlEncode( $availableDataElement.displayName )</option>
- #end
- </select>
- </td>
- </tr>
-
- </tbody>
- </table>
-
- <br/>
-
- <table id="indicatorSelectionArea">
- <colgroup>
- <col style="width: 500px;"/>
- <col/>
- <col style="width: 500px;"/>
- </colgroup>
- <thead>
- <tr>
- <th>$i18n.getString( "available_indicators" )</th>
- <th>$i18n.getString( "filter" )</th>
- <th>$i18n.getString( "selected_indicators" )</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>
- <select id="availableIndicatorsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
- </td>
- <td>
- <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableIndicatorsList' );"/><br/>
- <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'indicatorsSelectedList' );"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableIndicatorsList' );"/><br/>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'indicatorsSelectedList' );"/>
- </td>
- <td>
- <select id="indicatorsSelectedList" name="indicatorsSelectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 45px;">
- #foreach ( $availableIndicator in $indicators )
- <option value="$availableIndicator.id">$encoder.htmlEncode( $availableIndicator.displayName )</option>
- #end
- </select>
- </td>
- </tr>
-
- <tr>
- <td colspan="3">
- <input type="submit" value="$i18n.getString( 'save' )" style="width:120px" />
- <input type="button" onclick="dhis2.commons.redirectCurrentPage( 'dataSet.action' )" value="$i18n.getString( 'cancel' )" style="width:120px" />
- </td>
- </tr>
-
- </tbody>
- </table>
+#jqSelected({
+ "prefix": "de",
+ "i18n_available": "available_data_elements",
+ "i18n_selected": "selected_data_elements",
+ "objects": $dataElements
+})
+
+#jqSelected({
+ "prefix": "in",
+ "i18n_available": "available_indicators",
+ "i18n_selected": "selected_indicators",
+ "objects": $indicators
+})
+
+<table>
+ <tr>
+ <td colspan="3">
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:120px" />
+ <input type="button" onclick="dhis2.commons.redirectCurrentPage( 'dataSet.action' )" value="$i18n.getString( 'cancel' )" style="width:120px" />
+ </td>
+ </tr>
+</table>
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm 2014-04-07 02:08:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm 2014-04-07 07:19:13 +0000
@@ -183,44 +183,3 @@
</p>
</form>
-
-
-
-<!--
-<table>
- <colgroup>
- <col style="width: 500px;"/>
- <col/>
- <col style="width: 500px;"/>
- </colgroup>
-
-<tr>
- <th>$i18n.getString( "available" )</th>
- <th></th>
- <th>$i18n.getString( "selected" )
- <select id="roleValidator" style="display:none"/>
- </th>
-</tr>
-
-<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;">
- #foreach ( $selectedRole in $userCredentials.userAuthorityGroups )
- <option value="$selectedRole.id">$encoder.htmlEncode( $selectedRole.name )</option>
- #end
- </select>
- </td>
-</tr>
-</table>
--->