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