Skip to content

Commit

Permalink
Playground for CSV 784
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed May 1, 2020
1 parent 7e6ee88 commit ddd4d60
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.1'

gem 'jquery-rails', '~> 4.3'
gem 'client_side_validations', '~> 16.2.0'
gem 'client_side_validations', github: 'MichalRemis/client_side_validations', branch: 'SupportDateTimeSelects' # '~> 16.2.0'
gem 'client_side_validations-simple_form', '~> 10.1.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
Expand Down
15 changes: 10 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/MichalRemis/client_side_validations.git
revision: 5fa9a94829831b8714a5458431f54d992f597d9b
branch: SupportDateTimeSelects
specs:
client_side_validations (16.2.0)
js_regex (~> 3.1)
rails (>= 5.0.0.1, < 6.1)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -62,10 +71,6 @@ GEM
builder (3.2.4)
byebug (11.1.3)
character_set (1.4.0)
client_side_validations (16.2.0)
jquery-rails (~> 4.3)
js_regex (~> 3.1)
rails (>= 5.0.0.1, < 6.1)
client_side_validations-simple_form (10.1.0)
client_side_validations (>= 15.0, < 17.0)
simple_form (~> 5.0)
Expand Down Expand Up @@ -200,7 +205,7 @@ PLATFORMS
DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
client_side_validations (~> 16.2.0)
client_side_validations!
client_side_validations-simple_form (~> 10.1.0)
jbuilder (~> 2.7)
jquery-rails (~> 4.3)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
//= require jquery
//= require rails.validations
//= require rails.validations.simple_form
5 changes: 5 additions & 0 deletions app/models/box.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
class Box < ApplicationRecord
validates :name, presence: true
validates :description, presence: true
validates :a_date, presence: true
validates :a_datetime, presence: true
validates :a_time, presence: true
end
9 changes: 5 additions & 4 deletions app/views/boxes/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%= form_with(model: box, local: true) do |form| %>
<h4>Test CSV 784</h4>
<%= form_with(model: box, local: true, validate: true) do |form| %>
<% if box.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(box.errors.count, "error") %> prohibited this box from being saved:</h2>
Expand All @@ -23,17 +24,17 @@

<div class="field">
<%= form.label :a_date %>
<%= form.date_select :a_date %>
<%= form.date_select :a_date, prompt: true %>
</div>

<div class="field">
<%= form.label :a_datetime %>
<%= form.datetime_select :a_datetime %>
<%= form.datetime_select :a_datetime, prompt: true %>
</div>

<div class="field">
<%= form.label :a_time %>
<%= form.time_select :a_time %>
<%= form.time_select :a_time, prompt: true %>
</div>

<div class="actions">
Expand Down
24 changes: 24 additions & 0 deletions app/views/boxes/_simple_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h4>Test CSV 784</h4>
<%= simple_form_for(box, validate: true) do |form| %>
<% if box.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(box.errors.count, "error") %> prohibited this box from being saved:</h2>

<ul>
<% box.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<%= form.input :name %>
<%= form.input :description %>
<%= form.input :a_date, prompt: true %>
<%= form.input :a_datetime, prompt: true %>
<%= form.input :a_time, prompt: true %>

<div class="actions">
<%= form.submit %>
</div>
<% end %>
2 changes: 2 additions & 0 deletions app/views/boxes/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<h1>New Box</h1>

<!-- <%= render 'simple_form', box: @box %> -->

<%= render 'form', box: @box %>

<%= link_to 'Back', boxes_path %>
2 changes: 2 additions & 0 deletions app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<h1>Client Side Validations Playground</h1>

<%= link_to 'CSV 784', new_box_path %>

0 comments on commit ddd4d60

Please sign in to comment.