- if defined?(Foundation)
  = page_title :index, SourceFile
  .row
    = simple_form_for(SourceFile.new) do |f|
      .small-6.medium-4.columns
        .form-inputs= f.input :sti_type, collection: SourceFile.classes.select{|cls| can? :manage, cls}.map{|cls| [cls.model_name.human, cls.name]}, include_blank: '', input_html: {class: 'smart-select'}
      .small-6.medium-4.columns= f.input :original_file, as: :file
      .small-6.medium-4.columns= f.submit t('action.new.label', model: SourceFile.model_name.human), class: 'button'
  hr
  table.source_files
    thead
      = search_form_for @q do |f|
        = hidden_field_tag :per_page, params[:per_page], id: 'q_per_page'
        tr
          th= at :sti_type
          th= at :name
          th= at :state
          th= sort_link @q, :created_at
          th= at :creator
          th.actions
            i.icon-search
            = search_result_info @source_files
        = search_row do
          th= f.select :sti_type_eq, SourceFile.classes.select{|cls| can? :read, cls}.map{|cls| [cls.model_name.human, cls.name]}, {include_blank: ' - '}, class: 'smart-select'
          th= f.text_field :original_file_cont, placeholder: 'filename contains'
          th= f.select :state_eq, SourceFile.distinct.pluck(:state), {include_blank: ' - '}, {class: 'input-small'}
          th
            = f.text_field "created_at_gteq", placeholder: 'min', class: 'datepicker input-small'
            = f.text_field "created_at_lteq", placeholder: 'max', class: 'datepicker input-small'
          th
          th.column-filter.actions
            = f.submit t('dunlop.filter.apply').html_safe, class: 'submit-filters-button'
            = link_to dunlop.source_files_path(reset_q: true), class: 'clear-filters-button' do
              span== t('dunlop.filter.reset')

    tbody
      - @source_files.each do |source_file|
        - next unless can? :read, source_file
        tr
          td= link_to source_file.model_name.human, dunlop.source_file_path(source_file)
          td= source_file.original_file.file.try :identifier
          td= source_file.human_state_name
          td data-time=source_file.created_at.iso8601 data-format="LLL"
          td= link_to_model source_file.creator
          td.actions
            = table_show_link source_file, dunlop.source_file_path(source_file)
            = table_download_link source_file, dunlop.download_source_file_path(source_file)
            = table_destroy_link source_file, dunlop.source_file_path(source_file)

  = paginate @source_files
- else
  .ui.container
    = page_title :index, SourceFile
    .ui.horizontal.divider Nieuwe toevoegen
    = simple_form_for SourceFile.new, class: 'form' do |f|
      .ui.three.column.grid
        .column= f.input :sti_type, collection: SourceFile.classes.select{|cls| can? :manage, cls}.map{|cls| [cls.model_name.human, cls.name]}, include_blank: '', input_html: {class: 'smart-select'}
        .column= f.input :original_file, as: :file
        .column= f.submit t('action.new.label', model: SourceFile.model_name.human), class: 'ui button'
    .ui.horizontal.divider= SourceFile.model_name.human_plural
    = search_form_for(@q, html: {class: 'ui form'}) do |f|
      table.source_files.ui.compact.striped.table
        thead
          = hidden_field_tag :per_page, params[:per_page], id: 'q_per_page'
          tr
            th= at :sti_type
            th= at :name
            th= at :state
            th= sort_link @q, :created_at
            th= at :creator
            th.actions
              i.icon-search
              = search_result_info @source_files
          = search_row do
            th= f.select :sti_type_eq, SourceFile.classes.select{|cls| can? :read, cls}.map{|cls| [cls.model_name.human, cls.name]}, {include_blank: ' - '}, class: 'smart-select'
            th= f.text_field :original_file_cont, placeholder: 'filename contains'
            th= f.select :state_eq, SourceFile.distinct.pluck(:state), {include_blank: ' - '}, {class: 'input-small'}
            th
              .ui.mini.datepicker.input= f.text_field "created_at_gteq", placeholder: 'min'
              .ui.mini.datepicker.input= f.text_field "created_at_lteq", placeholder: 'max'
            th
            th.column-filter.actions
              button.ui.small.primary.icon.button.submit-filters-button
                i.filter.icon
              = link_to dunlop.source_files_path(reset_q: true), class: 'clear-filters-button ui basic yellow small icon button'
                i.undo.icon
        tbody
          - @source_files.each do |source_file|
            - next unless can? :read, source_file
            tr
              td= link_to source_file.model_name.human, dunlop.source_file_path(source_file)
              td= source_file.original_file.file.try :identifier
              td= source_file.human_state_name
              td data-time=source_file.created_at.iso8601 data-format="LLL"
              td= link_to_model source_file.creator
              td.actions
                = table_show_link source_file, dunlop.source_file_path(source_file)
                = table_download_link source_file, dunlop.download_source_file_path(source_file)
                = table_destroy_link source_file, dunlop.source_file_path(source_file)

    = paginate @source_files
