dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12156
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3669: made move selected/all buttons work.
------------------------------------------------------------
revno: 3669
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-05-19 16:53:21 +0200
message:
made move selected/all buttons work.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.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-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 2011-05-19 11:57:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2011-05-19 14:53:21 +0000
@@ -2,57 +2,132 @@
<script type="text/javascript">
var jqDataElementsSelectedList, jqIndicatorsSelectedList;
- jQuery(function() {
- jqDataElementsSelectedList = jQuery("#dataElementsSelectedList");
- jqIndicatorsSelectedList = jQuery("#indicatorsSelectedList");
-
- jqDataElementsSelectedList.dblclick(function(e) {
- var option = jQuery(this).find(":selected");
- var option_id = +option.attr("value");
- option.remove();
-
- var settings = jQuery("#availableDataElementsList").data("settings");
+ function dhisPaging_moveAllSelected(sourceId)
+ {
+ jQuery("#" + sourceId).dblclick();
+ }
+
+ function dhisPaging_moveAll(sourceId)
+ {
+ var jqSource = jQuery("#" + sourceId);
+ jqSource.find("option").attr("selected", "selected");
+ jqSource.dblclick();
+ }
+
+ function dataElementsSelectedList_dblclick(e) {
+ var settings = jQuery("#availableDataElementsList").data("settings");
+
+ jQuery(this).find(":selected").each(function(i) {
+ var jqThis = jQuery(this);
+ var option_id = +jqThis.attr("value");
+ jqThis.remove();
if( jQuery.isArray(settings.removeDataElements) )
{
var remove_idx = jQuery.inArray(option_id, settings.removeDataElements);
settings.removeDataElements.splice(remove_idx, remove_idx+1);
-
- if(settings.removeDataElements.length > 0) {
- settings.params.removeDataElements = settings.removeDataElements.join(",");
- } else {
- delete settings.removeDataElements;
- delete settings.params.removeDataElements;
- }
- }
-
- jQuery("#availableDataElementsList").data("settings", settings);
- jQuery("#availableDataElementsList").dhisPaging("load", "availableDataElementsList");
+ }
+ });
+
+ if(settings.removeDataElements && settings.removeDataElements.length > 0) {
+ settings.params.removeDataElements = settings.removeDataElements.join(",");
+ } else {
+ delete settings.removeDataElements;
+ delete settings.params.removeDataElements;
+ }
+
+ jQuery("#availableDataElementsList").data("settings", settings);
+ jQuery("#availableDataElementsList").dhisPaging("load", "availableDataElementsList");
+ }
+
+ function availableDataElementsList_dblclick(e) {
+ var settings = jQuery("#availableDataElementsList").data("settings");
+
+ jQuery("#availableDataElementsList").find(":selected").each(function(i) {
+ var jqThis = jQuery(this);
+ var option_id = +jqThis.attr("value");
+
+ jqDataElementsSelectedList.append( this );
+
+ if( jQuery.isArray(settings.removeDataElements) ) {
+ settings.removeDataElements.push(option_id);
+ } else {
+ settings.removeDataElements = [option_id];
+ }
});
- jqIndicatorsSelectedList.dblclick(function(e) {
- var option = jQuery(this).find(":selected");
- var option_id = +option.attr("value");
- option.remove();
-
- var settings = jQuery("#availableIndicatorsList").data("settings");
+ if(settings.removeDataElements && settings.removeDataElements.length > 0) {
+ settings.params.removeDataElements = settings.removeDataElements.join(",");
+ } else {
+ delete settings.removeDataElements;
+ delete settings.params.removeDataElements;
+ }
+
+ jQuery("#availableDataElementsList").data("settings", settings);
+ jQuery("#availableDataElementsList").dhisPaging("load", "availableDataElementsList");
+ }
+
+ function indicatorsSelectedList_dblclick(e) {
+ var settings = jQuery("#availableIndicatorsList").data("settings");
+
+ jQuery(this).find(":selected").each(function(i) {
+ var jqThis = jQuery(this);
+ var option_id = +jqThis.attr("value");
+ jqThis.remove();
if( jQuery.isArray(settings.removeIndicators) )
{
var remove_idx = jQuery.inArray(option_id, settings.removeIndicators);
settings.removeIndicators.splice(remove_idx, remove_idx+1);
-
- if(settings.removeIndicators.length > 0) {
- settings.params.removeIndicators = settings.removeIndicators.join(",");
- } else {
- delete settings.removeIndicators;
- delete settings.params.removeIndicators;
- }
- }
-
- jQuery("#availableIndicatorsList").data("settings", settings);
- jQuery("#availableIndicatorsList").dhisPaging("load", "availableIndicatorsList");
- });
+ }
+ });
+
+ if(settings.removeIndicators && settings.removeIndicators.length > 0) {
+ settings.params.removeIndicators = settings.removeIndicators.join(",");
+ } else {
+ delete settings.removeIndicators;
+ delete settings.params.removeIndicators;
+ }
+
+ jQuery("#availableIndicatorsList").data("settings", settings);
+ jQuery("#availableIndicatorsList").dhisPaging("load", "availableIndicatorsList");
+ }
+
+ function availableIndicatorsList_dblclick(e) {
+ var settings = jQuery("#availableIndicatorsList").data("settings");
+
+ jQuery("#availableIndicatorsList").find(":selected").each(function(i) {
+ var jqThis = jQuery(this);
+ var option_id = jqThis.attr("value");
+
+ jqIndicatorsSelectedList.append( this );
+
+ if( jQuery.isArray(settings.removeIndicators) ) {
+ settings.removeIndicators.push(+option_id);
+ } else {
+ settings.removeIndicators = [+option_id];
+ }
+ });
+
+ if(settings.removeIndicators && settings.removeIndicators.length > 0) {
+ settings.params.removeIndicators = settings.removeIndicators.join(",");
+ } else {
+ delete settings.removeIndicators;
+ delete settings.params.removeIndicators;
+ }
+
+ jQuery("#availableIndicatorsList").data("settings", settings);
+ jQuery("#availableIndicatorsList").dhisPaging("load", "availableIndicatorsList");
+ }
+
+ jQuery(function() {
+ jqDataElementsSelectedList = jQuery("#dataElementsSelectedList");
+ jqIndicatorsSelectedList = jQuery("#indicatorsSelectedList");
+
+ jqDataElementsSelectedList.dblclick(dataElementsSelectedList_dblclick);
+ jqIndicatorsSelectedList.dblclick(indicatorsSelectedList_dblclick);
+ jQuery("#availableDataElementsList").dblclick(availableDataElementsList_dblclick);
+ jQuery("#availableIndicatorsList").dblclick(availableIndicatorsList_dblclick);
jQuery("#availableDataElementsList").dhisPaging({
source: "../dhis-web-commons-ajax-json/getDataElements.action",
@@ -62,27 +137,6 @@
option.text( item.name );
option.attr( "value", item.id );
- option.dblclick(function(e) {
- var jqThis = jQuery(this);
- jqThis.unbind();
- var option_id = jqThis.attr("value");
-
- jqDataElementsSelectedList.append( this );
-
- var settings = jQuery("#availableDataElementsList").data("settings");
-
- if( jQuery.isArray(settings.removeDataElements) ) {
- settings.removeDataElements.push(+option_id);
- } else {
- settings.removeDataElements = [+option_id];
- }
-
- settings.params.removeDataElements = settings.removeDataElements.join(",");
-
- jQuery("#availableDataElementsList").data("settings", settings);
- jQuery("#availableDataElementsList").dhisPaging("load", "availableDataElementsList");
- });
-
return option;
},
filter: {
@@ -103,27 +157,6 @@
option.text( item.name );
option.attr( "value", item.id );
- option.dblclick(function(e) {
- var jqThis = jQuery(this);
- jqThis.unbind();
- var option_id = jqThis.attr("value");
-
- jqIndicatorsSelectedList.append( this );
-
- var settings = jQuery("#availableIndicatorsList").data("settings");
-
- if( jQuery.isArray(settings.removeIndicators) ) {
- settings.removeIndicators.push(+option_id);
- } else {
- settings.removeIndicators = [+option_id];
- }
-
- settings.params.removeIndicators = settings.removeIndicators.join(",");
-
- jQuery("#availableIndicatorsList").data("settings", settings);
- jQuery("#availableIndicatorsList").dhisPaging("load", "availableIndicatorsList");
- });
-
return option;
},
filter: {
@@ -202,7 +235,7 @@
<td>
</td>
<td>[$i18n.getString( "group" )]</td>
- <td></td>
+ <td></td>
</tr>
<tr>
@@ -216,10 +249,10 @@
<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="moveSelectedById( 'availableList', 'selectedList');"/><br/>
- <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="moveSelectedById( 'selectedList', 'availableList');"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="moveAllById( 'availableList', 'selectedList' );"/><br/>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'selectedList', 'availableList' );"/>
+ <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'availableDataElementsList' );"/><br/>
+ <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'dataElementsSelectedList' );"/><br/>
+ <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisPaging_moveAll( 'availableDataElementsList' );"/><br/>
+ <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisPaging_moveAll( 'dataElementsSelectedList' );"/>
</td>
<td>
<select id="dataElementsSelectedList" name="dataElementsSelectedList" multiple="multiple" style="min-width:25em;height:20em"></select>
@@ -260,10 +293,10 @@
<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="moveSelectedById( 'indicatorAvailableList', 'indicatorSelectedList');"/><br/>
- <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="moveSelectedById( 'indicatorSelectedList', 'indicatorAvailableList');"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="moveAllById( 'indicatorAvailableList', 'indicatorSelectedList' );"/><br/>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'indicatorSelectedList', 'indicatorAvailableList' );"/>
+ <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'availableIndicatorsList' );"/><br/>
+ <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'indicatorsSelectedList' );"/><br/>
+ <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisPaging_moveAll( 'availableIndicatorsList' );"/><br/>
+ <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisPaging_moveAll( 'indicatorsSelectedList' );"/>
</td>
<td>
<select id="indicatorsSelectedList" name="indicatorsSelectedList" multiple="multiple" style="min-width:20em;height:20em"></select>