summaryrefslogtreecommitdiff
path: root/app/views/forumthreads/search.html.erb
blob: a3c631f95c65346ee244014c5ee307dc58624005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<% title "Thread Search" %>
<h1>Thread Search</h1>
<h3>Leave a field blank to ignore that search aspect.</h3>
<% label = Label.where(name: params[:label]).first %>
<table>
  <tbody>
<%= form_tag({controller: "forumthreads", action: "search_redirect"}, method: :post) do %>
  <%
    forums = []
    Forum.all.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f|
      if current_user != nil && current_user.role_id > f.role_read_id.to_i || current_user == nil && f.role_read_id == nil
        forums << ["#{f.forumgroup.name} → #{f.name}", f.id] if f.forumgroup
      end
    end
  %>
  <% label_list = Label.pluck(:name).insert(0, "Label").insert(1, "No Label") %>
  <tr>
    <td>Forum</td>
    <td><%= select_tag "id", options_for_select(["Search All Threads"] + forums, params[:id]) %></td>
  </tr>
  <tr>
    <td>Label</td>
    <td>
      <%= select_tag "label", options_for_select(label_list, params[:label]), class: "auto-width" %>
    </td>
  </tr>
  <tr>
    <td>Title</td>
    <td>
      <%= text_field_tag "title", params[:title], placeholder: "Search Titles" %>
    </td>
  </tr>
  <tr>
    <td>Content</td>
    <td>
      <%= text_field_tag "content", params[:content], placeholder: "Search Contents" %>
    </td>
  <tr>
    <td>Author</td>
    <td>
      <%= render partial: "md_editor_user", locals: {name: "author", content: params[:author]} %>
    </td>
  </tr>
    <td>Replies</td>
    <td>
      <%= text_field_tag "reply", params[:reply], placeholder: "Search Replies" %>
    </td>
  </tr>
  <tr>
    <td>
      <%= submit_tag "Go", class: "btn blue", style: "width:50px" %>
    </td>
  </tr>
<% end %>
  </tbody>
</table>