dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #00462
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 140: dhis-web-commons-resources: Fixed bug #352324. Sort order now works properly.
------------------------------------------------------------
revno: 140
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-03-31 22:02:45 +0200
message:
dhis-web-commons-resources: Fixed bug #352324. Sort order now works properly.
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/lists.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortDataElementForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortIndicatorForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/lists.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/lists.js 2009-03-07 13:10:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/lists.js 2009-03-31 20:02:45 +0000
@@ -217,12 +217,12 @@
{
if ( list.options[ i ].selected )
{
- if ( i > 0 )
+ if ( i > 0 ) // Cannot move up the option at the top
{
var precedingOption = new Option( list.options[ i - 1 ].text, list.options[ i - 1 ].value );
var currentOption = new Option( list.options[ i ].text, list.options[ i ].value );
- list.options[ i - 1 ] = currentOption;
+ list.options[ i - 1 ] = currentOption; // Swapping place in the list
list.options[ i - 1 ].selected = true;
list.options[ i ] = precedingOption;
}
@@ -243,12 +243,12 @@
{
if ( list.options[ i ].selected )
{
- if ( i <= list.options.length - 1 )
+ if ( i <= list.options.length - 1 ) // Cannot move down the option at the bottom
{
var subsequentOption = new Option( list.options[ i + 1 ].text, list.options[ i + 1 ].value );
var currentOption = new Option( list.options[ i ].text, list.options[ i ].value );
- list.options[ i + 1 ] = currentOption;
+ list.options[ i + 1 ] = currentOption; // Swapping place in the list
list.options[ i + 1 ].selected = true;
list.options[ i ] = subsequentOption;
}
@@ -257,7 +257,7 @@
}
/**
- * Moves the selected option to the top of the list.
+ * Moves the selected options to the top of the list.
*
* @param listId the id of the list.
*/
@@ -265,51 +265,73 @@
{
var list = document.getElementById( listId );
- var moveOption = null;
+ var listLength = list.options.length;
+
+ // Copy selected options to holding list and remove from main list
+
+ var moveOptions = [];
+
+ for ( var i = listLength - 1; i >= 0; i-- )
+ {
+ if ( list.options[ i ].selected )
+ {
+ moveOptions.unshift( new Option( list.options[ i ].text, list.options[ i ].value ) );
+ list.remove( i );
+ }
+ }
+
+ // Move options in main list down a number of positions equal to selected options
+
+ list.options.length = listLength;
+
+ for ( var j = listLength - moveOptions.length - 1; j >= 0; j-- )
+ {
+ var moveOption = new Option( list.options[ j ].text, list.options[ j ].value );
+
+ list.options[ j + moveOptions.length ] = moveOption;
+ }
+
+ // Insert options in holding list at the top of main list
+
+ for ( var k = 0; k < moveOptions.length; k++ )
+ {
+ list.options[ k ] = moveOptions[ k ];
+ list.options[ k ].selected = true;
+ }
+}
+
+/**
+ * Moves the selected options to the bottom of the list.
+ *
+ * @param listId the id of the list.
+ */
+function moveSelectedOptionToBottom( listId )
+{
+ var list = document.getElementById( listId );
+
+ // Copy selected options to holding list and remove from main list
+
+ var moveOptions = [];
+
for ( var i = list.options.length - 1; i >= 0; i-- )
{
if ( list.options[ i ].selected )
{
- moveOption = new Option( list.options[ i ].text, list.options[ i ].value );
+ moveOptions.unshift( new Option( list.options[ i ].text, list.options[ i ].value ) );
+
+ list.remove( i );
}
+ }
+
+ // Insert options in holding list to the end of main list
+
+ for ( var j = 0; j < moveOptions.length; j++ )
+ {
+ list.add( moveOptions[ j ], null );
- if ( moveOption != null && i > 0 )
- {
- var nextOption = new Option( list.options[ i - 1 ].text, list.options[ i - 1 ].value );
- list.options[ i ] = nextOption;
- }
- }
-
- list.options[ 0 ] = moveOption;
-}
-
-/**
- * Moves the selected option to the bottom of the list.
- *
- * @param listId the id of the list.
- */
-function moveSelectedOptionToBottom( listId )
-{
- var list = document.getElementById( listId );
-
- var moveOption = null;
-
- for ( var i = 0; i < list.options.length; i++ )
- {
- if ( list.options[ i ].selected )
- {
- moveOption = new Option( list.options[ i ].text, list.options[ i ].value );
- }
-
- if ( moveOption != null && i < ( list.options.length - 1 ) )
- {
- var nextOption = new Option( list.options[ i + 1 ].text, list.options[ i + 1 ].value );
- list.options[ i ] = nextOption;
- }
- }
-
- list.options[ list.options.length - 1 ] = moveOption;
+ list.options[ list.options.length - 1 ].selected = true;
+ }
}
/**
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortDataElementForm.vm 2009-03-14 07:45:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortDataElementForm.vm 2009-03-31 20:02:45 +0000
@@ -11,7 +11,7 @@
</p>
<p>
-<select id="dataElements" name="dataElements" size="25" style="width:680px">
+<select multiple id="dataElements" name="dataElements" size="25" style="width:680px">
#foreach ( $element in $dataElements )
<option value="$element.id">$element.name</option>
#end
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortIndicatorForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortIndicatorForm.vm 2009-03-14 07:45:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/sortIndicatorForm.vm 2009-03-31 20:02:45 +0000
@@ -11,7 +11,7 @@
</p>
<p>
-<select id="indicators" name="indicators" size="25" style="width:680px">
+<select multiple id="indicators" name="indicators" size="25" style="width:680px">
#foreach ( $indicator in $indicators )
<option value="$indicator.id">$indicator.name</option>
#end
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm 2009-03-14 07:45:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/sortDataSetForm.vm 2009-03-31 20:02:45 +0000
@@ -11,7 +11,7 @@
</p>
<p>
-<select id="dataSets" name="dataSets" size="25" style="width:680px">
+<select multiple id="dataSets" name="dataSets" size="25" style="width:680px">
#foreach ( $dataSet in $dataSets )
<option value="$dataSet.id">$dataSet.name</option>
#end
--
Trunk
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.