Class: EasyAdmin::Fields::Index::BooleanComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/easy_admin/fields/index/boolean_component.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#field, #form, #record, #value

Instance Method Summary collapse

Methods inherited from BaseComponent

#easy_admin_url_helpers, #helpers, #initialize, #rails_url_helpers

Methods included from EasyAdmin::FieldsHelper

#field_component, #render_field

Methods included from DashboardsHelper

#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes

Constructor Details

This class inherits a constructor from EasyAdmin::Fields::BaseComponent

Instance Method Details

#view_templateObject



5
6
7
8
9
10
11
12
13
# File 'app/components/easy_admin/fields/index/boolean_component.rb', line 5

def view_template
  span(class: badge_classes) do
    if value
      unsafe_raw '<span class="flex items-center"><svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path></svg>Active</span>'
    else
      unsafe_raw '<span class="flex items-center"><svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>Inactive</span>'
    end
  end
end