Moodle release 3.3.8
[moodle.git] / mod / forum / templates / big_search_form.mustache
blob4d26e5c24cb22cba039449d932380ba3b8efa547
1 {{!
2     This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
17 {{!
18     @template mod_forum/big_search_form
20     Big search form.
22     Example context (json):
23     {
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     }
50 <div id="intro" class="box searchbox boxaligncenter">
51     {{#str}}searchforumintro, forum{{/str}}
52 </div>
53 <div class="box generalbox boxaligncenter">
54     <form id="searchform" action="{{actionurl}}" method="get">
55         <table class="searchbox table" id="form">
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">
96                     <input type="checkbox" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
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">
110                     <input type="checkbox" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
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">
124                     <select name="forumid" id="menuforumid">
125                         {{#forumoptions}}
126                             <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
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             {{#tagsenabled}}
148             <tr>
149                 <td class="c0">
150                     <label for="tags">{{#str}}searchtags, forum{{/str}}</label>
151                 </td>
152                 <td class="c1">
153                     <select class="custom-select" name="tags[]"
154                             id="tags" multiple>
155                         {{#tagoptions}}
156                             <option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
157                         {{/tagoptions}}
158                     </select>
159                 </td>
160             </tr>
161             {{/tagsenabled}}
162             <tr>
163                 <td colspan="2" class="submit">
164                     <div class="text-center">
165                         <input type="submit" value={{#quote}}{{#str}}searchforums, forum{{/str}}{{/quote}}>
166                     </div>
167                 </td>
168             </tr>
169         </table>
170     </form>
171 </div>
172 {{#js}}
173     require(['jquery'], function($) {
174         var toggleDateFields = function(prefix, disabled) {
175             $('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
176             $('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
177         };
179         toggleDateFields('from', !$("#searchform input[name='timefromrestrict']").prop('checked'));
180         $("#searchform input[name='timefromrestrict']").click(function() {
181             toggleDateFields('from', !this.checked);
182         });
184         toggleDateFields('to', !$("#searchform input[name='timetorestrict']").prop('checked'));
185         $("#searchform input[name='timetorestrict']").click(function() {
186             toggleDateFields('to', !this.checked);
187         });
188     });
189 {{/js}}