53 lines
1.7 KiB
Elixir
53 lines
1.7 KiB
Elixir
<h2>Filter</h2>
|
|
<%= form_for @changeset, Routes.filter_path(@conn, :update, @changeset.data.id), fn form -> %>
|
|
<div class="form-group">
|
|
<label for="mode">Mode</label>
|
|
<%= select form, :mode, [{"Accept", :accept}, {"Reject", :reject}] %>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="score">Score</label>
|
|
<%= number_input form, :score %>
|
|
</div>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>Property</th>
|
|
<th>Mode</th>
|
|
<th>Param</th>
|
|
<th>Weight</th>
|
|
</tr>
|
|
<%= inputs_for form, :rules, fn p -> %>
|
|
<tr>
|
|
<td>
|
|
<%= select p, :property, [{"URL", :url}, {"Title", :title}, {"Author", :author}, {"Content", :content}] %>
|
|
</td>
|
|
<td>
|
|
<%= select p, :mode, [{"contains", :contains_string}, {"matches regex", :matches_regex}] %>
|
|
</td>
|
|
<td>
|
|
<%= text_input p, :param %>
|
|
</td>
|
|
<td>
|
|
<%= number_input p, :weight %>
|
|
</td>
|
|
<td>
|
|
<%# when nesting form tags, the first nested one seems to get removed %>
|
|
<%# not the first nested one in each row, but the first nested one overall %>
|
|
<%# so we include a dummy form with display: none that gets stripped from the first row %>
|
|
<%# but is present and invisible in subsequent rows %>
|
|
<form style="display: none;"></form>
|
|
<%= form_tag Routes.filter_path(@conn, :remove_rule, @changeset.data.id, [rule_id: p.data.id]), method: :post do %>
|
|
<%= submit "Delete" %>
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</table>
|
|
|
|
<div class="form-group">
|
|
<%= submit "Update Filter" %>
|
|
</div>
|
|
<% end %>
|
|
<%= form_tag Routes.filter_path(@conn, :add_rule, @changeset.data.id), method: :post do %>
|
|
<%= submit "Add Rule" %>
|
|
<% end %> |