amélioration d'affichage sur les filtres

This commit is contained in:
Jérémy Lecour 2021-03-03 13:58:51 +01:00 committed by Jérémy Lecour
parent edeed58ac7
commit e922f532bb
8 changed files with 110 additions and 80 deletions

View file

@ -1,32 +1,32 @@
<div id="<%= dom_id condition %>">
<div id="<%= dom_id condition %>" class="flex flex-cols">
<p>
<div class="flex-auto text-left">
<strong>Enabled:</strong>
<%= condition.enabled %>
</p>
</div>
<p>
<div class="flex-auto text-left">
<strong>Property type:</strong>
<%= condition.property_type %>
</p>
</div>
<p>
<div class="flex-auto text-left">
<strong>Property value:</strong>
<%= condition.property_value %>
</p>
</div>
<p>
<div class="flex-auto text-left">
<strong>Test method:</strong>
<%= condition.test_method %>
</p>
</div>
<p>
<div class="flex-auto text-left">
<strong>Test value:</strong>
<%= condition.test_value %>
</p>
</div>
<p>
<div class="flex-auto text-left">
<strong>Inverted:</strong>
<%= condition.inverted %>
</p>
</div>
</div>

View file

@ -14,7 +14,10 @@
<div class="field">
<%= form.label :enabled %>
<%= form.check_box :enabled %>
<%= form.radio_button :enabled, true %>
<%= form.label :enabled_true, "Yes" %>
<%= form.radio_button :enabled, false %>
<%= form.label :enabled_false, "No" %>
</div>
<div class="field">
@ -39,7 +42,10 @@
<div class="field">
<%= form.label :inverted %>
<%= form.check_box :inverted %>
<%= form.radio_button :inverted, true %>
<%= form.label :inverted_true, "Yes" %>
<%= form.radio_button :inverted, false %>
<%= form.label :inverted_false, "No" %>
</div>
<div class="actions">

View file

@ -1,27 +1,33 @@
<div id="<%= dom_id filter %>" class="filter-<%= filter.enabled? ? 'enabled' : 'disabled' %> flex flex-row bg-green-500">
<div id="<%= dom_id filter %>" class="<%= filter.enabled? ? 'filter--enabled' : 'filter--disabled' %> flex space-x-2 bg-green-500">
<div class="flex flex-grow bg-yellow-500">
<div class="flex-auto bg-yellow-500">
<strong class="pr-1">Description:</strong>
<%= filter.description || "<i>No description</i>" %>
</div>
<div class="flex flex-grow bg-yellow-500">
<div class="flex-auto bg-yellow-500">
<strong class="pr-1">Operator:</strong>
<%= filter.operator %>
</div>
<div class="flex flex-grow bg-yellow-500">
<div class="flex-auto bg-yellow-500">
<strong class="pr-1">Inverted:</strong>
<%= filter.inverted? ? 'Yes' : 'No' %>
</div>
<div class="flex flex-grow-0 flex-col bg-gray-500">
<%= link_to 'Edit', edit_filter_path(@filter), class: "flex items-center" %>
<%= button_to 'Delete', @filter, method: :delete, data: { confirm: 'Are you sure?' }, class: "flex items-center" %>
<% if filter.enabled? %>
<%= button_to 'Disable', filter_disable_path(@filter), data: { method: :patch }, class: "flex items-center" %>
<% else %>
<%= button_to 'Enable', filter_enable_path(@filter), data: { method: :patch }, class: "flex items-center" %>
<% end %>
<div class="flex-none bg-gray-500 text-center">
<div class="">
<%= link_to 'Edit', edit_filter_path(@filter) %>
</div>
<div class="">
<%= link_to 'Delete', @filter, method: :delete, data: { confirm: 'Are you sure you want to delete this filter?' } %>
</div>
<div class="">
<% if filter.enabled? %>
<%= link_to 'Disable', disable_filter_path(@filter), data: { method: :patch, confirm: 'Are you sure you want to disable this filter?' } %>
<% else %>
<%= link_to 'Enable', enable_filter_path(@filter), data: { method: :patch, confirm: 'Are you sure you want to enable this filter?' } %>
<% end %>
</div>
</div>
</div>

View file

