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 | <g:javascript src="advancedQuery.js" /> |
---|
8 | <script type="text/javascript"> |
---|
9 | // Make a list of fields to search in |
---|
10 | var queryableFields = [ |
---|
11 | <g:set var="j" value="${0}" /> |
---|
12 | <g:each in="${searchableFields}" var="entity"> |
---|
13 | <g:each in="${entity.value}" var="field"> |
---|
14 | <g:if test="${j > 0}">,</g:if> |
---|
15 | { |
---|
16 | label: "${entity.key.toString().encodeAsJavaScript()}.${field.toString().encodeAsJavaScript()} ${entity.key.toString().encodeAsJavaScript()} ${field.toString().encodeAsJavaScript()}", |
---|
17 | show: "${(field[0].toUpperCase() + field[1..-1]).encodeAsJavaScript()}", |
---|
18 | value: "${entity.key.toString().encodeAsJavaScript()}.${field.toString().encodeAsJavaScript()}", |
---|
19 | entity: "${entity.key.toString().encodeAsJavaScript()}" |
---|
20 | } |
---|
21 | <g:set var="j" value="1" /> |
---|
22 | </g:each> |
---|
23 | </g:each> |
---|
24 | ]; |
---|
25 | |
---|
26 | <g:if test="${criteria && criteria.size() > 0}"> |
---|
27 | // Show given criteria |
---|
28 | $(function() { |
---|
29 | <g:each in="${criteria}" var="criterion"> |
---|
30 | showCriterium("${criterion.entityField().encodeAsJavaScript()}", "${criterion.value.toString().encodeAsJavaScript()}", "${criterion.operator.toString().encodeAsJavaScript()}"); |
---|
31 | </g:each> |
---|
32 | showHideNoCriteriaItem(); |
---|
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 | <form id="input_criteria"> |
---|
54 | <h2>Add criterium</h2> |
---|
55 | <p class="explanation"> |
---|
56 | N.B. Comparing numerical values is done without taking into |
---|
57 | account the units. E.g. a weight of 1 kg equals 1 grams. |
---|
58 | </p> |
---|
59 | <label for="field">Field</label> |
---|
60 | <select name="field" id="queryFieldSelect"> |
---|
61 | <option value=""></option> |
---|
62 | <g:each in="${searchableFields}" var="entity"> |
---|
63 | <optgroup label="${entity.key}"> |
---|
64 | <g:each in="${entity.value}" var="field"> |
---|
65 | <option value="${entity.key}.${field}"> |
---|
66 | ${field[0].toUpperCase() + field[1..-1]} |
---|
67 | </option> |
---|
68 | </g:each> |
---|
69 | </optgroup> |
---|
70 | </g:each> |
---|
71 | </select> |
---|
72 | |
---|
73 | <label for="value">Comparison</label> |
---|
74 | <select name="operator"> |
---|
75 | <option value="equals">Equals</option> |
---|
76 | <option value="contains">Contains</option> |
---|
77 | <option value=">=">Greater than or equals</option> |
---|
78 | <option value=">">Greater than</option> |
---|
79 | <option value="<">Lower than</option> |
---|
80 | <option value="<=">Lower than or equals</option> |
---|
81 | </select> |
---|
82 | |
---|
83 | <label for="value">Value</label> |
---|
84 | <input class='text' type="text" name="value" /> |
---|
85 | |
---|
86 | <input class="button" type="button" onClick="addCriterium();" value="Add" /> |
---|
87 | </form> |
---|
88 | <g:form action="search" method="get"> |
---|
89 | <label for="entity">Search for</label><g:select from="${entitiesToSearchFor}" optionKey="key" optionValue="value" name="entity" /><br /> |
---|
90 | <label for="entity">Searchtype</label><g:select from="${searchModes}" name="operator" /><br /> |
---|
91 | <label for="criteria">Criteria</label> |
---|
92 | <ul id="criteria"> |
---|
93 | <li class="emptyList">No criteria added. Use the form on the right to specify criteria to search on.</li> |
---|
94 | </ul> |
---|
95 | |
---|
96 | <input type="submit" value="Run query" class="submitcriteria" disabled="disabled" /> |
---|
97 | </g:form> |
---|
98 | |
---|
99 | <br clear="all" /> |
---|
100 | </div> |
---|
101 | <p class="options"> |
---|
102 | <g:link class="listPrevious" action="list">Previous searches</g:link> |
---|
103 | </p> |
---|
104 | <br clear="all" /> |
---|
105 | </body> |
---|
106 | </html> |
---|