jshoe/coursequestionbank

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

Summary

Maintainability
Test Coverage
// = form_for(collection, :html => {:class => 'form-inline'}) do |f|
//   = f.label :name
//   = f.text_field :name, :class => 'form-control'
//   = f.label :description
//   = f.text_field :description, :class => 'form-control', :placeholder => 'Write a description'
//   = f.select :color, ['Red', 'Blue', 'Green', 'Yellow', 'Black', 'Purple'], :class => 'form-control'
//   = f.label 'Mark as public?'
//   = f.check_box :is_public, :class => 'form-control'
//   %div.form-group
//     = f.submit 'Update', class: 'btn btn-primary'
//     =link_to collection_path(collection), :class => 'btn btn-default', method: :delete, :confirm => 'Delete this collection?', id: 'Delete' do
//       %span.glyphicon.glyphicon-trash
//       Delete Collection
//     =link_to export_path(:id => collection), :class => 'btn btn-default', id: 'Export' do
//       %span.glyphicon.glyphicon-export
//       Export


- if local_assigns[:new]
  - submit_path = [collections_path, :post]
- else
  - submit_path = [collection_path(:id => collection.id), :put]


= form_tag submit_path[0], :method => submit_path[1], :class => 'collection_form form-horizontal' do
  
  %div.form-group
    = label_tag :name, 'Name:', :class => 'col-xs-12 col-sm-2 control-label'
    %div.col-xs-12.col-sm-10
      = text_field_tag :name, collection.name, :id => nil, :class => 'form-control', :placeholder => 'Collection name'
  
  %div.form-group
    = label_tag :description, 'Description:', :class => 'col-xs-12 col-sm-2 control-label'
    %div.col-xs-12.col-sm-8
      = text_area_tag :description, collection.description, :id => nil, :class => 'form-control', :placeholder => 'Write a description'
  
  %div.form-group
    %div.col-sm-2
    %div.col-xs-12.col-sm-10
      = select_tag :privacy, privacy_options(collection.is_public), :id => nil, :class => 'form-control'
  
  // %div.form-group
  //   = label_tag :is_public, 'Public:', :class => 'col-xs-12 col-sm-2 control-label'
  //   %div.col-xs-12.col-sm-8
  //     = check_box_tag :is_public, 1, collection.is_public, :id => nil, :class => 'checkbox'
  
  %div.form-group
    %div.col-sm-2
    %div.col-sm-10.col-xs-12
      = submit_tag (local_assigns[:new] ? 'Create' : 'Update'), :class => 'btn btn-primary'