Sha256: cfd967e588e649ac71d1b0713e9391494da1cc8b2831f6c8f971821f8826caaa

Contents?: true

Size: 1.95 KB

Versions: 15

Compression:

Stored size: 1.95 KB

Contents

<% values = [] %>
<% fields.each do |field_name, type, options| %>
  <% value = component.value_for(field_name) %>

  <% if type == :check_box %>

    <% if ['1', true].include?(value) %>
      <% values << value %>
      <div class="d-inline me-3">
        <i class="text-success fa-regular fa-fw fa-circle-check"></i>
        <span><%= options.fetch(:label) %></span>
      </div>
    <% end %>

  <% elsif type == :select %>
      <% value = component.display_value_for_select(field_name, options) %>
      <% if value.present? %>
        <% values << value %>
        <div class="d-inline me-3">
          <span class="text-secondary"><%= options.fetch(:label) %>:</span>
          <span class="ms-1"><%= value %></span>
        </div>
      <% end %>
  <% elsif type == :datetime_range_field %>
    <% next unless value.present? %>

    <% values << value %>
    <div class="d-inline me-3">
      <span class="text-secondary"><%= options.fetch(:label) %>:</span>
      <span class="ms-1 text-primary"><%= value[:from] %></span>
      <span class="text-secondary">&rarr;</span>
      <span class="ms-1 text-primary"><%= value[:to] %></span>
    </div>
  <% elsif type == :date_range_field %>
    <% next unless value.present? %>

    <% values << value %>
    <div class="d-inline me-3">
      <span class="text-secondary"><%= options.fetch(:label) %>:</span>
      <span class="ms-1 text-primary"><%= value[:from] %></span>
      <span class="text-secondary">&rarr;</span>
      <span class="ms-1 text-primary"><%= value[:to] %></span>
    </div>
  <% elsif value.class && value.present? %>
    <%# TODO: Handle other field types %>

    <% values << value %>
    <div class="d-inline me-3">
      <span class="text-secondary"><%= options.fetch(:label) %>:</span>
      <span class="ms-1"><%= value %></span>
    </div>

  <% end %>
<% end %>

<% if values.empty? %>
  <div class="d-inline ms-3 me-3">
    <span class="fst-italic text-secondary">(No filters applied)</span>
  </div>
<% end %>

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
active_element-0.0.31 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.30 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.29 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.28 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.27 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.26 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.24 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.23 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.22 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.21 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.19 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.18 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.17 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.16 app/views/active_element/components/form/_summary.html.erb
active_element-0.0.15 app/views/active_element/components/form/_summary.html.erb