Update of /var/cvs/applications/searchrelate/templates
In directory james.mmbase.org:/tmp/cvs-serv18482

Modified Files:
        Searcher.js.jsp create.jspx node.tr.jspx page.jspx 
Log Message:
various details


See also: http://cvs.mmbase.org/viewcvs/applications/searchrelate/templates


Index: Searcher.js.jsp
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/Searcher.js.jsp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- Searcher.js.jsp     21 Apr 2008 12:21:44 -0000      1.14
+++ Searcher.js.jsp     21 Apr 2008 17:40:32 -0000      1.15
@@ -11,7 +11,7 @@
 
  *
  * @author Michiel Meeuwissen
- * @version $Id: Searcher.js.jsp,v 1.14 2008/04/21 12:21:44 michiel Exp $
+ * @version $Id: Searcher.js.jsp,v 1.15 2008/04/21 17:40:32 michiel Exp $
  */
 
 $(document).ready(function(){
@@ -156,7 +156,7 @@
            params.transaction = this.transaction;
        }
        var self = this;
-       $.ajax({async: false, url: url, type: "GET", dataType: "xml", data: 
params,
+       $.ajax({url: url, type: "GET", dataType: "xml", data: params,
                complete: function(res, status){
                    $(a).removeClass("submitting");
                    if (status == "success") {
@@ -233,7 +233,6 @@
 MMBaseRelater.prototype.relate = function(tr) {
     var number = this.getNumber(tr);
 
-
     // Set up data
     if (typeof(this.unrelated[number]) == "undefined") {
        this.related[number] = tr;
@@ -247,6 +246,9 @@
        this.logger.debug(currentList[0]);
        currentList.append(tr);
 
+       this.current.searcher.inc();
+       this.repository.searcher.dec();
+
        // Classes
        if ($(tr).hasClass("removed")) {
            $(tr).removeClass("removed");
@@ -286,6 +288,9 @@
     var repository =  $(this.div).find("div.mm_relate_repository 
div.searchresult table tbody");
     repository.append(tr);
 
+    this.current.searcher.dec();
+    this.repository.searcher.inc();
+
     // Classes
     if ($(tr).hasClass("new")) {
        $(tr).removeClass("new");
@@ -302,6 +307,36 @@
     });
 }
 
+/**
+ * Set mmbase context for new objects
+ */
+MMBaseRelater.prototype.setContext = function(context) {
+    if (this.current != null) {
+       this.current.searcher.context = context;
+    }
+    if (this.repository != null) {
+       this.repository.searcher.context = context;
+    }
+}
+
+MMBaseRelater.prototype.setPageSize = function(pagesize) {
+    if (this.current != null) {
+       this.current.searcher.pagesize = pagesize;
+    }
+    if (this.repository != null) {
+       this.repository.searcher.pagesize = pagesize;
+    }
+}
+
+MMBaseRelater.prototype.setMaxPages = function(maxpages) {
+    if (this.current != null) {
+       this.current.searcher.maxpages = maxpages;
+    }
+    if (this.repository != null) {
+       this.repository.searcher.maxpages = maxpages;
+    }
+}
+
 /*
  * 
***********************************************************************************************************************
  */
@@ -326,6 +361,9 @@
     this.bindEvents();
     this.validator = this.relater.validator;
     this.searchUrl = $(this.div).find("form.searchform").attr("action");
+    this.context   = "";
+    this.totalsize = -1;
+    this.foundsize = -1;
     this.logger.debug("found " + this.searchUrl);
 
 }
@@ -347,7 +385,7 @@
  * The actual query is supposed to be on the user's session, and will be 
picked up in page.jspx.
  */
 MMBaseSearcher.prototype.search = function(val, offset) {
-    if (val.tagName.toUpperCase() == "FORM") {
+    if (val != null && val.tagName != null && val.tagName.toUpperCase() == 
"FORM") {
        val = $(val).find("input").val();
     } else {
        $(this.div).find("form.searchform input").val(val);
@@ -356,13 +394,15 @@
     if (newSearch != this.value) {
        this.searchResults = {};
        this.value = newSearch;
+       this.totalsize = -1;
     }
     this.offset = offset;
 
-    var rep = this.getResultDiv();
-    var params = {id: this.getQueryId(), offset: offset, search: this.value, 
pagesize: this.pagesize, maxpages: this.maxpages};
+    var rep = this.getResultDiv();    var params = {id: this.getQueryId(), 
offset: offset, search: "" + this.value, pagesize: this.pagesize, maxpages: 
this.maxpages};
 
     var result = this.searchResults["" + offset];
+
+
     $(rep).empty();
     if (result == null) {
        var self = this;
@@ -370,10 +410,10 @@
                complete: function(res, status){
                    if ( status == "success" || status == "notmodified" ) {
                        result = res.responseText;
-                       self.logger.debug(result);
                        $(rep).empty();
+                       //console.log($(result).find("*").length);
                        $(rep).append($(result).find("> *"));
-                       self.searchResults["" + offset] = result;
+                       //self.searchResults["" + offset] = result;
                        self.addNewlyRelated(rep);
                        self.deleteNewlyRemoved(rep);
                        self.bindEvents(rep);
@@ -386,7 +426,7 @@
        this.logger.debug("reusing " + offset);
        this.logger.debug(rep);
        var self = this;
-       $(rep).append($(result).find("> *"));
+       $(rep).append($(result).find("*"));
        this.addNewlyRelated(rep);
        self.deleteNewlyRemoved(rep);
        this.bindEvents(rep);
@@ -394,10 +434,48 @@
     return false;
 }
 
+MMBaseSearcher.prototype.totalSize = function(size) {
+    var span = $(this.div).find("caption span.size")[0];
+    if (size == null) {
+       if (this.totalsize == -1) {
+           this.totalsize = span.textContent;
+       }
+    } else {
+       span.textContent = size;
+       this.totalsize = size;
+    }
+    return this.totalsize;
+}
+
+MMBaseSearcher.prototype.foundSize = function(size) {
+    var span = $(this.div).find("caption span.foundsize")[0];
+    if (size == null) {
+       if (this.foundsize == -1) {
+           this.foundsize = span.textContent;
+       }
+    } else {
+       span.textContent = size;
+       this.foundsize= size;
+    }
+    return this.foundsize;
+}
+
+MMBaseSearcher.prototype.inc = function() {
+    this.totalSize(this.totalSize() + 1);
+    this.foundSize(this.foundSize() + 1);
+}
+MMBaseSearcher.prototype.dec = function() {
+    this.totalSize(this.totalSize() - 1);
+    this.foundSize(this.foundSize() - 1);
+}
+
+
 MMBaseSearcher.prototype.create = function () {
     var rep = this.getResultDiv();
     var url = "${mm:link('/mmbase/searchrelate/create.jspx')}";
-    var params = { queryid: this.getQueryId() };
+    var params = { queryid: this.getQueryId(), context: this.context };
+
+
     var self = this;
     $.ajax({url: url, type: "GET", data: params,
            complete: function(res, status){
@@ -417,8 +495,7 @@
                            var newNode = 
$(subres).find("span.newnode")[0].firstChild.nodeValue;
                            self.logger.debug(newNode);
                            var tr = self.getTr(newNode);
-                           self.relater.relate(tr);
-                           self.search(newNode, self.offset);
+                           self.search(newNode, 0);
                        }
                    };
                    $(rep).find("form.mm_form").ajaxForm(options);


Index: create.jspx
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/create.jspx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- create.jspx 17 Apr 2008 09:18:55 -0000      1.5
+++ create.jspx 21 Apr 2008 17:40:32 -0000      1.6
@@ -10,6 +10,7 @@
     <fmt:bundle basename="org.mmbase.searchrelate.resources.searchrelate">
       <mm:cloud method="asis">
         <mm:import externid="queryid"  />
+        <mm:import externid="context"  />
         <mm:log>Found id ${queryid}</mm:log>
         <mm:import from="session" externid="${queryid}" id="query" 
required="true" />
 
@@ -25,11 +26,15 @@
                   <input type="submit" value="${createmessage}" />
                   <input type="hidden"  name="s" value="submitted" />
                   <input type="hidden" name="queryid" value="${queryid}" />
+                  <input type="hidden" name="context" value="${context}" />
                   <input type="hidden" name="nodemanager" id="nodemanager" 
value="${query.nodeManager.name}" />
                 </td>
               </tr>
             </tfoot>
             <mm:createnode id="newnode" type="${query.nodeManager.name}">
+              <c:if test="${! empty context}">
+                <mm:setcontext>${context}</mm:setcontext>
+              </c:if>
               <tbody>
                 <mm:fieldlist type="create" varStatus="field">
                   <tr class="fields ${field.current.name}">


Index: node.tr.jspx
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/node.tr.jspx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- node.tr.jspx        21 Apr 2008 12:17:11 -0000      1.2
+++ node.tr.jspx        21 Apr 2008 17:40:32 -0000      1.3
@@ -2,14 +2,15 @@
     xmlns:jsp="http://java.sun.com/JSP/Page";
     xmlns:c="http://java.sun.com/jsp/jstl/core";
     xmlns:mm="http://www.mmbase.org/mmbase-taglib-2.0";>
-  <mm:content expires="0">
-    <mm:cloud>
+  <jsp:output omit-xml-declaration="true" />
+  <mm:content expires="0" type="application/xml">
+    <mm:cloud method="asis">
 
       <mm:import externid="status" from="request" />
       <mm:import externid="id"     required="true" from="request,parameters" />
       <mm:import externid="node"     required="true" from="request,parameters" 
/>
       <mm:node referid="node">
-        <tr class="click ${(! empty status and status.index % 2 eq 0) ? 'even' 
: 'odd'}" id="${id}_node_${_node}">
+        <tr class="click ${(! empty status and status.index % 2 eq 0) ? 'even' 
: 'odd'}" >
           <td class="node number">
             <mm:field name="number" />
           </td>


Index: page.jspx
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/page.jspx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- page.jspx   21 Apr 2008 12:32:03 -0000      1.8
+++ page.jspx   21 Apr 2008 17:40:32 -0000      1.9
@@ -9,7 +9,7 @@
       Presents a table with one page of query results. Plus paging to other 
pages (in tfoot).
       Used in ajax-calls, but can also be directly included with mm:include 
(for initial results).
       @todo Searching only happens in actual mmbase queries now. How about 
lucene queries?
-      @version $Id: page.jspx,v 1.8 2008/04/21 12:32:03 michiel Exp $
+      @version $Id: page.jspx,v 1.9 2008/04/21 17:40:32 michiel Exp $
   -->
   <jsp:output omit-xml-declaration="true" />
   <mm:content expires="0" type="application/xml">
@@ -21,7 +21,7 @@
       <mm:import from="session" externid="${id}" id="query" required="true" />
       <mm:import externid="offset" vartype="integer">0</mm:import>
 
-      <mm:listnodescontainer id="b" clone="query">
+      <mm:listnodescontainer id="b" clone="query" jspvar="bq">
         <c:if test="${! empty search}">
           <mm:composite operator="OR">
             <mm:fieldlist container="b" type="search" varStatus="field">
@@ -31,7 +31,6 @@
             </mm:fieldlist>
             <mm:compare regexp="[0-9]+" referid="search">
               <mm:constraint field="number" value="${search}" />
-
             </mm:compare>
           </mm:composite>
         </c:if>
@@ -41,26 +40,21 @@
         <c:choose>
           <c:when test="${size > 0}">
             <fmt:message key="searchresults" var="summary">
-              <c:choose>
-                <c:when test="${size > 0}"><fmt:param value="${offset + 1}" 
/></c:when>
-                <c:otherwise><fmt:param value="0" /></c:otherwise>
-              </c:choose>
-              <c:choose>
-                <c:when test="${pagesize > size}"><fmt:param value="${size}" 
/></c:when>
-                <c:otherwise><fmt:param value="${pagesize}" /></c:otherwise>
-              </c:choose>
-              <fmt:param value="${size}" />
+              <fmt:param value="&lt;span class='offset'&gt;${size > 0 ? offset 
+ 1 : 0}&lt;/span&gt;" />
+              <fmt:param value="&lt;span class='foundsize'&gt;${pagesize > 
size ? size  : pagesize}&lt;/span&gt;" />
+              <fmt:param value="&lt;span class='size'&gt;${size}&lt;/span&gt;" 
/>
              <fmt:param value="${empty search ? '' : search}" />
            </fmt:message>
           </c:when>
           <c:otherwise>
             <fmt:message key="nothingfound" var="summary">
-              <fmt:param value="${search}" />
+              <fmt:param value="${empty search ? '' : search}" />
             </fmt:message>
           </c:otherwise>
         </c:choose>
-        <table summary="${summary}">
+        <table summary="${mm:escape('tagstripper(none)', summary)}">
           <caption class="${empty search ? 'emptysearch' : 
'search'}">${summary}</caption>
+          &lt;!-- <jsp:expression>bq.toSql()</jsp:expression> --&gt;
           <thead>
             <tr>
               <th class="node number">#</th>
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to