Update of /var/cvs/applications/searchrelate/templates
In directory james.mmbase.org:/tmp/cvs-serv16212
Modified Files:
Searcher.js.jsp create.jspx page.css.jsp page.jspx relate.jspf
Added Files:
node.tr.jspx
Log Message:
made creating of new nodes, and dleeting of relations work
See also: http://cvs.mmbase.org/viewcvs/applications/searchrelate/templates
node.tr.jspx is new
Index: Searcher.js.jsp
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/Searcher.js.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Searcher.js.jsp 10 Apr 2008 14:59:24 -0000 1.2
+++ Searcher.js.jsp 14 Apr 2008 15:45:15 -0000 1.3
@@ -11,7 +11,7 @@
*
* @author Michiel Meeuwissen
- * @version $Id: Searcher.js.jsp,v 1.2 2008/04/10 14:59:24 michiel Exp $
+ * @version $Id: Searcher.js.jsp,v 1.3 2008/04/14 15:45:15 michiel Exp $
*/
$(document).ready(function(){
@@ -49,10 +49,11 @@
this.logger.debug(d);
this.logger.debug("setting up current");
this.current = $(d).find(".mm_relate_current")[0];
+ this.canUnrelate = $(d).hasClass("can_unrelate");
if (this.current != null) {
this.addSearcher(this.current, "current");
} else {
- log.debug("No current rep found");
+ this.logger.debug("No current rep found");
}
if (typeof MMBaseValidator == "function") {
@@ -61,7 +62,6 @@
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");
}
@@ -86,8 +86,8 @@
});
if (this.canUnrelate) {
$(el).find("tr.click").each(function() {
- $(this).click(function() {
- anchor.searcher.unrelate(this);
+ $(this).click(function(tr) {
+ relater.unrelate(this);
return false;
})});
}
@@ -119,7 +119,7 @@
if (this.transaction != null) {
params.transaction = this.transaction;
}
- $.ajax({async: true, url: url, type: "GET", dataType: "xml", data:
params,
+ $.ajax({async: false, url: url, type: "GET", dataType: "xml", data:
params,
complete: function(res, status){
$(a).removeClass("submitting");
if (status == "success") {
@@ -264,8 +264,10 @@
this.relater = r;
this.type = type;
this.pagesize = 10;
+ this.maxpages = 20;
this.logger = logger != null ? logger : new MMBaseLogger();
this.value = "";
+ this.offset = 0;
this.transaction = null;
var self = this;
$(d).find("span.transactioname").each(function() {
@@ -300,10 +302,11 @@
this.searchResults = {};
this.value = newSearch;
}
+ this.offset = offset;
var rep = this.getResultDiv();
var url = "${mm:link('/mmbase/searchrelate/page.jspx')}";
- var params = {id: this.getQueryId(), offset: offset, search: this.value,
pagesize: this.pagesize};
+ var params = {id: this.getQueryId(), offset: offset, search: this.value,
pagesize: this.pagesize, maxpages: this.maxpages};
var result = this.searchResults["" + offset];
$(rep).empty();
@@ -342,19 +345,49 @@
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,
+ $.ajax({url: url, type: "GET", data: params,
complete: function(res, status){
if ( status == "success") {
result = res.responseText;
$(rep).empty();
$(rep).append($(result).find("> *"));
+ console.log($(result).find("input[name='nodemanager']")[0]);
+
self.validator.prefetchNodeManager($(result).find("input[name='nodemanager']")[0].value);
self.validator.addValidation(rep);
+ var options = {
+ url: "${mm:link('/mmbase/searchrelate/create.jspx')}",
+ target: null,
+ success: function(res) {
+ var newNode =
$(res).find("span.newnode")[0].firstChild.nodeValue;
+ var tr = self.getTr(newNode);
+ self.relater.relate(tr);
+ self.search(null, self.offset);
+ }
+ };
+ $(rep).find("form.mm_form").ajaxForm(options);
+
}
}
});
$(rep).append($("<p>Creating</p>"));
}
+
+MMBaseSearcher.prototype.getTr = function(node) {
+ var url = "${mm:link('/mmbase/searchrelate/node.tr.jspx')}";
+ var params = {id: this.getQueryId(), node: node};
+ var result;
+ $.ajax({async: false, url: url, type: "GET", dataType: "xml", data: params,
+ complete: function(res, status){
+ if ( status == "success" || status == "notmodified" ) {
+ result = res.responseText;
+ }
+ }
+ });
+ return result;
+}
+
+
MMBaseSearcher.prototype.deleteNewlyRemoved = function(rep) {
var self = this;
var deleted = false;
Index: create.jspx
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/create.jspx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- create.jspx 10 Apr 2008 14:59:24 -0000 1.1
+++ create.jspx 14 Apr 2008 15:45:15 -0000 1.2
@@ -5,22 +5,51 @@
xmlns:mm="http://www.mmbase.org/mmbase-taglib-2.0"
>
<jsp:output omit-xml-declaration="true" />
- <mm:content expires="0" type="application/xml">
+ <mm:content expires="0" type="text/html">
<mm:cloud method="asis">
<mm:import externid="id" required="true" />
<mm:import from="session" externid="${id}" id="query" required="true" />
- <table summary="Create node">
- <mm:fieldlist nodetype="${query.nodeManager.name}" type="create">
- <tr>
- <th><mm:fieldinfo type="guiname" /></th>
+ <mm:form page="/mmbase/searchrelate/create.jspx">
+ <input type="hidden" name="id" value="${id}" />
+ <input type="hidden" name="nodemanager"
value="${query.nodeManager.name}" />
+ <table class="create" summary="Create node">
+ <tfoot>
+ <tr class="buttons">
+ <td colspan="2">
+ <input type="submit" />
+ <input type="hidden" name="s" />
+ </td>
+ </tr>
+ </tfoot>
+ <mm:createnode id="newnode" type="${query.nodeManager.name}">
+ <tbody>
+ <mm:fieldlist type="create" varStatus="field">
+ <tr class="fields ${field.current.name}">
+ <th class="node">
+ <mm:fieldinfo type="guiname" />
+ </th>
<td>
<mm:fieldinfo type="input" />
<mm:fieldinfo type="errors" />
</td>
</tr>
</mm:fieldlist>
+ </tbody>
+ </mm:createnode>
</table>
+ <mm:import externid="s" />
+ <mm:present referid="s">
+ <mm:valid>
+ <mm:commit />
+ <mm:node referid="newnode">
+ <mm:log>Created new node ${_node}</mm:log>
+ Created <span class="newnode">${_node}</span>
+ </mm:node>
+ </mm:valid>
+ </mm:present>
+ </mm:form>
</mm:cloud>
</mm:content>
</div>
+
Index: page.css.jsp
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/page.css.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- page.css.jsp 8 Apr 2008 16:31:20 -0000 1.1
+++ page.css.jsp 14 Apr 2008 15:45:15 -0000 1.2
@@ -87,6 +87,11 @@
background-color: #e8d8d8;
}
+.mm_related .searchable table .paging.notneeded {
+ display: none;
+}
+
+
.failed {
background-color: red;
}
Index: page.jspx
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/page.jspx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- page.jspx 10 Apr 2008 14:59:24 -0000 1.2
+++ page.jspx 14 Apr 2008 15:45:15 -0000 1.3
@@ -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.2 2008/04/10 14:59:24 michiel Exp $
+ @version $Id: page.jspx,v 1.3 2008/04/14 15:45:15 michiel Exp $
-->
<jsp:output omit-xml-declaration="true" />
<mm:content expires="0" type="application/xml">
@@ -24,16 +24,16 @@
<mm:listnodescontainer id="b" clone="query">
<c:if test="${! empty search}">
<mm:composite operator="OR">
- <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"/>
+ <mm:fieldlist container="b" type="search" varStatus="field">
+ <c:if test="${field.current.dataType.class.name eq
'org.mmbase.datatypes.StringDataType'}">
+ <mm:constraint field="${field.current.name}" operator="LIKE"
value="%${search}%" casesensitive="false"/>
</c:if>
</mm:fieldlist>
</mm:composite>
</c:if>
+ <mm:size id="size" write="false" />
<mm:maxnumber value="${pagesize}" />
<mm:offset value="${offset}" />
-
<fmt:message key="searchresults" var="summary">
<fmt:param value="${search}" />
</fmt:message>
@@ -49,7 +49,7 @@
</tr>
</thead>
<!-- PAGING -->
- <tfoot>
+ <tfoot class="paging ${size gt pagesize ? 'needed' : 'notneeded'}">
<tr>
<td colspan="${colcount + 2}">
<mm:previousbatches maxtotal="${maxpages}" indexoffset="1">
@@ -66,8 +66,8 @@
<jsp:text>, </jsp:text>
<a class="navigate" href="${'#'}${id}_${_}"
name="${_}"><mm:index /></a>
<mm:last>
- <mm:index>
- <mm:compare value="${maxpages}">...</mm:compare>
+ <mm:index write="false">
+ <c:if test="${_ lt size / pagesize}">...</c:if>
</mm:index>
</mm:last>
</mm:nextbatches>
@@ -77,19 +77,7 @@
<!-- ACTUAL SEARCHRESULT -->
<tbody>
<mm:listnodes varStatus="status">
- <tr class="click ${status.index % 2 eq 0 ? 'even' : 'odd'}"
id="${id}_node_${_node}">
- <td class="node number">
- <mm:field name="number" />
- </td>
- <td class="node">
- <mm:nodeinfo type="gui" />
- </td>
- <mm:fieldlist type="list">
- <mm:fieldinfo type="name">
- <td class="fields ${_}"><mm:fieldinfo type="guivalue"
/></td>
- </mm:fieldinfo>
- </mm:fieldlist>
- </tr>
+ <mm:include page="node.tr.jspx" referids="id"
attributes="status,[EMAIL PROTECTED]" />
</mm:listnodes>
</tbody>
</table>
Index: relate.jspf
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/relate.jspf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- relate.jspf 8 Apr 2008 16:31:20 -0000 1.1
+++ relate.jspf 14 Apr 2008 15:45:15 -0000 1.2
@@ -1,11 +1,6 @@
<mm:listnodes referid="related" jspvar="n">
<jsp:expression>Queries.addToResult(current, n)</jsp:expression>
</mm:listnodes>
-<%--
- Not yet supported
- <mm:listnodes referid="unrelated" jspvar="n">
- <jsp:scriptlet>
- Queries.removeFromResult(current, n);
- </jsp:scriptlet>
- </mm:listnodes>
---%>
+<mm:listnodes referid="unrelated" jspvar="n">
+ <jsp:expression>Queries.removeFromResult(current, n)</jsp:expression>
+</mm:listnodes>
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs