bootstrap_form 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -0
  3. data/.rubocop.yml +3 -2
  4. data/.travis.yml +7 -1
  5. data/CHANGELOG.md +15 -1
  6. data/CONTRIBUTING.md +11 -0
  7. data/Dangerfile +4 -4
  8. data/Gemfile +7 -2
  9. data/OLD-README.md +795 -0
  10. data/README.md +150 -93
  11. data/Rakefile +2 -4
  12. data/bootstrap_form.gemspec +2 -1
  13. data/demo/.postcssrc.yml +3 -0
  14. data/demo/app/assets/config/manifest.js +2 -0
  15. data/demo/app/assets/stylesheets/actiontext.scss +38 -0
  16. data/demo/app/assets/stylesheets/application.scss +1 -0
  17. data/demo/app/helpers/bootstrap_helper.rb +16 -10
  18. data/demo/app/javascript/channels/consumer.js +6 -0
  19. data/demo/app/javascript/channels/index.js +5 -0
  20. data/demo/app/javascript/packs/application.js +11 -0
  21. data/demo/app/models/user.rb +2 -0
  22. data/demo/app/views/active_storage/blobs/_blob.html.erb +14 -0
  23. data/demo/app/views/bootstrap/form.html.erb +2 -1
  24. data/demo/app/views/layouts/application.html.erb +3 -0
  25. data/demo/bin/webpack +15 -0
  26. data/demo/bin/webpack-dev-server +15 -0
  27. data/demo/config/application.rb +2 -3
  28. data/demo/config/environments/development.rb +3 -1
  29. data/demo/config/environments/production.rb +48 -0
  30. data/demo/config/webpack/development.js +5 -0
  31. data/demo/config/webpack/environment.js +3 -0
  32. data/demo/config/webpack/production.js +5 -0
  33. data/demo/config/webpack/test.js +5 -0
  34. data/demo/config/webpacker.yml +92 -0
  35. data/demo/db/schema.rb +63 -18
  36. data/demo/package.json +13 -1
  37. data/demo/test/fixtures/action_text/rich_texts.yml +4 -0
  38. data/demo/yarn.lock +6257 -0
  39. data/lib/bootstrap_form.rb +34 -8
  40. data/lib/bootstrap_form/action_view_extensions/form_helper.rb +71 -0
  41. data/lib/bootstrap_form/components.rb +17 -0
  42. data/lib/bootstrap_form/components/hints.rb +60 -0
  43. data/lib/bootstrap_form/components/labels.rb +56 -0
  44. data/lib/bootstrap_form/components/layout.rb +39 -0
  45. data/lib/bootstrap_form/components/validation.rb +61 -0
  46. data/lib/bootstrap_form/engine.rb +10 -0
  47. data/lib/bootstrap_form/form_builder.rb +54 -524
  48. data/lib/bootstrap_form/form_group.rb +64 -0
  49. data/lib/bootstrap_form/form_group_builder.rb +103 -0
  50. data/lib/bootstrap_form/helpers.rb +9 -0
  51. data/lib/bootstrap_form/helpers/bootstrap.rb +39 -31
  52. data/lib/bootstrap_form/inputs.rb +40 -0
  53. data/lib/bootstrap_form/inputs/base.rb +40 -0
  54. data/lib/bootstrap_form/inputs/check_box.rb +89 -0
  55. data/lib/bootstrap_form/inputs/collection_check_boxes.rb +23 -0
  56. data/lib/bootstrap_form/inputs/collection_radio_buttons.rb +21 -0
  57. data/lib/bootstrap_form/inputs/collection_select.rb +25 -0
  58. data/lib/bootstrap_form/inputs/color_field.rb +14 -0
  59. data/lib/bootstrap_form/inputs/date_field.rb +14 -0
  60. data/lib/bootstrap_form/inputs/date_select.rb +14 -0
  61. data/lib/bootstrap_form/inputs/datetime_field.rb +14 -0
  62. data/lib/bootstrap_form/inputs/datetime_local_field.rb +14 -0
  63. data/lib/bootstrap_form/inputs/datetime_select.rb +14 -0
  64. data/lib/bootstrap_form/inputs/email_field.rb +14 -0
  65. data/lib/bootstrap_form/inputs/file_field.rb +35 -0
  66. data/lib/bootstrap_form/inputs/grouped_collection_select.rb +29 -0
  67. data/lib/bootstrap_form/inputs/inputs_collection.rb +44 -0
  68. data/lib/bootstrap_form/inputs/month_field.rb +14 -0
  69. data/lib/bootstrap_form/inputs/number_field.rb +14 -0
  70. data/lib/bootstrap_form/inputs/password_field.rb +14 -0
  71. data/lib/bootstrap_form/inputs/phone_field.rb +14 -0
  72. data/lib/bootstrap_form/inputs/radio_button.rb +77 -0
  73. data/lib/bootstrap_form/inputs/range_field.rb +14 -0
  74. data/lib/bootstrap_form/inputs/rich_text_area.rb +23 -0
  75. data/lib/bootstrap_form/inputs/search_field.rb +14 -0
  76. data/lib/bootstrap_form/inputs/select.rb +22 -0
  77. data/lib/bootstrap_form/inputs/telephone_field.rb +14 -0
  78. data/lib/bootstrap_form/inputs/text_area.rb +14 -0
  79. data/lib/bootstrap_form/inputs/text_field.rb +14 -0
  80. data/lib/bootstrap_form/inputs/time_field.rb +14 -0
  81. data/lib/bootstrap_form/inputs/time_select.rb +14 -0
  82. data/lib/bootstrap_form/inputs/time_zone_select.rb +22 -0
  83. data/lib/bootstrap_form/inputs/url_field.rb +14 -0
  84. data/lib/bootstrap_form/inputs/week_field.rb +14 -0
  85. data/lib/bootstrap_form/version.rb +1 -1
  86. metadata +79 -6
  87. data/.rubocop_todo.yml +0 -104
  88. data/lib/bootstrap_form/aliasing.rb +0 -35
  89. data/lib/bootstrap_form/helper.rb +0 -52
