rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zh...@apache.org
Subject svn commit: r1129912 - in /incubator/rave/trunk/rave-portal/src/main: java/org/apache/rave/portal/web/api/rpc/ java/org/apache/rave/portal/web/controller/ webapp/WEB-INF/views/ webapp/css/ webapp/script/
Date Tue, 31 May 2011 20:48:40 GMT
Author: zhguo
Date: Tue May 31 20:48:40 2011
New Revision: 1129912

URL: http://svn.apache.org/viewvc?rev=1129912&view=rev
Log:
RAVE-41: Need to be able to delete widgets from a page
https://issues.apache.org/jira/browse/RAVE-41

RAVE-11: Dynamic and highly customizable front-end engine (skins, pages, tabs, layouts, navigation)
https://issues.apache.org/jira/browse/RAVE-11

- Bug fixes
- Added support for deletion of widgets from page.
- Added UI element for widget maximization (switch to canvas view), but have not implemented
the real functionality.


Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
    incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css
    incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java?rev=1129912&r1=1129911&r2=1129912&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/PageApi.java
Tue May 31 20:48:40 2011
@@ -123,7 +123,7 @@ public class PageApi {
 	 */
 	@ResponseBody
     @RequestMapping(method=RequestMethod.POST, value="{pageId}/widget/delete")	
-    public RpcResult<Region> removeWidgetFromPage(@PathVariable final long widgetId,

+    public RpcResult<Region> removeWidgetFromPage(@RequestParam final long widgetId,

 																  @RequestParam final long regionId) {
 		return new RpcOperation<Region>() {
 			@Override

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java?rev=1129912&r1=1129911&r2=1129912&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
Tue May 31 20:48:40 2011
@@ -23,6 +23,7 @@ import org.apache.rave.portal.model.User
 import org.apache.rave.portal.service.PageService;
 import org.apache.rave.portal.service.UserService;
 import org.apache.rave.portal.web.util.ModelKeys;
+import org.apache.rave.portal.web.util.ViewNames;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -51,6 +52,6 @@ public class HomeController {
         User user = userService.getAuthenticatedUser();
         List<Page> pages = pageService.getAllPages(user.getUserId());
         model.addAttribute(ModelKeys.PAGES, pages);
-        return "home";
+        return ViewNames.HOME;
     }
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp?rev=1129912&r1=1129911&r2=1129912&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp Tue May 31 20:48:40
2011
@@ -37,6 +37,15 @@
     <a href="<spring:url value="/j_spring_security_logout" htmlEscape="true" />">Logout</a>
     <a href="<spring:url value="/app/store?referringPageId=${defaultPage.id}" />">Widget
Store</a>
 </div>
+
+<script src="${opensocial_engine_url}/js/container.js?c=1&container=default&debug=1"
type="text/javascript"></script>
+<script src="<spring:url value="/script/rave.js"/>" type="text/javascript"></script>
+<script src="<spring:url value="/script/rave_api.js"/>" type="text/javascript"></script>
+<script src="<spring:url value="/script/rave_opensocial.js"/>" type="text/javascript"></script>
+<script src="<spring:url value="/script/rave_wookie.js"/>" type="text/javascript"></script>
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
+<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" type="text/javascript"></script>
+
 <h1>Hello ${defaultPage.owner.username}, welcome to Rave!</h1>
 <script type="text/javascript">
     //Define the global widgets variable
@@ -46,9 +55,47 @@
 <c:forEach var="region" items="${defaultPage.regions}">
 <div class="region" id="region-${region.id}-id" >
     <c:forEach var="regionWidget" items="${region.regionWidgets}">
-    <div class="widget-wrapper">
+    <!-- FIXME: whether region.id should be included in the id. 
+         I am not sure whether id's of widgets in different regions can be the same.
+         If so, region.id must be included. When a gadget is moved, region id must be updated.

+         Otherwise, it is not needed.
+    -->
+    <div class="widget-wrapper" id="widget-wrapper-${region.id}-${regionWidget.id}">
         <div class="widget-title-bar" >
             <span id="widget-${regionWidget.id}-title">${regionWidget.widget.title}</span>
+            
+            <span id="widget-${regionWidget.id}-toolbar" style="float:right;">
+              <button id="widget-${regionWidget.id}-max" class="widget-toolbar-btn"></button>
+						  <button id="widget-${regionWidget.id}-remove" class="widget-toolbar-btn"></button>
+						  <script type="text/javascript">
+              $("#widget-${regionWidget.id}-max").button({
+                text: false,
+                icons: {
+                  primary: "ui-icon-arrow-4-diag"
+                }
+              }).click(function() {
+                alert("not implemented yet.");
+              });
+						  $("#widget-${regionWidget.id}-remove").button({
+					      text: false,
+					      icons: {
+					        primary: "ui-icon-close"
+					      }
+					    }).click(function() {
+					      rave.api.rpc.removeWidget({
+					    	  regionWidgetId: "${regionWidget.id}", 
+					    	  pageId: "${defaultPage.id}",
+					    	  region: {
+					    		  id: "region-${region.id}-id"
+					    	  },
+					    	  succCB: function() {
+					    		  $("#widget-wrapper-${region.id}-${regionWidget.id}").remove();
+					    	  }
+					    	});
+					    });
+						  </script>
+						</span>
+            
         </div>
         <div class="widget" id="widget-${regionWidget.id}-body">
 			 <!-- 
@@ -63,14 +110,6 @@
 </c:forEach>
 <div class="clear-float">&nbsp;</div>
 
-<script src="${opensocial_engine_url}/js/container.js?c=1&container=default&debug=1"
type="text/javascript"></script>
-<script src="<spring:url value="/script/rave.js"/>" type="text/javascript"></script>
-<script src="<spring:url value="/script/rave_api.js"/>" type="text/javascript"></script>
-<script src="<spring:url value="/script/rave_opensocial.js"/>" type="text/javascript"></script>
-<script src="<spring:url value="/script/rave_wookie.js"/>" type="text/javascript"></script>
-<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
-<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" type="text/javascript"></script>
-
 <script type="text/javascript">
     $(function(){
         rave.setContext("<spring:url value="/app/" />");

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css?rev=1129912&r1=1129911&r2=1129912&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/css/default.css Tue May 31 20:48:40 2011
@@ -17,6 +17,7 @@
 
 /**
 * This is the same as rave.css used for the website.
+* FIXME: where is rave.css?
 */
 
 body {
@@ -259,4 +260,9 @@ dl {
 dt {
     display: inline;
     float: left;
-}
\ No newline at end of file
+}
+
+button.widget-toolbar-btn {
+	width: 1em;
+}
+	
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js?rev=1129912&r1=1129911&r2=1129912&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/script/rave_api.js Tue May 31 20:48:40
2011
@@ -23,10 +23,10 @@ var rave = rave || {};
  */
 rave.api = rave.api || (function() {
     var rpcApi = (function() {
-		  //Base path to RPC services
+      //Base path to RPC services
         var path = "api/rpc/";
 
-		  //This method is implemented by PageApi.java.  
+      //This method is implemented by PageApi.java.  
         function moveWidgetOnPage(args) {
             //Note context must be set outside this library.  See home.jsp for example.
             $.post(rave.getContext() + path + "page/regionWidget/" + rave.getObjectIdFromDomId(args.widget.id)
+ "/move",
@@ -55,18 +55,21 @@ rave.api = rave.api || (function() {
                     }).error(handleError);
         }
 
-		  function deleteWidgetOnPage(args) {
-				$.post(rave.getContext() + path + "page/" +args.pageId + "/widget/delete",
-						 {
-							  widgetId: args.regionWidgetId,
-                       regionId: rave.getObjectIdFromDomId(args.region.id)						
-						 },
-						 function(result) {
-							  if(results.error) {
-									handleRpcError(result);
-							  }
-						 }).error(handleError);
-		  }
+      function deleteWidgetOnPage(args) {
+        $.post(rave.getContext() + path + "page/" +args.pageId + "/widget/delete",
+             {
+                widgetId: args.regionWidgetId,
+                regionId: rave.getObjectIdFromDomId(args.region.id)            
+             },
+             function(result) {
+                if(result.error && result.error == true) {
+                  handleRpcError(result);
+                } else {
+                	if (args.succCB != null && typeof args.succCB == 'function')
+                		args.succCB();
+                }
+             }).error(handleError);
+      }
 
         function handleError(jqXhr, status, error) {
             alert("Rave encountered an error while trying to contact the server.  Please
reload the page and try again. error: " + error);
@@ -92,8 +95,8 @@ rave.api = rave.api || (function() {
         return {
             moveWidget : moveWidgetOnPage,
             addWidgetToPage : addWidgetToPage,
-				removeWidget : deleteWidgetOnPage
-        }
+      removeWidget : deleteWidgetOnPage
+        };
 
     })();
 



Mime
View raw message