lfzawacki/musical-artifacts

View on GitHub
app/views/artifacts/_form.html.haml

Summary

Maintainability
Test Coverage
.row

  = link_to t('info.about.new_artifact_url') do
    %i.fa.fa-question-circle
  %span.new-artifact-help
    = t('.new_artifact_help_html', link: t('info.about.new_artifact_url'))

  = form_for(@artifact, html: { class: 'form-inline' }) do |f|

    - if @artifact.errors.any?
      #error_explanation.alert.alert-warning
        %p
          = t('.error', count: @artifact.errors.count)
        %ul
          - @artifact.errors.each do |attribute, message|
            %li
              %span.attribute-error= t("activerecord.attributes.artifact.#{attribute}")
              %span.attribute-message= message

    .row.pad-bottom

      .col-sm-12
        .control-group
          .form-group.col-xs-12.floating-label-form-group.controls
            = f.label :name
            = f.text_field :name, class: 'form-control', placeholder: true

        .control-group
          .form-group.col-xs-12.floating-label-form-group.controls
            = f.label :author
            = f.text_field :author, class: 'form-control', placeholder: true

    .row.pad-top.pad-bottom

      .col-sm-6

        .control-group
          .form-group.col-xs-12
            = f.label :description
            = f.text_area :description, class: 'form-control', rows: '12', placeholder: true

            #epiceditor{data: {:'base-theme' => asset_path("base/epiceditor.css"), :'preview-theme' => asset_path("preview-theme.css"), :'editor-theme' => asset_path("editor-theme.css")}}

      .col-sm-6
        .control-group
          .form-group.col-xs-12.floating-label-form-group.controls
            = f.label :file

            -if @artifact.file.present?
              = @artifact.file.file.identifier

            = f.file_field :file, class: 'btn btn-default btn-file form-control', placeholder: true

          - # Lists of links
          - [:mirrors, :more_info_urls].each do |list|
            .control-group.dynamic-inputs
              .form-group.col-xs-12.floating-label-form-group.controls
                = f.label list
                = f.text_field list, value: @artifact.send(list).try(:join, ','), class: 'dynamic-form-field', placeholder: true

          - # Tags lists list
          - [:software_list, :tag_list, :file_format_list].each do |list|
            .control-group.dynamic-inputs
              .form-group.col-xs-12.floating-label-form-group.controls
                = f.label list
                = f.text_field list, value: @artifact.send(list).join(','), class: 'dynamic-form-field', placeholder: true

    .row.pad-top
      .col-sm-12
        .control-group
          .form-group.col-xs-12.floating-label-form-group.controls
            - grouped_options = [ [t('.free_licenses'), @free_licenses], [t('.non_free_licenses'), @non_free_licenses] ]

            = f.label :license
            = f.select :license_id, grouped_options_for_select(grouped_options, @artifact.license_id), class: 'form-control license-select', placeholder: true

        .control-group
          .form-group.col-xs-12.floating-label-form-group.controls
            = f.label :extra_license_text
            = f.text_area :extra_license_text, class: 'form-control', placeholder: true

    .row.pad-top
      .form-group.col-xs-12
        = f.submit class: 'btn btn-new btn-lg btn-group-justified'