@@ -0,0 +1 @@
1
+ @import "actiontext";
@@ -3,19 +3,25 @@ module BootstrapHelper
3
3
  form_html = capture(&block)
4
4
 
5
5
  content_tag(:div, class: "example") do
6
- codemirror = content_tag(:div, class: "code", style: "display: none") do
7
- content_tag(:textarea, class: "codemirror") do
8
- HtmlBeautifier.beautify(form_html.strip.gsub(">", ">\n").gsub("<", "\n<"))
9
- end
10
- end
11
-
12
- toggle = content_tag(:button, class: "toggle btn btn-sm btn-info") do
13
- "Show Source Code"
14
- end
15
-
16
6
  concat(form_html)
17
7
  concat(toggle)
18
8
  concat(codemirror)
19
9
  end
20
10
  end
11
+
12
+ private
13
+
14
+ def codemirror(form_html)
15
+ content_tag(:div, class: "code", style: "display: none") do
16
+ content_tag(:textarea, class: "codemirror") do
17
+ HtmlBeautifier.beautify(form_html.strip.gsub(">", ">\n").gsub("<", "\n<"))
18
+ end
19
+ end
20
+ end
21
+
22
+ def toggle
23
+ content_tag(:button, class: "toggle btn btn-sm btn-info") do
24
+ "Show Source Code"
25
+ end
26
+ end
21
27
  end
@@ -0,0 +1,6 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+
4
+ import { createConsumer } from "@rails/actioncable"
5
+
6
+ export default createConsumer()
@@ -0,0 +1,5 @@
1
+ // Load all the channels within this directory and all subdirectories.
2
+ // Channel files must be named *_channel.js.
3
+
4
+ const channels = require.context('.', true, /_channel\.js$/)
5
+ channels.keys().forEach(channels)
@@ -0,0 +1,11 @@
1
+ // This file is automatically compiled by Webpack, along with any other files
2
+ // present in this directory. You're encouraged to place your actual application logic in
3
+ // a relevant structure within app/javascript and only use these pack files to reference
4
+ // that code so it'll be compiled.
5
+
6
+ require("@rails/ujs").start()
7
+ require("turbolinks").start()
8
+ require("@rails/activestorage").start()
9
+ require("channels")
10
+ require("trix")
11
+ require("@rails/actiontext")
@@ -6,4 +6,6 @@ class User < ApplicationRecord
6
6
 
