Update of /var/cvs/applications/searchrelate/templates
In directory james.mmbase.org:/tmp/cvs-serv5826/templates
Modified Files:
Searcher.js.jsp page.jspx
Added Files:
create.jspx
Log Message:
added i18n, some descriptions, and started to add some 'create new node'
functionality too
See also: http://cvs.mmbase.org/viewcvs/applications/searchrelate/templates
create.jspx is new
Index: Searcher.js.jsp
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/Searcher.js.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Searcher.js.jsp 8 Apr 2008 16:31:20 -0000 1.1
+++ Searcher.js.jsp 10 Apr 2008 14:59:24 -0000 1.2
@@ -11,7 +11,7 @@
*
* @author Michiel Meeuwissen
- * @version $Id: Searcher.js.jsp,v 1.1 2008/04/08 16:31:20 michiel Exp $
+ * @version $Id: Searcher.js.jsp,v 1.2 2008/04/10 14:59:24 michiel Exp $
*/
$(document).ready(function(){
@@ -54,12 +54,15 @@
} else {
log.debug("No current rep found");
}
+
+ if (typeof MMBaseValidator == "function") {
+ this.validator = new MMBaseValidator(this.div);
+ }
this.logger.debug("setting up repository");
this.repository = $(d).find(".mm_relate_repository")[0];
if (this.repository != null) this.addSearcher(this.repository,
"repository");
this.canUnrelate = $(d).hasClass("can_unrelate");
-
}
@@ -74,6 +77,13 @@
return this.searcher.search(anchor, 0);
});
});
+ $(el).find("a.create").each(function() {
+ var anchor = this;
+ anchor.searcher = searcher;
+ $(anchor).click(function(el) {
+ return this.searcher.create(anchor);
+ });
+ });
if (this.canUnrelate) {
$(el).find("tr.click").each(function() {
$(this).click(function() {
@@ -263,9 +273,20 @@
});
this.searchResults = {};
this.bindEvents();
+ this.validator = this.relater.validator;
+
+}
+
+MMBaseSearcher.prototype.getQueryId = function() {
+ var searchAnchor = $(this.div).find("a.search")[0];
+ var id = searchAnchor.href.substring(searchAnchor.href.indexOf("#") + 1);
+ return id;
}
+MMBaseSearcher.prototype.getResultDiv = function() {
+ return $(this.div).find("div.searchresult")[0]
+}
/**
* This method is called if somebody clicks on a.search.
@@ -279,12 +300,10 @@
this.searchResults = {};
this.value = newSearch;
}
- var searchAnchor = $(el).parents(".searchable").find("a.search")[0];
- var id = searchAnchor.href.substring(searchAnchor.href.indexOf("#") + 1);
- var rep = $(el).parents(".searchable").find("div.searchresult")[0]
+ var rep = this.getResultDiv();
var url = "${mm:link('/mmbase/searchrelate/page.jspx')}";
- var params = {id: id, offset: offset, search: this.value, pagesize:
this.pagesize};
+ var params = {id: this.getQueryId(), offset: offset, search: this.value,
pagesize: this.pagesize};
var result = this.searchResults["" + offset];
$(rep).empty();
@@ -318,6 +337,24 @@
return false;
}
+MMBaseSearcher.prototype.create = function () {
+ var rep = this.getResultDiv();
+ var url = "${mm:link('/mmbase/searchrelate/create.jspx')}";
+ var params = {id: this.getQueryId()};
+ var self = this;
+ $.ajax({url: url, type: "GET", dataType: "xml", data: params,
+ complete: function(res, status){
+ if ( status == "success") {
+ result = res.responseText;
+ $(rep).empty();
+ $(rep).append($(result).find("> *"));
+ self.validator.addValidation(rep);
+ }
+ }
+ });
+ $(rep).append($("<p>Creating</p>"));
+}
+
MMBaseSearcher.prototype.deleteNewlyRemoved = function(rep) {
var self = this;
var deleted = false;
Index: page.jspx
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/page.jspx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- page.jspx 8 Apr 2008 16:31:20 -0000 1.1
+++ page.jspx 10 Apr 2008 14:59:24 -0000 1.2
@@ -3,19 +3,28 @@
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"
+ xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
>
+ <!--
+ 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.2 2008/04/10 14:59:24 michiel Exp $
+ -->
<jsp:output omit-xml-declaration="true" />
<mm:content expires="0" type="application/xml">
+ <fmt:bundle basename="org.mmbase.searchrelate.resources.searchrelate">
<mm:import externid="id" required="true" />
<mm:import externid="search" />
<mm:import externid="pagesize">10</mm:import>
<mm:import externid="maxpages">20</mm:import>
<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">
<c:if test="${! empty search}">
<mm:composite operator="OR">
- <mm:fieldlist type="search" id="field">
+ <mm:fieldlist container="b" type="search" id="field">
<c:if test="${field.dataType.class.name eq
'org.mmbase.datatypes.StringDataType'}">
<mm:constraint field="${field.name}" operator="LIKE"
value="%${search}%" casesensitive="false"/>
</c:if>
@@ -24,7 +33,11 @@
</c:if>
<mm:maxnumber value="${pagesize}" />
<mm:offset value="${offset}" />
- <table summary="Search results for ${search}">
+
+ <fmt:message key="searchresults" var="summary">
+ <fmt:param value="${search}" />
+ </fmt:message>
+ <table summary="${summary}">
<thead>
<tr>
<th class="node number">#</th>
@@ -35,6 +48,7 @@
</mm:fieldlist>
</tr>
</thead>
+ <!-- PAGING -->
<tfoot>
<tr>
<td colspan="${colcount + 2}">
@@ -47,7 +61,7 @@
<a class="navigate" href="${'#'}${id}_${_}"
name="${_}"><mm:index /></a>
<jsp:text>, </jsp:text>
</mm:previousbatches>
- <mm:index offset="1" />
+ <span class="current"><mm:index offset="1" /></span>
<mm:nextbatches maxtotal="${maxpages}" indexoffset="1">
<jsp:text>, </jsp:text>
<a class="navigate" href="${'#'}${id}_${_}"
name="${_}"><mm:index /></a>
@@ -60,6 +74,7 @@
</td>
</tr>
</tfoot>
+ <!-- ACTUAL SEARCHRESULT -->
<tbody>
<mm:listnodes varStatus="status">
<tr class="click ${status.index % 2 eq 0 ? 'even' : 'odd'}"
id="${id}_node_${_node}">
@@ -71,8 +86,7 @@
</td>
<mm:fieldlist type="list">
<mm:fieldinfo type="name">
- <td class="fields ${_}"><mm:fieldinfo type="guivalue" />
- </td>
+ <td class="fields ${_}"><mm:fieldinfo type="guivalue"
/></td>
</mm:fieldinfo>
</mm:fieldlist>
</tr>
@@ -80,5 +94,6 @@
</tbody>
</table>
</mm:listnodescontainer>
+ </fmt:bundle>
</mm:content>
</div>
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs