Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
{{!
18
    @template mod_forum/big_search_form
19
 
20
    Big search form.
21
 
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
    }
49
}}
50
 
51
<div class="mb-4">
52
    {{#str}}searchforumintro, forum{{/str}}
53
</div>
54
 
55
    <form id="searchform" action="{{actionurl}}" method="get">
56
        <div class="rui-searchbox" id="form">
57
            <div class="mb-4">
58
                <label for="words">{{#str}}searchwords, forum{{/str}}</label>
59
                <input type="hidden" value="{{courseid}}" name="id">
60
                <input type="text" class="form-control" name="words" id="words" value="{{words}}">
61
            </div>
62
            <div class="mb-4">
63
                <label for="phrase">{{#str}}searchphrase, forum{{/str}}</label>
64
                <input type="text" class="form-control" name="phrase" id="phrase" value="{{phrase}}">
65
            </div>
66
            <div class="mb-4">
67
                <label for="notwords">{{#str}}searchnotwords, forum{{/str}}</label>
68
                <input type="text" class="form-control" name="notwords" id="notwords" value="{{notwords}}">
69
            </div>
70
            {{#showfullwords}}
71
                <div class="mb-4">
72
                    <label for="fullwords">{{#str}}searchfullwords, forum{{/str}}</label>
73
                    <input type="text" class="form-control" name="fullwords" id="fullwords" value="{{fullwords}}">
74
                </div>
75
            {{/showfullwords}}
76
            <div class="alert alert-light mb-1 d-inline-flex align-items-center w-100">
77
                    <div class="custom-control custom-switch">
78
                        <input type="checkbox" class="custom-control-input" id="timefromrestrict" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
79
                        <label class="custom-control-label" for="timefromrestrict">
80
                            {{#str}}searchdatefrom, forum{{/str}}
81
                        </label>
82
                    </div>
83
                    {{{datefromfields}}}
84
                    <input type="hidden" name="hfromday" value="0">
85
                    <input type="hidden" name="hfrommonth" value="0">
86
                    <input type="hidden" name="hfromyear" value="0">
87
                    <input type="hidden" name="hfromhour" value="0">
88
                    <input type="hidden" name="hfromminute" value="0">
89
            </div>
90
            <div class="alert alert-light mb-1 d-inline-flex align-items-center w-100">
91
                    <div class="d-inline-flex align-items-center">
92
                        <div class="custom-control custom-switch">
93
                            <input type="checkbox" class="custom-control-input" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
94
                            <label class="custom-control-label" for="timetorestrict">
95
                                {{#str}}searchdateto, forum{{/str}}
96
                            </label>
97
                        </div>
98
                        {{{datetofields}}}
99
                        <input type="hidden" name="htoday" value="0">
100
                        <input type="hidden" name="htomonth" value="0">
101
                        <input type="hidden" name="htoyear" value="0">
102
                        <input type="hidden" name="htohour" value="0">
103
                        <input type="hidden" name="htominute" value="0">
104
                    </div>
105
            </div>
106
            <div class="mb-4 alert alert-light">
107
                    <label for="menuforumid">{{#str}}searchwhichforums, forum{{/str}}</label>
108
                    <select name="forumid" id="menuforumid" class="ml-3 custom-select w-100">
109
                        {{#forumoptions}}
110
                            <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
111
                        {{/forumoptions}}
112
                    </select>
113
            </div>
114
            <div class="mb-4">
115
                    <label for="subject">{{#str}}searchsubject, forum{{/str}}</label>
116
                    <input type="text" class="form-control" name="subject" id="subject" value="{{subject}}">
117
            </div>
118
            <div class="mb-4">
119
                <label for="user">
120
                     <svg class="mr-1" width="24" height="24" fill="none" viewBox="0 0 24 24">
121
                        <circle cx="12" cy="8" r="3.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></circle>
122
                        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12.25 19.25H6.94953C5.77004 19.25 4.88989 18.2103 5.49085 17.1954C6.36247 15.7234 8.23935 14 12.25 14"></path>
123
                        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M14.75 17.75L16 19.25L19.25 14.75"></path>
124
                    </svg>
125
                    {{#str}}searchuser, forum{{/str}}
126
                </label>
127
                <input type="text" class="form-control" name="user" id="user" value="{{user}}">
128
            </div>
129
            {{^guestuser}}
130
            <div class="mb-4 alert alert-light">
131
                    <div class="custom-control custom-switch">
132
                        <input type="checkbox" class="custom-control-input" name="starredonly" id="starredonly" value="1" {{#starredonly}}checked{{/starredonly}}>
133
                        <label class="custom-control-label" for="starredonly">
134
                            {{#str}}starredonly, forum{{/str}}
135
                        </label>
136
                    </div>
137
            </div>
138
            {{/guestuser}}
139
            {{#tagsenabled}}
140
                <div class="mb-4">
141
                        <label class="mr-3" for="tags">
142
                            <svg width="24" height="24" fill="none" viewBox="0 0 24 24">
143
                                <circle cx="15" cy="9" r="1" fill="currentColor"></circle>
144
                                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 4.75H19.25V12L12.5535 18.6708C11.7544 19.4668 10.4556 19.445 9.68369 18.6226L5.28993 13.941C4.54041 13.1424 4.57265 11.8895 5.36226 11.1305L12 4.75Z"></path>
145
                            </svg>
146
                            {{#str}}searchtags, forum{{/str}}
147
                        </label>
148
                        <select class="custom-select" name="tags[]"
149
                                id="tags" multiple>
150
                            {{#tagoptions}}
151
                                <option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
152
                            {{/tagoptions}}
153
                        </select>
154
                </div>
155
            {{/tagsenabled}}
156
            <div>
157
                <button type="submit" class="btn btn-primary">{{#str}}searchforums, forum{{/str}}</button>
158
            </div>
159
        </div>
160
    </form>
161
 
162
{{#js}}
163
require(['jquery'], function($) {
164
    var toggleDateFields = function(prefix, disabled) {
165
        $('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
166
        $('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
167
    };
168
 
169
    toggleDateFields('from', !$("#searchform input[name='timefromrestrict']").prop('checked'));
170
    $("#searchform input[name='timefromrestrict']").click(function() {
171
        toggleDateFields('from', !this.checked);
172
    });
173
 
174
    toggleDateFields('to', !$("#searchform input[name='timetorestrict']").prop('checked'));
175
    $("#searchform input[name='timetorestrict']").click(function() {
176
        toggleDateFields('to', !this.checked);
177
    });
178
});
179
{{/js}}