portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r887897 - /portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Date Mon, 07 Dec 2009 12:03:31 GMT
Author: woonsan
Date: Mon Dec  7 12:03:31 2009
New Revision: 887897

URL: http://svn.apache.org/viewvc?rev=887897&view=rev
Log:
JS2-1057: replacing json target url by new jax-rs service url.
removes empty img src url.

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp?rev=887897&r1=887896&r2=887897&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Mon Dec  7 12:03:31 2009
@@ -50,15 +50,15 @@
     </tr>
 </table>
 
+<form id="<portlet:namespace/>form">
 <table id="<portlet:namespace/>portletsTab" style="display: none; border-collapse:
collapse;  width: 100%; margin-top: 0px; margin-bottom: 0px; float: left;">
-    <form onsubmit="return false;">
     <tr>
         <th class="portlet-section-header" colspan="10">Portlets</th>
     </tr>
     <tr>
         <td class="portlet-section-subheader" colspan='10'>
-            <input id="<portlet:namespace/>query" type="text" name="filter" size="15"
value="" >
-            <input id="<portlet:namespace/>search" type="button" value="Search"
/>
+            <input type="text" name="query" size="15" value="" >
+            <input type="submit" value="Search" />
         </td>
     </tr>
     
@@ -82,14 +82,14 @@
     <tr>
         <th class="portlet-section-header" colspan="2"></th>
     </tr>
-    </form>
 </table>
+</form>
 
 <div id="<portlet:namespace/>portletItemTemplate" style="display: none">
     <table style="border-collapse: collapse; width: 100%; margin-top: 0px; margin-bottom:
0px; float: left;">
 	    <tr>
 	        <td rowspan="2" width="20%" class="portlet-section-body">
-	            <img src='${portalContextPath}' />
+	            <img/>
 	        </td>
 	        <td width="80%" class="portlet-section-body">
 	            <div>#</span>
@@ -168,7 +168,7 @@
 </table>
 
 <script language="javascript">