@ -1,37 +1,48 @@
<%= form_with(model: filter) do |form| %>
<% if filter.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(filter.errors.count, "error") %> prohibited this filter from being saved:</h2>
<%= turbo_frame_tag "filter" do %>
<%= form_with(model: filter) do |form| %>
<% if filter.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(filter.errors.count, "error") %> prohibited this filter from being saved:</h2>
<ul>
<% filter.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
<ul>
<% filter.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= form.label :description %>
<%= form.text_field :description %>
</div>
<div class="field">
<%= form.label :enabled %>
<%= form.radio_button :enabled, true %>
<%= form.label :enabled_true, "Yes" %>
<%= form.radio_button :enabled, false %>
<%= form.label :enabled_false, "No" %>
</div>
<div class="field">
<%= form.label :operator %>
<%= form.radio_button :operator, "AND" %>
<%= form.label :operator_and, "AND" %>
<%= form.radio_button :operator, "OR" %>
<%= form.label :operator_or, "OR" %>
</div>
<div class="field">
<%= form.label :inverted %>
<%= form.radio_button :inverted, true %>
<%= form.label :inverted_true, "Yes" %>
<%= form.radio_button :inverted, false %>
<%= form.label :inverted_false, "No" %>
</div>
<div class="actions">
<%= form.submit %>
</div>
<% end %>
<div class="field">
<%= form.label :description %>
<%= form.text_field :description %>
</div>
<div class="field">
<%= form.label :enabled %>
<%= form.check_box :enabled %>
</div>
<div class="field">
<%= form.label :operator %>
<%= form.text_field :operator %>
</div>
<div class="field">
<%= form.label :inverted %>
<%= form.check_box :inverted %>
</div>
<div class="actions">
<%= form.submit %>
</div>
<% end %>
<% end %>

View file

@ -11,15 +11,19 @@
<% end %>
<div id="conditions">
<h2>Conditions</h2>
<%= render(@filter.conditions) || "No conditions yet" %>
<h2 class="text-xl py-1 font-semibold">Conditions</h2>
<%= render(@filter.conditions) || "<i class='italic'>No conditions yet</i>" %>
</div>
<%= turbo_frame_tag "new_condition", src: new_filter_condition_path(@filter), target: "_top" %>
<%= turbo_frame_tag "new_condition" do %>
<%= link_to "Add a new condition", new_filter_condition_path(@filter) %>
<% end %>
<div id="operations">
<h2>Operations</h2>
<%= render(@filter.operations) || "No operations yet" %>
<h2 class="text-xl py-1 font-semibold">Operations</h2>
<%= render(@filter.operations) || "<i class='italic'>No operations yet</i>" %>
</div>
<%= turbo_frame_tag "new_operation", src: new_filter_operation_path(@filter), target: "_top" %>
<%= turbo_frame_tag "new_operation" do %>
<%= link_to "Add a new operation", new_filter_operation_path(@filter) %>
<% end %>

View file

@ -14,7 +14,10 @@
<div class="field">
<%= form.label :enabled %>
<%= form.check_box :enabled %>
<%= form.radio_button :enabled, true %>
<%= form.label :enabled_true, "Yes" %>
<%= form.radio_button :enabled, false %>
<%= form.label :enabled_false, "No" %>
</div>
<div class="field">

View file

@ -1,17 +1,17 @@
<div id="<%= dom_id operation %>">
<div id="<%= dom_id operation %>" class="flex flex-cols">
<p>
<strong>Enabled:</strong>
<div class="flex-auto text-left">
<strong class="pr-1">Enabled:</strong>
<%= operation.enabled %>
</p>
</div>
<p>
<strong>Class name:</strong>
<div class="flex-auto text-left">
<strong class="pr-1">Class name:</strong>
<%= operation.class_name %>
</p>
</div>
<p>
<strong>Argument:</strong>
<div class="flex-auto text-left">
<strong class="pr-1">Argument:</strong>
<%= operation.argument %>
</p>
</div>
</div>

View file

@ -6,8 +6,8 @@ Rails.application.routes.draw do
resources :emails
resources :metadata_mappings
resources :filters do
patch :enable
patch :disable
patch :enable, on: :member
patch :disable, on: :member
resources :conditions
resources :operations
end