Skip to content

Commit

Permalink
simple form stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravShah committed Sep 18, 2018
1 parent 65911d2 commit dbda04c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 78 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -27,6 +27,7 @@ gem 'assembly-image'
gem 'assembly-objectfile', '~> 1.7'
gem 'dor-services', '~> 5.29'
gem 'modsulator'
gem 'simple_form'

group :test do
gem 'coveralls', require: false
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Expand Up @@ -444,6 +444,9 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
simple_form (4.0.1)
actionpack (>= 5.0)
activemodel (>= 5.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -545,6 +548,7 @@ DEPENDENCIES
rubocop-rspec
ruby-prof
shoulda-matchers!
simple_form
sqlite3
turbolinks
uglifier
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.scss
Expand Up @@ -17,3 +17,7 @@
background-color: #8c1515;
color: white;
}

abbr[title], abbr[data-original-title] {
text-decoration: none;
}
4 changes: 1 addition & 3 deletions app/controllers/bundle_contexts_controller.rb
@@ -1,6 +1,6 @@
class BundleContextsController < ApplicationController
def index
@bundle_context = BundleContext.new(job_runs: [JobRun.new])
@bundle_context = BundleContext.new(job_runs: [JobRun.new(job_type: "preassembly")], content_structure: "simple_image", content_metadata_creation: "default")
end

def create
Expand All @@ -17,9 +17,7 @@ def create
# TODO: toggle job_type by extra param (#299)
# @job_run = JobRun.create(bundle_context: @bundle_context, job_type: 'discovery_report')
else
p @bundle_context.errors.full_messages
render :index

end
end

Expand Down
96 changes: 22 additions & 74 deletions app/views/bundle_contexts/_yaml_form.erb
@@ -1,77 +1,25 @@
<h3>Complete the YAML form below</h3>
<%= form_with model: @bundle_context, local: true do |form| %>
<%if @bundle_context.errors.any? %>
<h3 class="text-danger">ERRORS</h3>
<% end %>
<div class="row">
<div class="col-5">
<%= form.fields_for :job_runs do |jt| %>
<%= jt.label :job_type %>
<%= jt.select(:job_type, [["Pre Assembly Run", "preassembly"],["Discovery Report", "discovery_report"]]) %>
<% end %>
</div>
</div>
<div class="row">
<div class="col-5">
<%= form.label :project_name %>
<%if @bundle_context.errors.include?(:project_name)%>
<% style = "form_control is-invalid" %>

<div class="invalid-feedback">
<h1> HELLO </h1>
<%= @bundle_context.errors.full_messages_for(:project_name).first %>
</div>
<% else %>
<% style = "form_control" %>
<% end %>
<%= form.text_field :project_name, class: style %>
</div>
</div>
<div class="row">
<div class="col-5">
<%= form.label :content_structure, "Content Structure" %>
<%= form.select :content_structure, options_for_select([
['Simple Image', 'simple_image'],
['Simple Book', 'simple_book'],
['Book as Image','book_as_image'],
['File', 'file'],
['SMPL', 'smpl']
]), class: "form-control" %>
</div>
</div>
<div class="row">
<div class="col-5">
<%= form.label :bundle_dir, "Bundle Directory" %>
<%if @bundle_context.errors.include?(:bundle_dir) %>
<%= form.text_field :bundle_dir, class: "form-control is-invalid" %>
<div class="invalid-feedback">
<h1>HELLO</h1>
<%= @bundle_context.errors.full_messages_for(:bundle_dir).first %>
</div>
<% else %>
<%= form.text_field :bundle_dir, class: "form-control" %>
<% end %>
</div>
</div>
<div class="row">
<div class="col-5">
<%= form.label :staging_style_symlink, "Staging Style Symlink?" %>
<%= form.check_box :staging_style_symlink, class: "form-control" %>
</div>
</div>
<div class="row mt-2">
<div class="col-5">
<%= form.label :content_metadata_creation %>
<%= form.select :content_metadata_creation, options_for_select([
["Default", "default"],

<%= simple_form_for(@bundle_context) do |form| %>
<%= form.simple_fields_for :job_runs do |jt| %>
<%= jt.input :job_type, collection: [["Pre Assembly Run", "preassembly"],["Discovery Report", "discovery_report"]] %>
<% end %>
<%= form.input :project_name %>
<%= form.input :content_structure, collection: [['Simple Image', 'simple_image'],
['Simple Book', 'simple_book'],
['Book as Image','book_as_image'],
['File', 'file'],
['SMPL', 'smpl']] %>
<%= form.input :bundle_dir %>
<%= form.input :staging_style_symlink %>
<%= form.input :content_metadata_creation, collection: [["Default", "default"],
["Filename", "filename"],
["SMPL", "smpl_cm_style"]
]), class: "form-control" %>
</div>
</div>
<div class="row mt-3">
<div class="col-2 ml-5">
<%= submit_tag("Submit", class: "form-control btn-sul-dlss") %>
</div>
</div>
["SMPL", "smpl_cm_style"]] %>
<%= form.button :submit, class: "btn-sul-dlss" %>
<% end %>
6 changes: 5 additions & 1 deletion config/locales/en.yml
Expand Up @@ -30,4 +30,8 @@
# available at http://guides.rubyonrails.org/i18n.html.

en:
hello: "Hello world"
helpers:
submit:
bundle_context:
update: "Submit"
create: "Submit"

0 comments on commit dbda04c

Please sign in to comment.