<%
     # Redmine plugin for Document Management System "Features"
     #
     # Karel Pičman <karel.picman@kontron.com>
     #
     # This file is part of Redmine DMSF plugin.
     #
     # Redmine DMSF plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General
     # Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
     # later version.
     #
     # Redmine DMSF plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
     # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
     # more details.
     #
     # You should have received a copy of the GNU General Public License along with Redmine DMSF plugin. If not, see
     # <https://www.gnu.org/licenses/>.
%>

<p>
  <%= content_tag(:label, l(:field_column_names)) %>
  <% columns = DmsfFolder::AVAILABLE_COLUMNS.dup %>
  <% columns.concat(extra_columns) if defined?(extra_columns) %>
  <% index = columns.index(l(:field_project)) %>
  <%# Move Project to the second position %>
  <% if index %>
    <% columns.insert(0, columns.delete_at(index)) %>
  <% end %>
  <% cfs = DmsfFileRevisionCustomField.visible.order(:position) %>
  <% selected_columns = DmsfFolder::DEFAULT_COLUMNS if selected_columns.blank? %>
  <% columns.each_with_index do |column, i| %>
    <%= check_box_tag 'settings[dmsf_columns][]', column, selected_columns.include?(column), id: "dmsf_column_#{i}" %>
    <%= l("label_column_#{column}").capitalize %>
    <br>
  <% end %>
  <% columns = cfs.map{ |c| c.name }
     columns.each_with_index do |column, i| %>
    <%= check_box_tag 'settings[dmsf_columns][]', column, selected_columns.include?(column), id: "dmsf_column_#{i}" %>
    <%= h column.capitalize %>
    <br>
  <% end %>
</p>
