MDL-57660 mod_forum: Preserve forum ID selection after form submission
[moodle.git] / mod / forum / templates / big_search_form.mustache
CommitLineData
10deddd3
FM
1{{!
2 This file is part of Moodle - http://moodle.org/
3
4 Moodle is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 Moodle is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16}}
17{{!
d679a45f
MC
18 @template mod_forum/big_search_form
19
10deddd3 20 Big search form.
d679a45f
MC
21
22 Example context (json):
23 {
d679a45f
MC
24 "actionurl": "https://example.com/mod/forum/search.php",
25 "courseid": "2",
26 "words": "apples",
27 "phrase": "Lorem ipsum dolor",
28 "notwords": "Not these words",
29 "showfullwords": [
30 {
31 "fullwords": "Exactly"
32 }
33 ],
34 "datefromchecked": 1,
35 "datetochecked": "",
36 "forumoptions": [
37 {
38 "name": "Forum One",
39 "value": "23"
40 },
41 {
42 "name": "Forum Two",
43 "value": "34"
44 }
45 ],
46 "subject": "Help me please",
47 "user": "Helpy McUser"
48 }
10deddd3
FM
49}}
50<div id="intro" class="box searchbox boxaligncenter">
51 {{#str}}searchforumintro, forum{{/str}}
52</div>
53<div class="box generalbox boxaligncenter">
10deddd3 54 <form id="searchform" action="{{actionurl}}" method="get">
1847d4c5 55 <table class="searchbox table" id="form">
10deddd3
FM
56 <tr>
57 <td class="c0">
58 <label for="words">{{#str}}searchwords, forum{{/str}}</label>
59 <input type="hidden" value="{{courseid}}" name="id">
60 </td>
61 <td class="c1">
62 <input type="text" size="35" name="words" id="words" value="{{words}}">
63 </td>
64 </tr>
65 <tr>
66 <td class="c0">
67 <label for="phrase">{{#str}}searchphrase, forum{{/str}}</label>
68 </td>
69 <td class="c1">
70 <input type="text" size="35" name="phrase" id="phrase" value="{{phrase}}">
71 </td>
72 </tr>
73 <tr>
74 <td class="c0">
75 <label for="notwords">{{#str}}searchnotwords, forum{{/str}}</label>
76 </td>
77 <td class="c1">
78 <input type="text" size="35" name="notwords" id="notwords" value="{{notwords}}">
79 </td>
80 </tr>
81 {{#showfullwords}}
82 <tr>
83 <td class="c0">
84 <label for="fullwords">{{#str}}searchfullwords, forum{{/str}}</label>
85 </td>
86 <td class="c1">
87 <input type="text" size="35" name="fullwords" id="fullwords" value="{{fullwords}}">
88 </td>
89 </tr>
90 {{/showfullwords}}
91 <tr>
92 <td class="c0">
93 {{#str}}searchdatefrom, forum{{/str}}
94 </td>
95 <td class="c1">
22526ad9 96 <input type="checkbox" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
10deddd3
FM
97 {{{datefromfields}}}
98 <input type="hidden" name="hfromday" value="0">
99 <input type="hidden" name="hfrommonth" value="0">
100 <input type="hidden" name="hfromyear" value="0">
101 <input type="hidden" name="hfromhour" value="0">
102 <input type="hidden" name="hfromminute" value="0">
103 </td>
104 </tr>
105 <tr>
106 <td class="c0">
107 {{#str}}searchdateto, forum{{/str}}
108 </td>
109 <td class="c1">
22526ad9 110 <input type="checkbox" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
10deddd3
FM
111 {{{datetofields}}}
112 <input type="hidden" name="htoday" value="0">
113 <input type="hidden" name="htomonth" value="0">
114 <input type="hidden" name="htoyear" value="0">
115 <input type="hidden" name="htohour" value="0">
116 <input type="hidden" name="htominute" value="0">
117 </td>
118 </tr>
119 <tr>
120 <td class="c0">
121 <label for="menuforumid">{{#str}}searchwhichforums, forum{{/str}}</label>
122 </td>
123 <td class="c1">
d679a45f 124 <select name="forumid" id="menuforumid">
10deddd3 125 {{#forumoptions}}
1da58a1a 126 <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
10deddd3
FM
127 {{/forumoptions}}
128 </select>
129 </td>
130 </tr>
131 <tr>
132 <td class="c0">
133 <label for="subject">{{#str}}searchsubject, forum{{/str}}</label>
134 </td>
135 <td class="c1">
136 <input type="text" size="35" name="subject" id="subject" value="{{subject}}">
137 </td>
138 </tr>
139 <tr>
140 <td class="c0">
141 <label for="user">{{#str}}searchuser, forum{{/str}}</label>
142 </td>
143 <td class="c1">
144 <input type="text" size="35" name="user" id="user" value="{{user}}">
145 </td>
146 </tr>
147 <tr>
1847d4c5
DP
148 <td colspan="2" class="submit">
149 <div class="text-center">
150 <input type="submit" value={{#quote}}{{#str}}searchforums, forum{{/str}}{{/quote}}>
151 </div>
10deddd3
FM
152 </td>
153 </tr>
154 </table>
155 </form>
10deddd3 156</div>
22526ad9
DP
157{{#js}}
158 require(['jquery'], function($) {
159 var toggleDateFields = function(prefix, disabled) {
160 $('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
161 $('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
162 };
163
e0e5407e 164 toggleDateFields('from', !$("#searchform input[name='timefromrestrict']").prop('checked'));
22526ad9
DP
165 $("#searchform input[name='timefromrestrict']").click(function() {
166 toggleDateFields('from', !this.checked);
167 });
168
e0e5407e 169 toggleDateFields('to', !$("#searchform input[name='timetorestrict']").prop('checked'));
22526ad9
DP
170 $("#searchform input[name='timetorestrict']").click(function() {
171 toggleDateFields('to', !this.checked);
172 });
173 });
174{{/js}}