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

Modified Files:
        Searcher.js.jsp 
Log Message:
support for maxnumber (maxnumber of current query is used)


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.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- Searcher.js.jsp     23 Apr 2008 07:24:53 -0000      1.18
+++ Searcher.js.jsp     24 Apr 2008 14:40:10 -0000      1.19
@@ -11,7 +11,7 @@
 
  *
  * @author Michiel Meeuwissen
- * @version $Id: Searcher.js.jsp,v 1.18 2008/04/23 07:24:53 michiel Exp $
+ * @version $Id: Searcher.js.jsp,v 1.19 2008/04/24 14:40:10 michiel Exp $
  */
 
 $(document).ready(function(){
@@ -120,8 +120,8 @@
                return this.searcher.create(anchor);
            });
        });
-       if (this.canUnrelate) {
-           $(el).find("tr.click").each(function() {
+       if (this.canUnrelate && this.current) {
+           $(this.current).find("tr.click").each(function() {
                $(this).click(function(tr) {
                    relater.unrelate(this);
                    return false;
@@ -232,16 +232,21 @@
  */
 MMBaseRelater.prototype.relate = function(tr) {
     var number = this.getNumber(tr);
-
+    this.logger.debug("Found number to relate " + number + "+" + 
this.getNumbers(this.related));
+    // Set up HTML
+    if (this.current != null) {
+       if (this.current.searcher.maxNumber > 0 && 
(this.current.searcher.totalSize() + 1) > this.current.searcher.maxNumber) {
+           return alert("Can only relate maximally " + 
this.current.searcher.maxNumber);
+       }
     // Set up data
     if (typeof(this.unrelated[number]) == "undefined") {
        this.related[number] = tr;
     }
-    this.logger.debug("Found number to relate " + number + "+" + 
this.getNumbers(this.related));
+
     this.unrelated[number] = null;
 
-    // Set up HTML
-    if (this.current != null) {
+
+
        var currentList =  $(this.current).find("div.searchresult table tbody");
        this.logger.debug(currentList[0]);
        currentList.append(tr);
@@ -277,6 +282,8 @@
  */
 MMBaseRelater.prototype.unrelate = function(tr) {
     var number = this.getNumber(tr);
+    this.logger.debug("Unrelating " + number);
+
 
     // Set up data
     if (typeof(this.related[number]) == "undefined") {
@@ -365,6 +372,7 @@
     this.totalsize = -1;
     this.last = -1;
     this.logger.debug("found " + this.searchUrl);
+    this.maxNumber = -1;
 
 }
 
@@ -443,10 +451,10 @@
     var span = $(this.div).find("caption span.size")[0];
     if (size == null) {
        if (this.totalsize == -1) {
-           this.totalsize = parseInt(span.textContent);
+           this.totalsize = span == null ? 0 : parseInt(span.textContent);
        }
     } else {
-       span.textContent = size;
+       if (span != null) span.textContent = size;
        this.totalsize = size;
     }
     return this.totalsize;
@@ -454,6 +462,7 @@
 
 MMBaseSearcher.prototype.lastIndex = function(size) {
     var span = $(this.div).find("caption span.last")[0];
+    if (span == null) return;
     if (size == null) {
        if (this.last == -1) {
            this.last = parseInt(span.textContent);
@@ -466,10 +475,12 @@
 }
 
 MMBaseSearcher.prototype.inc = function() {
+    this.logger.debug("inc");
     this.totalSize(1 + this.totalSize());
     this.lastIndex(1 + this.lastIndex());
 }
 MMBaseSearcher.prototype.dec = function() {
+    this.logger.debug("dec");
     this.totalSize(-1 + this.totalSize());
     this.lastIndex(-1 + this.lastIndex());
 }
@@ -496,7 +507,7 @@
                        url: "${mm:link('/mmbase/searchrelate/create.jspx')}",
                        target:     null,
                        success:    function(subres, substatus) {
-                           self.logger.debug(substatus);
+                           self.logger.debug(substatus + ": " + subres);
                            var newNode = 
$(subres).find("span.newnode")[0].firstChild.nodeValue;
                            self.logger.debug(newNode);
                            var tr = self.getTr(newNode);
@@ -528,6 +539,7 @@
 
 
 MMBaseSearcher.prototype.deleteNewlyRemoved = function(rep) {
+    this.logger.debug("Deleting newly removed");
     var self = this;
     var deleted = false;
     if (this.relater != null && this.type == "repository") {
@@ -582,6 +594,7 @@
 }
 
 MMBaseSearcher.prototype.resetTrClasses = function() {
+    this.logger.debug("Resetting tr's");
     var i = 0;
     $(this.div).find("div.searchresult table tbody tr").each(function() {
        $(this).removeClass("odd");
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to