Author: andre
Date: 2010-02-12 12:01:31 +0100 (Fri, 12 Feb 2010)
New Revision: 40981

Modified:
   
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
   
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
   
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
Log:
porting from 1.9 (MMB-1933)

Modified: 
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
===================================================================
--- 
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
 2010-02-12 10:55:05 UTC (rev 40980)
+++ 
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
 2010-02-12 11:01:31 UTC (rev 40981)
@@ -23,8 +23,11 @@
                            description="An mmbase Query describing which list 
is considered to represent already 'related' nodes" />
 
   <jsp:directive.attribute name="submit"            type="java.lang.String"
-                           description="A jquery selector. The 'commit' action 
will be binded to the 'onclick' of the elements that match"  />
+                           description="A jquery selector. The 'commit' action 
will be binded to the 'onclick' of the elements that match."  />
 
+  <jsp:directive.attribute name="instant"           type="java.lang.Boolean"
+                           description="Relating or unrelating should happen 
inmediate after clicking an item or not. Defaults to both relating and 
unrelating true. When false confirmation is needed via submit." />
+
   <jsp:directive.attribute name="unrelate"          type="java.lang.Boolean"
                            description="Whether, or not, the tools should also 
allow deletion of relations" />
 
@@ -37,7 +40,7 @@
   <jsp:directive.attribute name="extracreate"           type="java.lang.String"
                            description="Jsp to be included in after the field 
list in the create jsp." />
 
-  <jsp:directive.attribute name="transaction "       type="java.lang.String"
+  <jsp:directive.attribute name="transaction"        type="java.lang.String"
                            description="The name of the mmbase transaction to 
be used" />
 
   <jsp:directive.attribute name="pagesize"           type="java.lang.Integer"
@@ -55,18 +58,15 @@
   <jsp:directive.attribute name="context"
                            description="The MMBase security context for new 
nodes (defaults to unset, which will normally result in nodes in the default 
context of the current user)" />
 
-
   <jsp:directive.attribute name="currentTitle"        fragment="true"
                            description="A piece of HTML that will be presented 
first in the 'current' div"/>
 
   <jsp:directive.attribute name="repositoryTitle"     fragment="true"
                            description="A piece of HTML that will be presented 
first in the 'repository' div"/>
 
-
   <jsp:directive.attribute name="forms"               type="java.lang.Boolean"
                            description="Whether to produce forms. Default to 
true, but since forms cannot be nested you may want to set this to false."/>
 
-
   <jsp:directive.attribute name="customizedir"        type="java.lang.String"
                            description="Enables the specification of the 
location of a directory with extra actions on nodes in the lists which will 
become visible in the td.action." />
 
@@ -114,8 +114,8 @@
   <script type="text/javascript">
     $(document).ready(function() {
     <c:if test="${! empty submit}">
-      <!-- if a submit id is given, commit the search/relate on click of that 
element -->
-         $("${submit}").click(function(el) {
+      <!-- if a submit attribute is given, commit the search/relate on click 
of that element -->
+         $("#mm_related_${sid} ${submit}").click(function(el) {
             return $("#mm_related_${sid}")[0].relater.commit(el); });</c:if>
       $("#mm_related_${sid}").each(function() {
       if (this.relater != null) {
@@ -137,7 +137,7 @@
       xmlns:fmt="http://java.sun.com/jsp/jstl/fmt";
       basename="org.mmbase.searchrelate.resources.searchrelate">
     <div id="mm_related_${sid}"
-         class="mm_related ${empty unrelate or ! unrelate ? '' : 
'can_unrelate'} ${empty relations or ! relations ? '' : 'can_editrelations'}  
${styleClass}">
+         class="mm_related ${empty unrelate or ! unrelate ? '' : 
'can_unrelate'} ${empty relations or ! relations ? '' : 'can_editrelations'} 
${empty instant or instant == true ? 'instant' : ''} ${styleClass}">
       <c:if test="${! empty transaction}">
         <span class="transactionname" style="display: 
none;">${transaction}</span>
       </c:if>

Modified: 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
===================================================================
--- 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
  2010-02-12 10:55:05 UTC (rev 40980)
+++ 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
  2010-02-12 11:01:31 UTC (rev 40981)
@@ -63,6 +63,7 @@
     this.logger.debug(d);
     this.logger.debug("setting up current");
     this.current       = $(d).find(".mm_relate_current")[0];
+    this.instant       = $(d).hasClass("instant");  // instant action
     this.canUnrelate   = $(d).hasClass("can_unrelate");
     this.canEditrelations = $(d).hasClass("can_editrelations");
     if (this.current != null) {
@@ -96,7 +97,7 @@
 
 /**
  *  This Searcher.js.jsp is normally loaded implicetly by the first 
mm-sr:relate. Using the 'ready'
- *  function, you can do something immediately after the MMBaseRealter is 
ready. E.g. you can add a
+ *  function, you can do something immediately after the MMBaseRelater is 
ready. E.g. you can add a
  *  'relateCallBack' function.
  *  @todo I think jquery provides something with user defined events.
  */
@@ -116,6 +117,7 @@
     var relater = this;
     if ($(el).hasClass("searchable")) {
         var searcher =  new MMBaseSearcher(el, this, type, this.logger);
+        // search
         $(el).find("a.search").each(function() {
             var anchor = this;
             anchor.searcher = searcher;
@@ -124,7 +126,7 @@
                     return this.searcher.search(document.getElementById(id), 
0, anchor);
             });
         });
-
+        // search (submit)
         $(this.repository).find("form.searchform").each(function() {
             var form = this;
             form.searcher = searcher;
@@ -132,6 +134,7 @@
                 return this.searcher.search(form, 0);
             });
         });
+        // create
         $(el).find("a.create").each(function() {
             var anchor = this;
             anchor.searcher = searcher;
@@ -139,13 +142,6 @@
                 return this.searcher.create(anchor);
             });
         });
-        if (this.canUnrelate && this.current) {
-            $(this.current).find("tr.click").each(function() {
-                $(this).click(function(tr) {
-                    relater.unrelate(this);
-                    return false;
-                })});
-        }
     }
 }
 
