From dbda04ce5f290b0432f801f347eeafb127bb47cc Mon Sep 17 00:00:00 2001 From: Sarav Shah Date: Tue, 18 Sep 2018 13:32:59 -0700 Subject: [PATCH] simple form stuff --- Gemfile | 1 + Gemfile.lock | 4 + app/assets/stylesheets/application.scss | 4 + app/controllers/bundle_contexts_controller.rb | 4 +- app/views/bundle_contexts/_yaml_form.erb | 96 +++++-------------- config/locales/en.yml | 6 +- 6 files changed, 37 insertions(+), 78 deletions(-) diff --git a/Gemfile b/Gemfile index 1c5579542..6f6cd81e1 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 2c65ef94c..f2467fc6f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -545,6 +548,7 @@ DEPENDENCIES rubocop-rspec ruby-prof shoulda-matchers! + simple_form sqlite3 turbolinks uglifier diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a1086b8be..af93396a2 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -17,3 +17,7 @@ background-color: #8c1515; color: white; } + +abbr[title], abbr[data-original-title] { + text-decoration: none; +} \ No newline at end of file diff --git a/app/controllers/bundle_contexts_controller.rb b/app/controllers/bundle_contexts_controller.rb index 8925ee86d..170bdbc9d 100644 --- a/app/controllers/bundle_contexts_controller.rb +++ b/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 @@ -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 diff --git a/app/views/bundle_contexts/_yaml_form.erb b/app/views/bundle_contexts/_yaml_form.erb index 72150c7da..e4ffd3c2b 100644 --- a/app/views/bundle_contexts/_yaml_form.erb +++ b/app/views/bundle_contexts/_yaml_form.erb @@ -1,77 +1,25 @@

Complete the YAML form below

-<%= form_with model: @bundle_context, local: true do |form| %> - <%if @bundle_context.errors.any? %> -

ERRORS

- <% end %> -
-
- <%= form.fields_for :job_runs do |jt| %> - <%= jt.label :job_type %> - <%= jt.select(:job_type, [["Pre Assembly Run", "preassembly"],["Discovery Report", "discovery_report"]]) %> - <% end %> -
-
-
-
- <%= form.label :project_name %> - <%if @bundle_context.errors.include?(:project_name)%> - <% style = "form_control is-invalid" %> - -
-

HELLO

- <%= @bundle_context.errors.full_messages_for(:project_name).first %> -
- <% else %> - <% style = "form_control" %> - <% end %> - <%= form.text_field :project_name, class: style %> -
-
-
-
- <%= 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" %> -
-
-
-
- <%= form.label :bundle_dir, "Bundle Directory" %> - <%if @bundle_context.errors.include?(:bundle_dir) %> - <%= form.text_field :bundle_dir, class: "form-control is-invalid" %> -
-

HELLO

- <%= @bundle_context.errors.full_messages_for(:bundle_dir).first %> -
- <% else %> - <%= form.text_field :bundle_dir, class: "form-control" %> - <% end %> -
-
-
-
- <%= form.label :staging_style_symlink, "Staging Style Symlink?" %> - <%= form.check_box :staging_style_symlink, class: "form-control" %> -
-
-
-
- <%= 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" %> -
-
-
-
- <%= submit_tag("Submit", class: "form-control btn-sul-dlss") %> -
-
+ ["SMPL", "smpl_cm_style"]] %> + <%= form.button :submit, class: "btn-sul-dlss" %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index decc5a857..da79c85a3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,4 +30,8 @@ # available at http://guides.rubyonrails.org/i18n.html. en: - hello: "Hello world" + helpers: + submit: + bundle_context: + update: "Submit" + create: "Submit" \ No newline at end of file