Skip to content

Commit 79b0df9

Browse files
committed
Add filter form to view
1 parent 7ee7710 commit 79b0df9

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

app/assets/stylesheets/forms.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,23 @@ select.form-element {
2020
}
2121

2222
& > .form-group {
23-
margin: 0.5em 0;
23+
margin: 0 0 1em 0;
2424

2525
@media screen and (min-width: $screen-md) {
26-
margin: 0 0.5em;
26+
margin: 0 1em 0 0;
2727
flex: 1;
2828
}
2929
}
3030

3131
& > .actions {
3232
display: flex;
3333
align-items: flex-end;
34+
margin-bottom: 4px; // to match bottom margin on .form-element
35+
36+
button, input[type="submit"] {
37+
margin: unset;
38+
padding: 9.5px 12px; // because for some reason it has to be 9.5px to match .form-elements' height
39+
}
3440
}
3541
}
3642

app/views/admin/audit_log.html.erb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
<h1><%= t 'admin.tools.audit_log' %></h1>
22

3+
<div>
4+
<h3>Filters</h3>
5+
<%= form_tag audit_log_path, method: :get, class: 'form-inline' do %>
6+
<div class="form-group-horizontal">
7+
<div class="form-group">
8+
<%= label_tag :log_type, 'Log category', class: 'form-element' %>
9+
<%= select_tag :log_type, options_for_select(@log_types.map { |lt| [lt, lt] }, selected: params[:log_type]),
10+
include_blank: true, class: 'form-element' %>
11+
</div>
12+
<div class="form-group">
13+
<%= label_tag :event_type, 'Event', class: 'form-element' %>
14+
<%= select_tag :event_type, options_for_select(@event_types.map { |et| [et, et] },
15+
selected: params[:event_type]),
16+
include_blank: true, class: 'form-element' %>
17+
</div>
18+
<div class="form-group">
19+
<%= label_tag :from, 'From date', class: 'form-element' %>
20+
<%= date_field_tag :from, params[:from], class: 'form-element' %>
21+
</div>
22+
<div class="form-group">
23+
<%= label_tag :to, 'To date', class: 'form-element' %>
24+
<%= date_field_tag :to, params[:to], class: 'form-element' %>
25+
</div>
26+
<div class="actions">
27+
<%= submit_tag 'Filter', class: 'button is-filled' %>
28+
</div>
29+
</div>
30+
<% end %>
31+
</div>
32+
333
<div class="category-meta">
434
<h3><%= pluralize(@logs.count, t('g.log')) %></h3>
35+
536
<div class="button-list is-gutterless">
637
<% classes = 'button is-outlined is-muted' %>
738
<%= link_to t('g.age'), request.params.merge(sort: 'age'),

0 commit comments

Comments
 (0)