<% settings = Setting.plugin_redmine_ux_toolkit || {} %>
<% issue_quality_enabled = settings.fetch('enable_issue_quality_check', '0').to_s == '1' %>
<% subject_short_enabled = settings.fetch('issue_quality_check_subject_short', '1').to_s == '1' %>
<% description_empty_enabled = settings.fetch('issue_quality_check_description_empty', '1').to_s == '1' %>
<% description_short_enabled = settings.fetch('issue_quality_check_description_short', '1').to_s == '1' %>
<% assignee_missing_enabled = settings.fetch('issue_quality_check_assignee_missing', '1').to_s == '1' %>
<% priority_missing_enabled = settings.fetch('issue_quality_check_priority_missing', '1').to_s == '1' %>
<% min_subject_length = settings.fetch('issue_quality_min_subject_length', '8').to_i %>
<% min_description_length = settings.fetch('issue_quality_min_description_length', '30').to_i %>
<% min_subject_length = 8 unless (1..1000).cover?(min_subject_length) %>
<% min_description_length = 30 unless (1..1000).cover?(min_description_length) %>

<p>
  <strong><%= l(:label_ux_toolkit_issue_quality) %></strong>
</p>

<p>
  <%= hidden_field_tag 'settings[enable_issue_quality_check]', '0', id: nil %>
  <%= check_box_tag 'settings[enable_issue_quality_check]',
                    '1',
                    issue_quality_enabled,
                    id: 'settings_enable_issue_quality_check' %>
  <%= label_tag 'settings_enable_issue_quality_check',
                l(:label_ux_toolkit_enable_issue_quality_check) %>
  <em class="info"><%= l(:text_ux_toolkit_issue_quality_help) %></em>
</p>

<fieldset class="box">
  <legend><%= l(:label_ux_toolkit_issue_quality_checks) %></legend>

  <p>
    <%= hidden_field_tag 'settings[issue_quality_check_subject_short]', '0', id: nil %>
    <%= check_box_tag 'settings[issue_quality_check_subject_short]',
                      '1',
                      subject_short_enabled,
                      id: 'settings_issue_quality_check_subject_short' %>
    <%= label_tag 'settings_issue_quality_check_subject_short',
                  l(:label_ux_toolkit_issue_quality_check_subject_short) %>
  </p>

  <p>
    <%= hidden_field_tag 'settings[issue_quality_check_description_empty]', '0', id: nil %>
    <%= check_box_tag 'settings[issue_quality_check_description_empty]',
                      '1',
                      description_empty_enabled,
                      id: 'settings_issue_quality_check_description_empty' %>
    <%= label_tag 'settings_issue_quality_check_description_empty',
                  l(:label_ux_toolkit_issue_quality_check_description_empty) %>
  </p>

  <p>
    <%= hidden_field_tag 'settings[issue_quality_check_description_short]', '0', id: nil %>
    <%= check_box_tag 'settings[issue_quality_check_description_short]',
                      '1',
                      description_short_enabled,
                      id: 'settings_issue_quality_check_description_short' %>
    <%= label_tag 'settings_issue_quality_check_description_short',
                  l(:label_ux_toolkit_issue_quality_check_description_short) %>
  </p>

  <p>
    <%= hidden_field_tag 'settings[issue_quality_check_assignee_missing]', '0', id: nil %>
    <%= check_box_tag 'settings[issue_quality_check_assignee_missing]',
                      '1',
                      assignee_missing_enabled,
                      id: 'settings_issue_quality_check_assignee_missing' %>
    <%= label_tag 'settings_issue_quality_check_assignee_missing',
                  l(:label_ux_toolkit_issue_quality_check_assignee_missing) %>
  </p>

  <p>
    <%= hidden_field_tag 'settings[issue_quality_check_priority_missing]', '0', id: nil %>
    <%= check_box_tag 'settings[issue_quality_check_priority_missing]',
                      '1',
                      priority_missing_enabled,
                      id: 'settings_issue_quality_check_priority_missing' %>
    <%= label_tag 'settings_issue_quality_check_priority_missing',
                  l(:label_ux_toolkit_issue_quality_check_priority_missing) %>
  </p>
</fieldset>

<p>
  <%= label_tag 'settings_issue_quality_min_subject_length',
                l(:label_ux_toolkit_issue_quality_min_subject_length) %>
  <%= number_field_tag 'settings[issue_quality_min_subject_length]',
                       min_subject_length,
                       min: 1,
                       max: 1000,
                       id: 'settings_issue_quality_min_subject_length',
                       size: 6 %>
</p>

<p>
  <%= label_tag 'settings_issue_quality_min_description_length',
                l(:label_ux_toolkit_issue_quality_min_description_length) %>
  <%= number_field_tag 'settings[issue_quality_min_description_length]',
                       min_description_length,
                       min: 1,
                       max: 1000,
                       id: 'settings_issue_quality_min_description_length',
                       size: 6 %>
</p>
