<% settings = Setting.plugin_redmine_ux_toolkit || {} %>
<% recent_issues_limit = UxToolkitRecentIssue::ALLOWED_LIMITS.include?(settings['recent_issues_limit'].to_i) ? settings['recent_issues_limit'].to_i : UxToolkitRecentIssue::DEFAULT_LIMIT %>
<% recent_projects_limit = UxToolkitRecentProject::ALLOWED_LIMITS.include?(settings['recent_projects_limit'].to_i) ? settings['recent_projects_limit'].to_i : UxToolkitRecentProject::DEFAULT_LIMIT %>
<% show_recent_issues_in_sidebar = settings.fetch('show_recent_issues_in_sidebar', '1').to_s == '1' %>
<% show_recent_projects_in_sidebar = settings.fetch('show_recent_projects_in_sidebar', '1').to_s == '1' %>

<div class="ux-toolkit-settings-group">
  <header class="ux-toolkit-settings-group-header">
    <h3><%= l(:label_ux_toolkit_settings_group_recent_history) %></h3>
    <p><%= l(:text_ux_toolkit_settings_group_recent_history) %></p>
  </header>
  <div class="ux-toolkit-settings-group-body">
    <div class="ux-toolkit-settings-section">
      <p>
        <strong><%= l(:label_ux_toolkit_recently_visited_issues) %></strong>
      </p>

      <p>
        <%= label_tag 'settings_recent_issues_limit',
                      l(:label_ux_toolkit_recent_issues_limit) %>
        <%= select_tag 'settings[recent_issues_limit]',
                       options_for_select(UxToolkitRecentIssue::ALLOWED_LIMITS.map { |limit| [limit, limit] }, recent_issues_limit),
                       id: 'settings_recent_issues_limit' %>
        <em class="info"><%= l(:text_ux_toolkit_recent_issues_limit_help) %></em>
      </p>

      <p>
        <%= hidden_field_tag 'settings[show_recent_issues_in_sidebar]', '0', id: nil %>
        <%= check_box_tag 'settings[show_recent_issues_in_sidebar]',
                          '1',
                          show_recent_issues_in_sidebar,
                          id: 'settings_show_recent_issues_in_sidebar' %>
        <%= label_tag 'settings_show_recent_issues_in_sidebar',
                      l(:label_ux_toolkit_show_recent_issues_in_sidebar) %>
        <em class="info"><%= l(:text_ux_toolkit_show_recent_issues_in_sidebar_help) %></em>
      </p>
    </div>

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

      <p>
        <%= label_tag 'settings_recent_projects_limit',
                      l(:label_ux_toolkit_recent_projects_limit) %>
        <%= select_tag 'settings[recent_projects_limit]',
                       options_for_select(UxToolkitRecentProject::ALLOWED_LIMITS.map { |limit| [limit, limit] }, recent_projects_limit),
                       id: 'settings_recent_projects_limit' %>
        <em class="info"><%= l(:text_ux_toolkit_recent_projects_limit_help) %></em>
      </p>

      <p>
        <%= hidden_field_tag 'settings[show_recent_projects_in_sidebar]', '0', id: nil %>
        <%= check_box_tag 'settings[show_recent_projects_in_sidebar]',
                          '1',
                          show_recent_projects_in_sidebar,
                          id: 'settings_show_recent_projects_in_sidebar' %>
        <%= label_tag 'settings_show_recent_projects_in_sidebar',
                      l(:label_ux_toolkit_show_recent_projects_in_sidebar) %>
        <em class="info"><%= l(:text_ux_toolkit_show_recent_projects_in_sidebar_help) %></em>
      </p>
    </div>
  </div>
</div>
