1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
---|
4 | <meta name="layout" content="main"/> |
---|
5 | <title>Query database</title> |
---|
6 | <link rel="stylesheet" href="<g:resource dir="css" file="advancedQuery.css" />" type="text/css"/> |
---|
7 | <link rel="stylesheet" href="<g:resource dir="css" file="buttons.css" />" type="text/css"/> |
---|
8 | <g:javascript src="advancedQuery.js" /> |
---|
9 | <script type="text/javascript"> |
---|
10 | // Make a list of fields to search in |
---|
11 | var queryableFields = [ |
---|
12 | <g:set var="j" value="${0}" /> |
---|
13 | <g:each in="${searchableFields}" var="entity"> |
---|
14 | <g:each in="${entity.value}" var="field"> |
---|
15 | <g:if test="${j > 0}">,</g:if> |
---|
16 | { |
---|
17 | label: "${( |
---|
18 | entity.key.toString() + '.' + field.toString() + ' ' + |
---|
19 | entity.key.toString() + ' ' + field.toString() + ' ' + |
---|
20 | (field == '*' ? 'any field' : '') |
---|
21 | ).encodeAsJavaScript()}", |
---|
22 | show: "${ |
---|
23 | (field == '*' ? |
---|
24 | '[Any field in ' + entity.key.toString() + ']' : |
---|
25 | (field?.size() > 1 ? |
---|
26 | field[0].toUpperCase() + field[1..-1] : |
---|
27 | field) |
---|
28 | ).encodeAsJavaScript()}", |
---|
29 | value: "${entity.key.toString().encodeAsJavaScript()}.${field.toString().encodeAsJavaScript()}", |
---|
30 | entity: "${entity.key.toString().encodeAsJavaScript()}" |
---|
31 | } |
---|
32 | <g:set var="j" value="1" /> |
---|
33 | </g:each> |
---|
34 | </g:each> |
---|
35 | ]; |
---|
36 | |
---|
37 | <g:if test="${criteria && criteria.size() > 0}"> |
---|
38 | // Show given criteria |
---|
39 | $(function() { |
---|
40 | <g:each in="${criteria}" var="criterion"> |
---|
41 | showCriterium("${criterion.entityField().encodeAsJavaScript()}", "${criterion.value.toString().encodeAsJavaScript()}", "${criterion.operator.toString().encodeAsJavaScript()}"); |
---|
42 | </g:each> |
---|
43 | }); |
---|
44 | </g:if> |
---|
45 | </script> |
---|
46 | </head> |
---|
47 | <body> |
---|
48 | |
---|
49 | <h1>Search database</h1> |
---|
50 | |
---|
51 | <g:if test="${flash.error}"> |
---|
52 | <div class="errormessage"> |
---|
53 | ${flash.error.toString().encodeAsHTML()} |
---|
54 | </div> |
---|
55 | </g:if> |
---|
56 | <g:if test="${flash.message}"> |
---|
57 | <div class="message"> |
---|
58 | ${flash.message.toString().encodeAsHTML()} |
---|
59 | </div> |
---|
60 | </g:if> |
---|
61 | |
---|
62 | <div id="searchForm"> |
---|
63 | <g:form action="search" method="get"> |
---|
64 | |
---|
65 | <h3><span class="nummer">1</span>Select criteria</h3> |
---|
66 | <p class="explanation"> |
---|
67 | N.B. Comparing numerical values is done without taking into |
---|
68 | account the units. E.g. a weight of 1 kg equals 1 grams. |
---|
69 | </p> |
---|
70 | <ul id="criteria"> |
---|
71 | <li class="titlerow"> |
---|
72 | <span class="entityfield"> |
---|
73 | Field |
---|
74 | </span> |
---|
75 | <span class="operator"> |
---|
76 | Operator |
---|
77 | </span> |
---|
78 | <span class="value"> |
---|
79 | Value |
---|
80 | </span> |
---|
81 | </li> |
---|
82 | <li class="newCriterion"> |
---|
83 | <span class="entityfield"> |
---|
84 | <select name="criteria.0.entityfield" id="queryFieldSelect"> |
---|
85 | <option value=""></option> |
---|
86 | <g:each in="${searchableFields}" var="entity"> |
---|
87 | <optgroup label="${entity.key}"> |
---|
88 | <g:each in="${entity.value}" var="field"> |
---|
89 | <option value="${entity.key}.${field}"> |
---|
90 | <g:if test="${field?.size() > 1}"> |
---|
91 | ${field[0].toUpperCase() + field[1..-1]} |
---|
92 | </g:if> |
---|
93 | <g:else> |
---|
94 | ${field} |
---|
95 | </g:else> |
---|
96 | </option> |
---|
97 | </g:each> |
---|
98 | </optgroup> |
---|
99 | </g:each> |
---|
100 | </select> |
---|
101 | </span> |
---|
102 | <span class="operator"> |
---|
103 | <select id="operator" name="criteria.0.operator"> |
---|
104 | <option value="equals">Equals</option> |
---|
105 | <option value="contains">Contains</option> |
---|
106 | <option value=">=">>=</option> |
---|
107 | <option value=">">></option> |
---|
108 | <option value="<"><</option> |
---|
109 | <option value="<="><=</option> |
---|
110 | </select> |
---|
111 | </span> |
---|
112 | <span class="value"> |
---|
113 | <input class='text' type="text" id="value" name="criteria.0.value" /> |
---|
114 | </span> |
---|
115 | <span class="addButton"> |
---|
116 | <a href="#" onClick="addCriterion(); return false;"> |
---|
117 | <img src="${fam.icon( name: 'add' )}" border="0"> |
---|
118 | </a> |
---|
119 | </span> |
---|
120 | </li> |
---|
121 | </ul> |
---|
122 | |
---|
123 | <div id="searchMode"> |
---|
124 | <h3><span class="nummer">1b</span>Search mode</h3> |
---|
125 | <p> |
---|
126 | Choose how to combine the given criteria:<br /> |
---|
127 | <g:select from="${searchModes}" name="operator" /> |
---|
128 | </p> |
---|
129 | </div> |
---|
130 | |
---|
131 | <h3><span class="nummer">2</span>Output type</h3> |
---|
132 | <p> |
---|
133 | Choose the type of output:<br /> |
---|
134 | <g:select from="${entitiesToSearchFor}" optionKey="key" optionValue="value" name="entity" /> |
---|
135 | </p> |
---|
136 | |
---|
137 | <h3><span class="nummer">3</span>Run query</h3> |
---|
138 | <p> |
---|
139 | <input type="submit" value="Search" class="submitcriteria" /> |
---|
140 | </p> |
---|
141 | </g:form> |
---|
142 | |
---|
143 | <br clear="all" /> |
---|
144 | </div> |
---|
145 | <g:if test="${session.queries?.size()}"> |
---|
146 | <p class="options"> |
---|
147 | <g:link class="listPrevious" action="list">Previous searches</g:link> |
---|
148 | </p> |
---|
149 | </g:if> |
---|
150 | <br clear="all" /> |
---|
151 | </body> |
---|
152 | </html> |
---|