@@ -158,8 +154,8 @@
 
 
 /**
- * Commits made changes to MMBase. Depends on a jsp 
/mmbase/searchrelate/relate.jsp to do the actual work.
- * This jsp, in turn, depends on the query in the user's session which defined 
what precisely must happen.
+ * Commits makes changes to MMBase. Depends on a jsp 
/mmbase/searchrelate/relate.jsp to do the actual work.
+ * This jsp, in turn, depends on the query in the user's session which defines 
precisely what must happen.
  */
 MMBaseRelater.prototype.commit = function(ev) {
     var relatedNumbers   = this.getNumbers(this.related);
@@ -323,7 +319,6 @@
 
         this.unrelated[number] = null;
 
-
         var currentList =  $(this.current).find("div.searchresult table 
tbody");
         this.logger.debug(currentList[0]);
         currentList.append(tr);
@@ -395,15 +390,15 @@
 
     // Events
     $(tr).unbind();
-    var searcher = this;
+    var self = this;
     $(tr).click(function() {
-        searcher.relate(this)
+        self.relateIt(this)
     });
     $(this.div).trigger("mmsrUnrelate", [tr, this]);
 }
 
 /**
- * Saves a modified relations values.
+ * Does not create a relation but saves a modified one. 
  */
 MMBaseRelater.prototype.saverelation = function(ev) {
     ev.preventDefault();
@@ -577,7 +572,7 @@
 }
 
 /**
- * This method is called if somebody clicks on a.search.
+ * This is called when clicking on a.search or a.navigate (when paging).
  * It depends on a jsp /mmbase/searchrelate/page.jspx to return the search 
results.
  * Feeded are a.o. 'id' 'offset' and 'search'.
  * The actual query is supposed to be on the user's session, and will be 
picked up in page.jspx.
@@ -665,7 +660,8 @@
 
 /**
  * If you defined in your CSS that 'implicit' search results are not visible 
at all, then
- * you can call this method to bind events to change the texts on the search 
buttons accordingly (between 'search' and 'close').
+ * you can call this method to bind events to change the texts on the search 
buttons accordingly 
+ * (between 'search' and 'close').
  */
 MMBaseSearcher.prototype.implicitsAreHidden = function() {
     $(document).bind("mmsrPaged",
@@ -822,7 +818,6 @@
 
 }
 
-
 MMBaseSearcher.prototype.filter = function(tr) {
     if (this.type == "repository" && this.relater != null) {
         var number = this.relater.getNumber(tr);
@@ -850,7 +845,6 @@
     var self = this;
     this.logger.debug("binding to "+ $(this.div).find("a.navigate"));
 
-
     $(this.div).find("a.navigate").click(function(ev) {
         var anchor = ev.target;
         self.logger.debug("navigating " + anchor);

Modified: 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
===================================================================
--- 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
        2010-02-12 10:55:05 UTC (rev 40980)
+++ 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/page.jspx
        2010-02-12 11:01:31 UTC (rev 40981)
@@ -75,14 +75,14 @@
                 <c:otherwise>
                   <th class="node number" scope="col">#</th>
                   <th class="node guitype" scope="col"><fmt:message 
key="nodetype"  /></th>
-                  <th class="node gui" scope="col"></th>
+                  <th class="node gui" scope="col"><jsp:text> </jsp:text></th>
                     <mm:fieldlist nodetype="${query.nodeManager.name}" 
type="list" varStatus="field">
                       <th class="fields ${field.current.name}" 
scope="col"><mm:fieldinfo type="guiname" /></th>
                       <mm:last><mm:index write="false" id="colcount" 
/></mm:last>
                     </mm:fieldlist>
                 </c:otherwise>
               </c:choose>
-              <th class="node action" scope="col"> </th>
+              <th class="node action" scope="col"><jsp:text> </jsp:text></th>
             </tr>
           </thead>
           <!--  PAGING -->

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

Reply via email to