Extract on/off status selector into component cell

pull/6001/head
Oliver Günther 7 years ago
parent e6ebfd7279
commit 96fcbca95e
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 16
      app/cells/components/on_off_status_cell.rb
  2. 19
      app/cells/views/components/on_off_status/show.erb

@ -0,0 +1,16 @@
module Components
##
# A language switch and text area for updating a localized text setting.
class OnOffStatusCell < ::RailsCell
options :on_text
options :on_description
options :off_text
options :off_description
options :is_on
def enabled?
!!model[:is_on]
end
end
end

@ -0,0 +1,19 @@
<%# The javscript for this cell is included in `settings.js.erb`. %>
<div class="on-off-status-cell">
<% if enabled? %>
<span class="mobile-otp--2fa-status -enabled">
<%= op_icon 'icon-yes' %>
<%= model[:on_text] %>
</span>
<p>
<%= model[:on_description] %>
</p>
<% else %>
<span class="mobile-otp--2fa-status -disabled">
<%= op_icon 'icon-not-supported' %>
<%= model[:off_text] %>
</span>
<p><%= model[:off_description] %></p>
<% end %>
</div>
Loading…
Cancel
Save