← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11573: Dashboard, made it possible to move to end of list

 

------------------------------------------------------------
revno: 11573
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-08-05 17:06:33 +0200
message:
  Dashboard, made it possible to move to end of list
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css


--
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-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2013-08-05 14:35:21 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2013-08-05 15:06:33 +0000
@@ -7,7 +7,7 @@
 dhis2.db.currentShareType;
 dhis2.db.currentShareId;
 
-// TODO drop at end of list
+// TODO proper link hrefs
 
 //------------------------------------------------------------------------------
 // Document ready
@@ -78,22 +78,25 @@
 		over: dhis2.db.dropOver,
 		out: dhis2.db.dropOut
 	} );
-	
+
 	$( ".dropItem" ).droppable( {
 		accept: ".item",
 		drop: dhis2.db.dropItem
 	} );
+	
+	$( ".lastDropItem" ).droppable( {
+		over: dhis2.db.lastDropOver,
+		out: dhis2.db.lastDropOut
+	} );	
 }
 
-dhis2.db.dragStart = function( event, ui ) {	
-	$( this ).css( "opacity", "0.6" );
+dhis2.db.dragStart = function( event, ui ) {
 	$( this ).hide();
 	dhis2.db.currentItem = $( this ).attr( "id" );
 	dhis2.db.currentItemPos = $( this ).data( "position" );
 }
 
 dhis2.db.dragStop = function( event, ui ) {
-	$( this ).css( "opacity", "1.0" );
 	$( this ).show();
 	$( ".dropItem" ).hide();
 	dhis2.db.currentItem = undefined;
@@ -117,6 +120,14 @@
 	$( "#" + dropItemId ).hide();
 }
 
+dhis2.db.lastDropOver = function( event, ui ) {
+	$( this ).removeClass( "lastDropItem" ).show();
+}
+
+dhis2.db.lastDropOut = function( event, ui ) {
+	$( this ).addClass( "lastDropItem" );
+}
+
 dhis2.db.dropItem = function( event, ui ) {
 	var position = parseInt( $( this ).data( "position" ) );
 	position++;
@@ -297,6 +308,8 @@
 					dhis2.db.renderLinkItem( $d, item.id, item.resources, "Resources", position );
 				}
 			} );
+			
+			dhis2.db.renderLastDropItem( $d, parseInt( data.items.length - 1 ) );
 		}
 		else
 		{
@@ -310,8 +323,8 @@
 dhis2.db.renderLinkItem = function( $d, itemId, contents, title, position )
 {
 	var html = 
-		"<li><div class='dropItem' id='drop" + itemId + "' data-position='" + position + "'></div>" +
-		"<div class='item' id='" + itemId + "' data-position='" + position + "'><div class='itemHeader'><a href='javascript:dhis2.db.removeItem( \"" + itemId + "\" )'>Remove</a></div>" +
+		"<li><div class='dropItem' id='drop" + itemId + "' data-position='" + position + "'></div></li>" +
+		"<li><div class='item' id='" + itemId + "' data-position='" + position + "'><div class='itemHeader'><a href='javascript:dhis2.db.removeItem( \"" + itemId + "\" )'>Remove</a></div>" +
 		"<ul class='itemList'><li class='itemTitle' title='Drag to new position'>" + title + "</li>";
 	
 	$.each( contents, function( index, content )
@@ -326,6 +339,13 @@
 	$d.append( html );
 }
 
+dhis2.db.renderLastDropItem = function( $d, position )
+{
+	var html = "<li><div class='dropItem lastDropItem' id='dropLast' data-position='" + position + "'></div></li>";
+	
+	$d.append( html );
+}
+
 dhis2.db.moveItem = function( id, position ) {
 	var url = "../api/dashboards/" + dhis2.db.current + "/items/" + id + "/position/" + position;
 	

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css	2013-07-26 09:01:07 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css	2013-08-05 15:06:33 +0000
@@ -99,6 +99,18 @@
   display: none;
 }
 
+.lastDropItem
+{
+  width: 405px;
+  height: 328px;
+  padding: 6px;
+  margin: 0 19px 19px 0;
+  border: 1px solid #fff;
+  background-color: #fff;
+  border-radius: 3px;
+  display: block;
+}
+
 .itemHeader
 {
   margin: 0 0 10px 0;