source: trunk/grails-app/views/searchable/index.gsp @ 196

Last change on this file since 196 was 196, checked in by jahn, 10 years ago

Sample selection of the query controller: added buttons for subgroup selection, controller changes for passing on subselections, and some JS for selecting the checkboxes. The actual function of the checkboxes has to be clearified. When I check only subject, should the parent subject also be ticked? Or should it be the other way round? Plenty needs to be done in this step of the query still.

File size: 6.1 KB
Line 
1
2<%@ page import="org.springframework.util.ClassUtils" %>
3<%@ page import="org.codehaus.groovy.grails.plugins.searchable.SearchableUtils" %>
4<%@ page import="org.codehaus.groovy.grails.plugins.searchable.lucene.LuceneUtils" %>
5<%@ page import="org.codehaus.groovy.grails.plugins.searchable.util.StringQueryUtils" %>
6<html>
7  <head>
8    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
9    <meta name="layout" content="main" />
10  <g:set var="entityName" value="${message(code: 'study.label', default: 'Study')}" />
11  <title><g:message code="default.list.label" args="[entityName]" /></title>
12    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
13    <title><g:if test="${params.q && params.q?.trim() != ''}">${params.q} - </g:if>Results</title>
14 
15    <script type="text/javascript">
16        var focusQueryInput = function() {
17            document.getElementById("q").focus();
18        }
19    </script>
20
21  </head>
22  <body onload="focusQueryInput();">
23
24<div class="nav">
25    <h1>Advanced query - select studies</h1>
26   
27    <div style="clear: both; display: none;" class="hint">See <a href="http://lucene.apache.org/java/docs/queryparsersyntax.html">Lucene query syntax</a> for advanced queries</div>
28  </div>
29  <div id="main">
30    <g:set var="haveQuery" value="${params.q?.trim()}" />
31    <g:set var="haveResults" value="${searchResult?.results}" />
32    <div class="title">
33      <span>
34        <br>
35        <g:if test="${haveQuery && haveResults}">
36          Showing <strong>${searchResult.offset + 1}</strong> - <strong>${searchResult.results.size() + searchResult.offset}</strong> of <strong>${searchResult.total}</strong>
37          results for <strong>${params.q}</strong>
38        </g:if>
39        <g:else>
40        &nbsp;
41        </g:else>
42      </span>
43    </div>
44
45    <br>
46    <g:if test="${haveQuery && !haveResults && !parseException}">
47      <p>Nothing matched your query - <strong>${params.q}</strong></p>
48      <g:if test="${!searchResult?.suggestedQuery}">
49        <p>Suggestions:</p>
50        <ul>
51          <li>Try a suggested query: <g:link controller="searchable" action="index" params="[q: params.q, suggestQuery: true]">Search again with the <strong>suggestQuery</strong> option</g:link><br />
52            <em>Note: Suggestions are only available when classes are mapped with <strong>spellCheck</strong> options, either at the class or property level.<br />
53                The simplest way to do this is add <strong>spellCheck "include"</strong> to the domain class searchable mapping closure.<br />
54                See the plugin/Compass documentation Mapping sections for details.</em>
55          </li>
56        </ul>
57      </g:if>
58    </g:if>
59
60    <g:if test="${searchResult?.suggestedQuery}">
61      <p>Did you mean <g:link controller="searchable" action="index" params="[q: searchResult.suggestedQuery]">${StringQueryUtils.highlightTermDiffs(params.q.trim(), searchResult.suggestedQuery)}</g:link>?</p>
62    </g:if>
63
64    <g:if test="${parseException}">
65      <p>Your query - <strong>${params.q}</strong> - is not valid.</p>
66      <p>Suggestions:</p>
67      <ul>
68        <li>Fix the query: see <a href="http://lucene.apache.org/java/docs/queryparsersyntax.html">Lucene query syntax</a> for examples</li>
69        <g:if test="${LuceneUtils.queryHasSpecialCharacters(params.q)}">
70          <li>Remove special characters like <strong>" - [ ]</strong>, before searching, eg, <em><strong>${LuceneUtils.cleanQuery(params.q)}</strong></em><br />
71              <em>Use the Searchable Plugin's <strong>LuceneUtils#cleanQuery</strong> helper method for this: <g:link controller="searchable" action="index" params="[q: LuceneUtils.cleanQuery(params.q)]">Search again with special characters removed</g:link></em>
72          </li>
73          <li>Escape special characters like <strong>" - [ ]</strong> with <strong>\</strong>, eg, <em><strong>${LuceneUtils.escapeQuery(params.q)}</strong></em><br />
74              <em>Use the Searchable Plugin's <strong>LuceneUtils#escapeQuery</strong> helper method for this: <g:link controller="searchable" action="index" params="[q: LuceneUtils.escapeQuery(params.q)]">Search again with special characters escaped</g:link></em><br />
75              <em>Or use the Searchable Plugin's <strong>escape</strong> option: <g:link controller="searchable" action="index" params="[q: params.q, escape: true]">Search again with the <strong>escape</strong> option enabled</g:link></em>
76          </li>
77        </g:if>
78      </ul>
79    </g:if>
80
81<g:form action="selectsample">
82
83    <g:if test="${haveResults}">
84      <div class="results">
85          <table>
86        <g:each var="result" in="${searchResult.results}" status="index">
87            <tr>
88              <td>
89              <input type="checkbox" name="${result.id}" id="${result.title}">
90              </td>
91              <td>
92          <div class="result">
93            <g:set var="className" value="${ClassUtils.getShortName(result.getClass())}" />
94            <g:set var="link" value="${createLink(controller: className[0].toLowerCase() + className[1..-1], action: 'show', id: result.id)}" />
95            <div class="name"><a href="${link}">${className} ${result.id}</a></div>
96            <g:set var="desc" value="${result.toString()}" />
97            <g:if test="${desc.size() > 120}"><g:set var="desc" value="${desc[0..120] + '...'}" /></g:if>
98            <div class="desc">${desc.encodeAsHTML()}</div>
99            <br>
100          </div>
101              </td>
102            </tr>
103        </g:each>
104          </table>
105      </div>
106
107      <br>
108      <INPUT TYPE=submit name=submit Value=">> Execute and continue with sample selection">
109
110      <div>
111        <div class="paging">
112          <g:if test="${haveResults}">
113            <br>
114              Page:
115              <g:set var="totalPages" value="${Math.ceil(searchResult.total / searchResult.max)}" />
116              <g:if test="${totalPages == 1}"><span class="currentStep">1</span></g:if>
117              <g:else><g:paginate controller="searchable" action="index" params="[q: params.q]" total="${searchResult.total}" prev="&lt; previous" next="next &gt;"/></g:else>
118          </g:if>
119        </div>
120      </div>
121    </g:if>
122</g:form>
123  </div>
124  </body>
125</html>
Note: See TracBrowser for help on using the repository browser.