7
7
  has_one :address
8
8
  accepts_nested_attributes_for :address
9
+
10
+ has_rich_text(:life_story) if Rails::VERSION::STRING > "6"
9
11
  end
@@ -0,0 +1,14 @@
1
+ <figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
2
+ <% if blob.representable? %>
3
+ <%= image_tag blob.representation(resize_to_fit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
4
+ <% end %>
5
+
6
+ <figcaption class="attachment__caption">
7
+ <% if caption = blob.try(:caption) %>
8
+ <%= caption %>
9
+ <% else %>
10
+ <span class="attachment__name"><%= blob.filename %></span>
11
+ <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
12
+ <% end %>
13
+ </figcaption>
14
+ </figure>
@@ -1,7 +1,7 @@
1
1
  <h3>Horizontal Form</h3>
2
2
 
3
3
  <%= form_with_source do %>
4
- <%= bootstrap_form_for @user, layout: :horizontal do |form| %>
4
+ <%= bootstrap_form_with model: @user, layout: :horizontal, local: true do |form| %>
5
5
  <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
6
6
  <%= form.password_field :password, placeholder: "Password" %>
7
7
  <%= form.select :status, [['activated', 1], ['blocked', 2]], prompt: "Please Select" %>
@@ -48,6 +48,7 @@
48
48
  <%= form.password_field :password, placeholder: "Password" %>
49
49
  <%= form.check_box :terms, label: "Agree to Terms" %>
50
50
  <%= form.collection_check_boxes :misc, @collection, :id, :street %>
51
+ <%= form.rich_text_area(:life_story) if Rails::VERSION::STRING > "6" %>
51
52
  <%= form.submit %>
52
53
  <% end %>
53
54
  <% end %>
@@ -10,6 +10,9 @@
10
10
 
11
11
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.33.0/codemirror.min.css">
12
12
 
13
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
14
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
15
+
13
16
  <style type="text/css">
14
17
  .example {
15
18
  padding: 1.5em;
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "rubygems"
11
+ require "bundler/setup"
12
+
13
+ require "webpacker"
14
+ require "webpacker/webpack_runner"
15
+ Webpacker::WebpackRunner.run(ARGV)
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "rubygems"
11
+ require "bundler/setup"
12
+
13
+ require "webpacker"
14
+ require "webpacker/dev_server_runner"
15
+ Webpacker::DevServerRunner.run(ARGV)
@@ -9,9 +9,8 @@ module Dummy
9
9
  class Application < Rails::Application
10
10
  # Initialize configuration defaults for originally generated Rails version.
11
11
 
12
- if config.respond_to?(:load_defaults)
13
- config.load_defaults [Rails::VERSION::MAJOR, Rails::VERSION::MINOR].join(".")
14
- end
12
+ config.respond_to?(:load_defaults) &&
13
+ config.load_defaults([Rails::VERSION::MAJOR, Rails::VERSION::MINOR].join("."))
15
14
 
16
15
  config.secret_key_base = "ignore" if config.respond_to?(:secret_key_base)
17
16
 
@@ -1,4 +1,6 @@
1
1
  Rails.application.configure do
2
+ # Verifies that versions and hashed value of the package contents in the project's package.json
3
+ config.webpacker.check_yarn_integrity = true
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
4
6
  # In the development environment your application's code is reloaded on
@@ -14,7 +16,7 @@ Rails.application.configure do
14
16
 
15
17
  # Enable/disable caching. By default caching is disabled.
16
18
  # Run rails dev:cache to toggle caching.
17
- if Rails.root.join("tmp/caching-dev.txt").exist?
19
+ if Rails.root.join("tmp", "caching-dev.txt").exist?
18
20
  config.action_controller.perform_caching = true
19
21
 
20
22
  config.cache_store = :memory_store
@@ -0,0 +1,48 @@
1
+ Rails.application.configure do
2
+ # Verifies that versions and hashed value of the package contents in the project's package.json
3
+ config.webpacker.check_yarn_integrity = false
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # The test environment is used exclusively to run your application's
7
+ # test suite. You never need to work with it otherwise. Remember that
8
+ # your test database is "scratch space" for the test suite and is wiped
9
+ # and recreated between test runs. Don't rely on the data there!
10
+ config.cache_classes = true
11
+
12
+ # Do not eager load code on boot. This avoids loading your whole application
13
+ # just for the purpose of running a single test. If you are using a tool that
14
+ # preloads Rails for running tests, you may have to set it to true.
15
+ config.eager_load = false
16
+
17
+ # Configure public file server for tests with Cache-Control for performance.
18
+ config.public_file_server.enabled = true
19
+ config.public_file_server.headers = {
20
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
21
+ }
22
+
23
+ # Show full error reports and disable caching.
24
+ config.consider_all_requests_local = true
25
+ config.action_controller.perform_caching = false
26
+
27
+ # Raise exceptions instead of rendering exception templates.
28
+ config.action_dispatch.show_exceptions = false
29
+
30
+ # Disable request forgery protection in test environment.
31
+ config.action_controller.allow_forgery_protection = false
32
+
33
+ # Store uploaded files on the local file system in a temporary directory
34
+ config.active_storage.service = :test if config.respond_to?(:active_storage)
35
+
36
+ config.action_mailer.perform_caching = false
37
+
38
+ # Tell Action Mailer not to deliver emails to the real world.
39
+ # The :test delivery method accumulates sent emails in the
40
+ # ActionMailer::Base.deliveries array.
41
+ config.action_mailer.delivery_method = :test
42
+
43
+ # Print deprecation notices to the stderr.
44
+ config.active_support.deprecation = :stderr
45
+
46
+ # Raises error for missing translations
47
+ # config.action_view.raise_on_missing_translations = true
48
+ end
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,3 @@
1
+ const { environment } = require('@rails/webpacker')
2
+
3
+ module.exports = environment
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,92 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_root_path: public
7
+ public_output_path: packs
8
+ cache_path: tmp/cache/webpacker
9
+ check_yarn_integrity: false
10
+ webpack_compile_output: false
11
+
12
+ # Additional paths webpack should lookup modules
13
+ # ['app/assets', 'engine/foo/app/assets']
14
+ resolved_paths: []
15
+
16
+ # Reload manifest.json on all requests so we reload latest compiled packs
17
+ cache_manifest: false
18
+
19
+ # Extract and emit a css file
20
+ extract_css: false
21
+
22
+ static_assets_extensions:
23
+ - .jpg
24
+ - .jpeg
25
+ - .png
26
+ - .gif
27
+ - .tiff
28
+ - .ico
29
+ - .svg
30
+ - .eot
31
+ - .otf
32
+ - .ttf
33
+ - .woff
34
+ - .woff2
35
+ extensions:
36
+ - .mjs
37
+ - .js
38
+ - .sass
39
+ - .scss
40
+ - .css
41
+ - .module.sass
42
+ - .module.scss
43
+ - .module.css
44
+ - .png
45
+ - .svg
46
+ - .gif
47
+ - .jpeg
48
+ - .jpg
49
+
50
+ development:
51
+ <<: *default
52
+ compile: true
53
+
54
+ # Verifies that versions and hashed value of the package contents in the project's package.json
55
+ check_yarn_integrity: true
56
+ # Reference: https://webpack.js.org/configuration/dev-server/
57
+ dev_server:
58
+ https: false
59
+ host: localhost
60
+ port: 3035
61
+ public: localhost:3035
62
+ hmr: false
63
+ # Inline should be set to true if using HMR
64
+ inline: true
65
+ overlay: true
66
+ compress: true
67
+ disable_host_check: true
68
+ use_local_ip: false
69
+ quiet: false
70
+ headers:
71
+ 'Access-Control-Allow-Origin': '*'
72
+ watch_options:
73
+ ignored: '**/node_modules/**'
74
+
75
+
76
+ test:
77
+ <<: *default
78
+ compile: true
79
+
80
+ # Compile test packs to a separate directory
81
+ public_output_path: packs-test
82
+
83
+ production:
84
+ <<: *default
85
+
86
+ # Production depends on precompilation of packs prior to booting for performance.
87
+ compile: false
88
+ # Extract and emit a css file
89
+ extract_css: true
90
+
91
+ # Cache manifest.json for performance
92
+ cache_manifest: true
@@ -1,24 +1,69 @@
1
- ActiveRecord::Schema.define(version: 1) do
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `rails
6
+ # db:schema:load`. When creating a new database, `rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
2
12
 
3
- create_table :addresses, force: :cascade do |t|
4
- t.integer :user_id
5
- t.string :street
6
- t.string :city
7
- t.string :state
8
- t.string :zip_code
9
- t.timestamps
13
+ ActiveRecord::Schema.define(version: 2019_01_26_192508) do
14
+
15
+ create_table "action_text_rich_texts", force: :cascade do |t|
16
+ t.string "name", null: false
17
+ t.text "body", limit: 16777215
18
+ t.string "record_type", null: false
19
+ t.integer "record_id", null: false
20
+ t.datetime "created_at", null: false
21
+ t.datetime "updated_at", null: false
22
+ t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
23
+ end
24
+
25
+ create_table "active_storage_attachments", force: :cascade do |t|
26
+ t.string "name", null: false
27
+ t.string "record_type", null: false
28
+ t.integer "record_id", null: false
29
+ t.integer "blob_id", null: false
30
+ t.datetime "created_at", null: false
31
+ t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
32
+ t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
33
+ end
34
+
35
+ create_table "active_storage_blobs", force: :cascade do |t|
36
+ t.string "key", null: false
37
+ t.string "filename", null: false
38
+ t.string "content_type"
39
+ t.text "metadata"
40
+ t.bigint "byte_size", null: false
41
+ t.string "checksum", null: false
42
+ t.datetime "created_at", null: false
43
+ t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
44
+ end
45
+
46
+ create_table "addresses", force: :cascade do |t|
47
+ t.integer "user_id"
48
+ t.string "street"
49
+ t.string "city"
50
+ t.string "state"
51
+ t.string "zip_code"
52
+ t.datetime "created_at", null: false
53
+ t.datetime "updated_at", null: false
10
54
  end
11
55
 
12
- create_table :users, force: :cascade do |t|
13
- t.string :email
14
- t.string :password
15
- t.text :comments
16
- t.string :status
17
- t.string :misc
18
- t.text :preferences
19
- t.boolean :terms, default: false
20
- t.string :type
21
- t.timestamps
56
+ create_table "users", force: :cascade do |t|
57
+ t.string "email"
58
+ t.string "password"
59
+ t.text "comments"
60
+ t.string "status"
61
+ t.string "misc"
62
+ t.text "preferences"
63
+ t.boolean "terms", default: false
64
+ t.string "type"
65
+ t.datetime "created_at", null: false
66
+ t.datetime "updated_at", null: false
22
67
  end
23
68
 
24
69
  end
@@ -1,5 +1,17 @@
1
1
  {
2
2
  "name": "dummy",
3
3
  "private": true,
4
- "dependencies": {}
4
+ "dependencies": {
5
+ "@rails/actioncable": "^6.0.0-alpha",
6
+ "@rails/actiontext": "^6.0.0-beta1",
7
+ "@rails/activestorage": "^6.0.0-alpha",
8
+ "@rails/ujs": "^6.0.0-alpha",
9
+ "@rails/webpacker": "^4.0.0-rc.7",
10
+ "trix": "^1.0.0",
11
+ "turbolinks": "^5.2.0"
12
+ },
13
+ "version": "0.1.0",
14
+ "devDependencies": {
15
+ "webpack-dev-server": "^3.1.14"
16
+ }
5
17
  }