<% settings = Setting.plugin_redmine_ux_toolkit || {} %>
<% sla_light_enabled = settings.fetch('enable_sla_light', '0').to_s == '1' %>
<% first_response_hours = settings.fetch('sla_light_first_response_hours', '8').to_i %>
<% resolution_hours = settings.fetch('sla_light_resolution_hours', '72').to_i %>
<% pause_status_ids = Array(settings['sla_light_pause_status_ids']).map(&:to_s) %>
<% first_response_hours = 8 unless (1..10_000).cover?(first_response_hours) %>
<% resolution_hours = 72 unless (1..10_000).cover?(resolution_hours) %>

<div class="ux-toolkit-settings-section">
  <p>
    <strong><%= l(:label_ux_toolkit_sla_light) %></strong>
  </p>

  <p>
    <%= hidden_field_tag 'settings[enable_sla_light]', '0', id: nil %>
    <%= check_box_tag 'settings[enable_sla_light]',
                      '1',
                      sla_light_enabled,
                      id: 'settings_enable_sla_light' %>
    <%= label_tag 'settings_enable_sla_light',
                  l(:label_ux_toolkit_enable_sla_light) %>
    <em class="info"><%= l(:text_ux_toolkit_sla_light_help) %></em>
  </p>

  <p>
    <%= label_tag 'settings_sla_light_first_response_hours',
                  l(:label_ux_toolkit_sla_light_first_response_hours) %>
    <%= number_field_tag 'settings[sla_light_first_response_hours]',
                         first_response_hours,
                         min: 1,
                         max: 10_000,
                         id: 'settings_sla_light_first_response_hours',
                         size: 6 %>
  </p>

  <p>
    <%= label_tag 'settings_sla_light_resolution_hours',
                  l(:label_ux_toolkit_sla_light_resolution_hours) %>
    <%= number_field_tag 'settings[sla_light_resolution_hours]',
                         resolution_hours,
                         min: 1,
                         max: 10_000,
                         id: 'settings_sla_light_resolution_hours',
                         size: 6 %>
  </p>

  <p>
    <%= label_tag 'settings_sla_light_pause_status_ids',
                  l(:label_ux_toolkit_sla_light_pause_statuses) %>
    <%= hidden_field_tag 'settings[sla_light_pause_status_ids][]', '', id: nil %>
    <%= select_tag 'settings[sla_light_pause_status_ids][]',
                   options_from_collection_for_select(IssueStatus.sorted, :id, :name, pause_status_ids),
                   multiple: true,
                   size: [[IssueStatus.count, 8].min, 1].max,
                   id: 'settings_sla_light_pause_status_ids' %>
    <em class="info"><%= l(:text_ux_toolkit_sla_light_pause_statuses_help) %></em>
  </p>
</div>
