Author: michiel
Date: 2010-07-05 18:55:21 +0200 (Mon, 05 Jul 2010)
New Revision: 42802

Modified:
   
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
   
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
   
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/node.tr.jspx
   
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
Log:
support for aliases attribute. Making more use of live events to make it easier 
useable

Modified: 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
===================================================================
--- 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
        2010-07-05 15:37:30 UTC (rev 42801)
+++ 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
        2010-07-05 16:55:21 UTC (rev 42802)
@@ -28,7 +28,7 @@
 
 $(document).ready(
     function() {
-        List.prototype.init(document, false);
+        List.prototype.init(document);
 
         // we allow mm-sr:search to be used for your own implementation of 
searcher.
         // This arranges the version arranged by mm-sr:relatednodes itself
@@ -277,16 +277,7 @@
 /**
  * Initializes every div.list in the given element to be a List
  */
-List.prototype.init = function(el, initSearchers) {
-    if (typeof initSearchers == "undefined" || initSearchers) {
-        if (typeof MMBaseRelater == "function") {
-            $(el).find("div.mm_related").each(function() {
-                    if (this.relater == null) {
-                        this.relater = new MMBaseRelater(this);
-                    }
-                });
-        }
-    }
+List.prototype.init = function(el) {
 
     var l = List; // hoping to make IE a bit faster
     $(el).find("div.list").each(function() {

Modified: 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
===================================================================
--- 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
    2010-07-05 15:37:30 UTC (rev 42801)
+++ 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
    2010-07-05 16:55:21 UTC (rev 42802)
@@ -28,11 +28,16 @@
 
 $(document).ready(
     function(){
-        $("body").find("div.mm_related").each(
-            function() {
-                if (this.relater == null) {
+        $("div.mm_related").live(
+           "click",
+           function(ev) {
+               if (this.relater == null) {
                     this.relater = new MMBaseRelater(this);
-                }
+                   $(ev.target).click();
+                   return false;
+                } else {
+                   return true;
+               }
             });
 
        /*
@@ -139,6 +144,8 @@
 
     if (this.current != null) {
         this.addSearcher(this.current, "current");
+       console.log($(this.div).find("div.settings 
span.currentMaxNumber").val());
+       //        if (relater.current != null) { 
this.relater.current.searcher.maxNumber = ${current.maxNumber}; }
     } else {
         this.logger.debug("No current rep found");
     }
@@ -174,6 +181,23 @@
         );
     }
 
+
+    $(d).find("div.settings span.transactioname").each(
+       function() {
+            this.transaction = this.nodeValue;
+       });
+    $(d).find("div.settings span.fields").each(
+       function() {
+           this.fields = this.nodeValue;
+       });
+    this.setAliases($(d).find("div.settings span.aliases").html() || false);
+    this.setFields($(d).find("div.settings span.fields").html());
+    this.setCustomizedir($(d).find("div.settings span.customizedir").html());
+    this.setPageSize($(d).find("div.settings span.pagesize").html());
+    this.setMaxPages($(d).find("div.settings span.maxpages").html());
+    this.setContext($(d).find("div.settings span.context").html());
+
+
     $(this.div).trigger("mmsrRelaterReady", [self]);
 
 }
@@ -643,57 +667,77 @@
  * Set mmbase context for new objects
  */
 MMBaseRelater.prototype.setContext = function(context) {
-    if (this.current != null) {
-        this.current.searcher.context = context;
+    if (context != null) {
+       if (this.current != null) {
+            this.current.searcher.context = context;
+       }
+       if (this.repository != null) {
+            this.repository.searcher.context = context;
+       }
     }
-    if (this.repository != null) {
-        this.repository.searcher.context = context;
-    }
 };
 
 MMBaseRelater.prototype.setSessionName = function(sessionName) {
-    if (this.current != null) {
-        this.current.searcher.sessionName = sessionName;
+    if (sessionName != null) {
+       if (this.current != null) {
+            this.current.searcher.sessionName = sessionName;
+       }
+       if (this.repository != null) {
+            this.repository.searcher.sessionName = sessionName;
+       }
     }
-    if (this.repository != null) {
-        this.repository.searcher.sessionName = sessionName;
-    }
 };
 
 MMBaseRelater.prototype.setFields = function(fields) {
+    if (fields != null) {
+       if (this.current != null) {
+            this.current.searcher.setFields(fields);
+       }
+       if (this.repository != null) {
+            this.repository.searcher.setFields(fields);
+       }
+    }
+};
+MMBaseRelater.prototype.setAliases = function(a) {
     if (this.current != null) {
-        this.current.searcher.setFields(fields);
+        this.current.searcher.setAliases(a);
     }
     if (this.repository != null) {
-        this.repository.searcher.setFields(fields);
+        this.repository.searcher.setAliases(a);
     }
-}
+};
 
 MMBaseRelater.prototype.setCustomizedir = function(customizedir) {
-    if (this.current != null) {
-        this.current.searcher.setCustomizedir(customizedir);
+    if (customizedir != null) {
+       if (this.current != null) {
+            this.current.searcher.setCustomizedir(customizedir);
+       }
+       if (this.repository != null) {
+            this.repository.searcher.setCustomizedir(customizedir);
+       }
     }
-    if (this.repository != null) {
-        this.repository.searcher.setCustomizedir(customizedir);
-    }
 };
 
 MMBaseRelater.prototype.setPageSize = function(pagesize) {
-    if (this.current != null) {
-        this.current.searcher.setPageSize(pagesize);
+    if (pagesize != null) {
+       if (this.current != null) {
+            this.current.searcher.setPageSize(pagesize);
+       }
+       if (this.repository != null) {
+            this.repository.searcher.setPageSize(pagesize);
+       }
     }
-    if (this.repository != null) {
-        this.repository.searcher.setPageSize(pagesize);
-    }
 };
 
 MMBaseRelater.prototype.setMaxPages = function(maxpages) {
-    if (this.current != null) {
-        this.current.searcher.maxpages = maxpages;
+    if (maxpages != null) {
+       if (this.current != null) {
+            this.current.searcher.maxpages = maxpages;
+       }
+       if (this.repository != null) {
+            this.repository.searcher.maxpages = maxpages;
+       }
     }
-    if (this.repository != null) {
-        this.repository.searcher.maxpages = maxpages;
-    }
 };
 
 /**
@@ -709,6 +753,7 @@
     this.relater = r;
     this.type    = type;
     this.fields = "";
+    this.aliases = false;
     this.customizedir = "";
     this.pagesize = 10;
     this.maxpages = 20;
@@ -718,9 +763,7 @@
     this.transaction   = null;
     this.canEditrelations = $(r.div).hasClass("can_editrelations");
     var self = this;
-    $(d).find("span.transactioname").each(function() {
-        this.transaction = this.nodeValue;
-    });
+
     this.searchResults = {};
     this.bindEvents();
     // Arrange that pressing enter in the search-area works:
@@ -753,6 +796,10 @@
 MMBaseSearcher.prototype.setFields = function(fields) {
     this.fields = fields;
 };
+MMBaseSearcher.prototype.setAliases = function(aliases) {
+    this.aliases = aliases;
+    console.log(this.aliases);
+};
 
 MMBaseSearcher.prototype.setPageSize = function(pagesize) {
     this.pagesize = pagesize;
@@ -812,12 +859,12 @@
         this.offset = offset;
     }
 
-    var rep = this.getResultDiv();
     var params = {
         id: this.getQueryId(),
         offset: offset,
         search: "" + this.value,
         fields: this.fields,
+        aliases: this.aliases,
         pagesize: this.pagesize,
         maxpages: this.maxpages,
         customizedir: this.customizedir,
@@ -826,6 +873,7 @@
 
     var result = this.searchResults["" + offset];
     this.logger.debug("Searching " + this.searchUrl + " " + params);
+    this.logger.debug(params);
 
     if (result == null) {
         var self = this;

Modified: 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/node.tr.jspx
===================================================================
--- 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/node.tr.jspx
       2010-07-05 15:37:30 UTC (rev 42801)
+++ 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/node.tr.jspx
       2010-07-05 16:55:21 UTC (rev 42802)
@@ -10,14 +10,18 @@
       <mm:import externid="id"     required="true" from="request,parameters" />
       <mm:import externid="node"   required="true" from="request,parameters" />
       <mm:import externid="fields" from="request,parameters" />
+      <mm:import externid="aliases" from="request,parameters" />
       <mm:import externid="editrelations" from="request,parameters" />
       <mm:import externid="customizedir"  from="request,parameters" />
       <mm:import externid="relation"      from="request,parameters" />
-      
+
       <mm:node referid="node">
         <mm:nodeinfo type="nodemanager" id="nodemanager" write="false" />
         <tr class="click ${(! empty status and status.index % 2 eq 0) ? 'even' 
: 'odd'} ${nodemanager}">
           <td class="node number"><mm:field name="number" /></td>
+          <c:if test="${aliases eq 'true'}">
+            <td class="node aliases" scope="col"><mm:aliaslist><mm:write 
/><mm:last inverse="true">, </mm:last></mm:aliaslist></td>
+          </c:if>
           <td class="node relation">
             <mm:compare referid="id" 
regexp="\w*current">${relation}</mm:compare>
           </td>

Modified: 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
===================================================================
--- 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
  2010-07-05 15:37:30 UTC (rev 42801)
+++ 
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
  2010-07-05 16:55:21 UTC (rev 42802)
@@ -24,6 +24,7 @@
       <mm:import externid="customizedir" from="parameters"/>
       <mm:import externid="relations" id="editrelations" from="parameters" />
       <mm:import externid="fields" from="parameters" id="flds" />
+      <mm:import externid="aliases" from="parameters">false</mm:import>
 
       <mm:listnodescontainer id="b" clone="query" jspvar="bq">
         <c:if test="${! empty search}">
@@ -67,6 +68,9 @@
               <c:choose>
                 <c:when test="${!empty flds}">
                   <th class="node number" scope="col">#</th>
+                  <c:if test="${aliases eq 'true'}">
+                    <th class="node aliases" scope="col">alias</th>
+                  </c:if>
                   <th class="node relation" scope="col">rel</th>
                   <th class="node guitype" scope="col"><fmt:message 
key="nodetype" /></th>
                   <mm:fieldlist nodetype="${query.nodeManager.name}" 
fields="$flds" varStatus="field">
@@ -76,6 +80,9 @@
                 </c:when>
                 <c:otherwise>
                   <th class="node number" scope="col">#</th>
+                  <c:if test="${aliases eq 'true'}">
+                    <th class="node aliases" scope="col">alias</th>
+                  </c:if>
                   <th class="node relation" scope="col">rel</th>
                   <th class="node guitype" scope="col"><fmt:message 
key="nodetype"  /></th>
                   <th class="node gui" scope="col"><jsp:text> </jsp:text></th>
@@ -148,7 +155,7 @@
                 </mm:isnotempty>
               </mm:compare>
 
-              <mm:include page="node.tr.jspx" 
attributes="status,_n...@node,customizedir?,f...@fields?,editrelations?,relation?"
 />
+              <mm:include page="node.tr.jspx" 
attributes="status,_n...@node,customizedir?,f...@fields?,editrelations?,relation?,aliases?"
 />
 
               <c:if test="${editrelations == true}">
                 <mm:compare referid="id" regexp="\w*current">

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to