-YUI().use('io', 'dataschema-json', 'node-base', 'cookie', function(Y) {
+YUI().use('io', 'json', 'node-base', 'cookie', function(Y) {
 
     function switchTab(e) {
         var tabId = ('string' == typeof(e) ? e : e.target.get("id"));
@@ -203,23 +203,13 @@
     var onLoadPortletComplete = function(id, o, args) { 
         var id = id; // Transaction ID. 
         var data = o.responseText; // Response data.
-        var schemaPortletList = {
-            metaFields: {status:"status", action:"action"},
-            resultListLocator: "portlets", 
-            resultFields: [{key:"name"}, {key:"displayName"}, {key:"description"}, {key:"image"}]
-        };
-
         var dataOut = null;
 
         try {
-            dataOut = Y.DataSchema.JSON.apply(schemaPortletList, data);
-            // TODO: error handling
+            dataOut = Y.JSON.parse(data);
             if (!dataOut) {
                 Y.log("Error: no data found.");
                 return;
-            } else if (dataOut.error) {
-                Y.log("Error: " + dataOut.error);
-                return;
             }
         } catch (e) {
             Y.log("Error: " + e.message);
@@ -232,27 +222,49 @@
         portletsPanel = clonedPortletsPanel;
         
         var templatePanel = Y.Node.one("#<portlet:namespace/>portletItemTemplate");
-        var results = dataOut.results;
-        for (var i = 0; i < results.length; i++) {
-            var item = results[i];
+        var defs = [];
+        if (dataOut.definitions.definition) {
+            if (dataOut.definitions.definition instanceof Array) {
+                defs = dataOut.definitions.definition;
+            } else {
+                defs.push(dataOut.definitions.definition);
+            }
+        }
+        for (var i = 0; i < defs.length; i++) {
+            var def = defs[i];
             var clone = templatePanel.cloneNode(true);
             clone.setStyle('display', '');
             var imgNode = clone.one('img');
-            var url = imgNode.get('src');
-            var imgURL = url + "/" + item.image;
-            imgNode.set('src', imgURL);
-            var nameNode = clone.one('div');
-            nameNode.setContent(item.displayName);
+            if (def.portletIcon) {
+                imgNode.set("src", "${portalContextPath}/images/portlets/" + def.portletIcon);
+            } else {
+                imgNode.set("src", "${portalContextPath}/images/portlets/applications-other.png");
+            }
             
-            <c:if test="${editAccess}">
-                var actionURL = "<portlet:actionURL/>";
-                var addActionURL = actionURL + (actionURL.indexOf('?') == -1 ? "?portletAdd="
: "&portletAdd=") + item.name;
-                clone.all("a").item(1).set("href", addActionURL);
-            </c:if>
+            var nameNode = clone.one('div');
+
+            if (def.displayNames.displayName) {
+                if (def.displayNames.displayName instanceof Array) {
+                    nameNode.setContent(def.displayNames.displayName[0].value);
+                } else {
+                    nameNode.setContent(def.displayNames.displayName.value);
+                }
+            }
+
+            <c:choose>
+	            <c:when test="${editAccess}">
+	                var actionURL = "<portlet:actionURL/>";
+	                var addActionURL = actionURL + (actionURL.indexOf('?') == -1 ? "?portletAdd="
: "&portletAdd=") + def.uniqueName;
+	                clone.all("a").item(1).set("href", addActionURL);
+	            </c:when>
+	            <c:otherwise>
+	                clone.all("a").item(1).remove();
+	            </c:otherwise>
+	        </c:choose>
             
             // TODO: add handlers for preview
             
-            clone.set("id", "<portlet:namespace/>portletItem-" + item.name);
+            clone.set("id", "<portlet:namespace/>portletItem-" + def.uniqueName);
             
             portletsPanel.appendChild(clone);
         }
@@ -268,23 +280,26 @@
             return;
         }
         Y.Cookie.set("toolboxcat", category);
-        var uri = "${portalContextPath}/ajaxapi/?action=getportlets&format=json";
-        uri += "&filter=" + category;
+        var uri = "${portalContextPath}/services/portletregistry/definition/?_type=json";
+        uri += "&query=" + category;
         Y.on('io:complete', onLoadPortletComplete, this, []); 
         var request = Y.io(uri);
-        Y.Node.one("#<portlet:namespace/>query").set("value", "");
+        Y.Node.getDOMNode(Y.Node.one("#<portlet:namespace/>form")).query.value = "";
     }
     
     var loadPortletsByQuery = function(e) {
-        var query = Y.Node.one("#<portlet:namespace/>query").get("value");
-        var uri = "${portalContextPath}/ajaxapi/?action=getportlets&format=json";
+        var form = Y.Node.getDOMNode(e.target);
+        var query = form.query.value;
+        var uri = "${portalContextPath}/services/portletregistry/definition/?_type=json";
         if (query) {
-            uri += "&filter=" + query;
+            uri += "&query=" + query;
         }
         Y.on('io:complete', onLoadPortletComplete, this, []); 
         var request = Y.io(uri);
         
         Y.Node.getDOMNode(Y.Node.one("#<portlet:namespace/>categories")).selectedIndex
= 0;
+
+        e.halt();
     };
     
     Y.on("click", switchTab, "#<portlet:namespace/>portletsTabAction");
@@ -292,8 +307,8 @@
     Y.on("click", switchTab, "#<portlet:namespace/>themesTabAction");
     Y.on("click", switchTab, "#<portlet:namespace/>widgetsTabAction");
     Y.on("change", loadPortletsInCategory, "#<portlet:namespace/>categories");
-    Y.on("click", loadPortletsByQuery, "#<portlet:namespace/>search");
-
+    Y.on("submit", loadPortletsByQuery, "#<portlet:namespace/>form");
+    
     var tabId = Y.Cookie.get("toolboxtab");
     if (!tabId) {
         tabId = "<portlet:namespace/>portletsTabAction";



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message