dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12222
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3709: generalized move functionality
------------------------------------------------------------
revno: 3709
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-05-23 15:51:02 +0200
message:
generalized move functionality
modified:
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-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-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataSet.js
--
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/jQuery/jquery.dhisPaging.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 2011-05-23 13:05:25 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 2011-05-23 13:51:02 +0000
@@ -33,11 +33,13 @@
// Support functions
// -----------------------------------------------
+/* perform dblclick action on the sourceId */
function dhisPaging_moveAllSelected(sourceId)
{
jQuery("#" + sourceId).dblclick();
}
+/* select all options and perform dblclick action on the sourceId */
function dhisPaging_moveAll(sourceId)
{
var jqSource = jQuery("#" + sourceId);
@@ -45,6 +47,69 @@
jqSource.dblclick();
}
+/*
+ *
+ */
+function dhisPaging_availableList_dblclick(sourceId, targetId, removeArray) {
+ var jqAvailableList = jQuery("#" + sourceId);
+ var jqSelectedList = jQuery("#" + targetId);
+
+ var settings = jqAvailableList.data("settings");
+
+ jqAvailableList.find(":selected").each(function(i) {
+ var jqThis = jQuery(this);
+ var option_id = +jqThis.attr("value");
+
+ jqSelectedList.append( this );
+
+ if( jQuery.isArray(settings[removeArray]) ) {
+ settings[removeArray].push(option_id);
+ } else {
+ settings[removeArray] = [option_id];
+ }
+ });
+
+ if(settings[removeArray] && settings[removeArray].length > 0) {
+ settings.params[removeArray] = settings[removeArray].join(",");
+ } else {
+ delete settings[removeArray];
+ delete settings.params[removeArray];
+ }
+
+ jqAvailableList.dhisPaging("load", sourceId);
+}
+
+/*
+ *
+ */
+function dhisPaging_selectedList_dblclick(sourceId, targetId, removeArray) {
+ var jqAvailableList = jQuery("#" + targetId);
+ var jqSelectedList = jQuery("#" + sourceId);
+
+ var settings = jQuery("#" + targetId).data("settings");
+
+ jqSelectedList.find(":selected").each(function(i) {
+ var jqThis = jQuery(this);
+ var option_id = +jqThis.attr("value");
+ jqThis.remove();
+
+ if( jQuery.isArray(settings[removeArray]) )
+ {
+ var remove_idx = jQuery.inArray(option_id, settings[removeArray]);
+ settings[removeArray].splice(remove_idx, remove_idx+1);
+ }
+ });
+
+ if(settings[removeArray] && settings[removeArray].length > 0) {
+ settings.params[removeArray] = settings[removeArray].join(",");
+ } else {
+ delete settings[removeArray];
+ delete settings.params[removeArray];
+ }
+
+ jqAvailableList.dhisPaging("load", targetId);
+}
+
// -----------------------------------------------
// Plugin
// -----------------------------------------------
=== 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-20 11:01:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2011-05-23 13:51:02 +0000
@@ -1,13 +1,24 @@
<script type="text/javascript" src="javascript/addDataSet.js"></script>
<script type="text/javascript">
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);
+ var jqDataElementsSelectedList = jQuery("#dataElementsSelectedList");
+ var jqIndicatorsSelectedList = jQuery("#indicatorsSelectedList");
+
+ jQuery("#availableDataElementsList").dblclick(function() {
+ dhisPaging_availableList_dblclick("availableDataElementsList", "dataElementsSelectedList", "removeDataElements");
+ });
+
+ jqDataElementsSelectedList.dblclick(function() {
+ dhisPaging_selectedList_dblclick("dataElementsSelectedList", "availableDataElementsList", "removeDataElements");
+ });
+
+ jQuery("#availableIndicatorsList").dblclick(function() {
+ dhisPaging_availableList_dblclick("availableIndicatorsList", "indicatorsSelectedList", "removeIndicators");
+ });
+
+ jqIndicatorsSelectedList.dblclick(function() {
+ dhisPaging_selectedList_dblclick("indicatorsSelectedList", "availableIndicatorsList", "removeIndicators");
+ });
jQuery("#availableDataElementsList").dhisPaging({
source: "../dhis-web-commons-ajax-json/getDataElements.action",
=== 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 2011-05-20 11:01:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2011-05-23 13:51:02 +0000
@@ -21,13 +21,24 @@
}
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);
+ var jqDataElementsSelectedList = jQuery("#dataElementsSelectedList");
+ var jqIndicatorsSelectedList = jQuery("#indicatorsSelectedList");
+
+ jQuery("#availableDataElementsList").dblclick(function() {
+ dhisPaging_availableList_dblclick("availableDataElementsList", "dataElementsSelectedList", "removeDataElements");
+ });
+
+ jqDataElementsSelectedList.dblclick(function() {
+ dhisPaging_selectedList_dblclick("dataElementsSelectedList", "availableDataElementsList", "removeDataElements");
+ });
+
+ jQuery("#availableIndicatorsList").dblclick(function() {
+ dhisPaging_availableList_dblclick("availableIndicatorsList", "indicatorsSelectedList", "removeIndicators");
+ });
+
+ jqIndicatorsSelectedList.dblclick(function() {
+ dhisPaging_selectedList_dblclick("indicatorsSelectedList", "availableIndicatorsList", "removeIndicators");
+ });
removeDataElementsList = getRemoveDataElementsList();
removeIndicatorsList = getRemoveIndicatorsList();
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataSet.js 2011-05-23 13:05:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataSet.js 2011-05-23 13:51:02 +0000
@@ -1,113 +1,4 @@
-// --------------------------------------------------------------------------------------------------------------------
-// Methods for moving between two selection boxes
-// --------------------------------------------------------------------------------------------------------------------
-var jqDataElementsSelectedList, jqIndicatorsSelectedList;
-
-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 && settings.removeDataElements.length > 0) {
- settings.params.removeDataElements = settings.removeDataElements.join(",");
- } else {
- delete settings.removeDataElements;
- delete settings.params.removeDataElements;
- }
-
- 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];
- }
- });
-
- if(settings.removeDataElements && settings.removeDataElements.length > 0) {
- settings.params.removeDataElements = settings.removeDataElements.join(",");
- } else {
- delete settings.removeDataElements;
- delete settings.params.removeDataElements;
- }
-
- 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 && 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");
-}
-
// -----------------------------------------------------------------------------
// DataSet details form
// -----------------------------------------------------------------------------