binda 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +63 -0
- data/Rakefile +37 -0
- data/app/assets/config/binda_manifest.js +2 -0
- data/app/assets/javascripts/binda/application.js +18 -0
- data/app/assets/javascripts/binda/components/form_item.js +54 -0
- data/app/assets/javascripts/binda/components/form_item_asset.js +24 -0
- data/app/assets/javascripts/binda/components/form_item_repeater.js +66 -0
- data/app/assets/javascripts/binda/components/sortable.js +44 -0
- data/app/assets/javascripts/binda/dist/binda.bundle.js +336 -0
- data/app/assets/javascripts/binda/index.js +16 -0
- data/app/assets/stylesheets/binda/application.css +6 -0
- data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -0
- data/app/assets/stylesheets/binda/components/button.scss +7 -0
- data/app/assets/stylesheets/binda/components/form_body.scss +2 -0
- data/app/assets/stylesheets/binda/components/form_item.scss +169 -0
- data/app/assets/stylesheets/binda/components/form_item_asset.scss +20 -0
- data/app/assets/stylesheets/binda/components/form_section.scss +40 -0
- data/app/assets/stylesheets/binda/components/login.scss +6 -0
- data/app/assets/stylesheets/binda/components/main_container.scss +0 -0
- data/app/assets/stylesheets/binda/components/main_content.scss +5 -0
- data/app/assets/stylesheets/binda/components/main_header.scss +25 -0
- data/app/assets/stylesheets/binda/components/main_table.scss +28 -0
- data/app/assets/stylesheets/binda/components/sidebar.scss +131 -0
- data/app/assets/stylesheets/binda/components/sortable.scss +98 -0
- data/app/assets/stylesheets/binda/index.scss +24 -0
- data/app/assets/stylesheets/binda/layout/components_index.scss +9 -0
- data/app/assets/stylesheets/binda/layout/dashboard.scss +7 -0
- data/app/assets/stylesheets/binda/layout/users_sign_in.scss +29 -0
- data/app/assets/stylesheets/binda/settings/common.scss +93 -0
- data/app/assets/stylesheets/binda/settings/fonts.scss +90 -0
- data/app/assets/stylesheets/binda/settings/variables.scss +83 -0
- data/app/assets/stylesheets/scaffolds.scss +89 -0
- data/app/controllers/binda/application_controller.rb +29 -0
- data/app/controllers/binda/assets_controller.rb +62 -0
- data/app/controllers/binda/bindings_controller.rb +62 -0
- data/app/controllers/binda/categories_controller.rb +60 -0
- data/app/controllers/binda/components_controller.rb +223 -0
- data/app/controllers/binda/dates_controller.rb +62 -0
- data/app/controllers/binda/field_groups_controller.rb +114 -0
- data/app/controllers/binda/field_settings_controller.rb +66 -0
- data/app/controllers/binda/galleries_controller.rb +62 -0
- data/app/controllers/binda/manage/users_controller.rb +97 -0
- data/app/controllers/binda/repeaters_controller.rb +67 -0
- data/app/controllers/binda/settings_controller.rb +75 -0
- data/app/controllers/binda/structures_controller.rb +89 -0
- data/app/controllers/binda/texts_controller.rb +62 -0
- data/app/controllers/binda/users/confirmations_controller.rb +33 -0
- data/app/controllers/binda/users/omniauth_callbacks_controller.rb +33 -0
- data/app/controllers/binda/users/passwords_controller.rb +37 -0
- data/app/controllers/binda/users/registrations_controller.rb +89 -0
- data/app/controllers/binda/users/sessions_controller.rb +30 -0
- data/app/controllers/binda/users/unlocks_controller.rb +33 -0
- data/app/helpers/binda/application_helper.rb +25 -0
- data/app/helpers/binda/assets_helper.rb +4 -0
- data/app/helpers/binda/bindings_helper.rb +4 -0
- data/app/helpers/binda/categories_helper.rb +10 -0
- data/app/helpers/binda/components_helper.rb +10 -0
- data/app/helpers/binda/dates_helper.rb +4 -0
- data/app/helpers/binda/field_groups_helper.rb +10 -0
- data/app/helpers/binda/field_settings_helper.rb +14 -0
- data/app/helpers/binda/galleries_helper.rb +4 -0
- data/app/helpers/binda/repeaters_helper.rb +4 -0
- data/app/helpers/binda/settings_helper.rb +13 -0
- data/app/helpers/binda/structures_helper.rb +4 -0
- data/app/helpers/binda/texts_helper.rb +4 -0
- data/app/jobs/binda/application_job.rb +4 -0
- data/app/mailers/binda/application_mailer.rb +6 -0
- data/app/models/binda/application_record.rb +5 -0
- data/app/models/binda/asset.rb +21 -0
- data/app/models/binda/binding.rb +24 -0
- data/app/models/binda/category.rb +31 -0
- data/app/models/binda/component.rb +186 -0
- data/app/models/binda/date.rb +9 -0
- data/app/models/binda/field_group.rb +40 -0
- data/app/models/binda/field_setting.rb +95 -0
- data/app/models/binda/gallery.rb +18 -0
- data/app/models/binda/repeater.rb +108 -0
- data/app/models/binda/setting.rb +42 -0
- data/app/models/binda/structure.rb +31 -0
- data/app/models/binda/text.rb +9 -0
- data/app/models/binda/user.rb +8 -0
- data/app/uploaders/binda/asset/image_uploader.rb +76 -0
- data/app/views/binda/assets/_form.html.erb +22 -0
- data/app/views/binda/assets/edit.html.erb +6 -0
- data/app/views/binda/assets/index.html.erb +29 -0
- data/app/views/binda/assets/new.html.erb +5 -0
- data/app/views/binda/assets/show.html.erb +19 -0
- data/app/views/binda/bindings/_form.html.erb +32 -0
- data/app/views/binda/bindings/edit.html.erb +6 -0
- data/app/views/binda/bindings/index.html.erb +31 -0
- data/app/views/binda/bindings/new.html.erb +5 -0
- data/app/views/binda/bindings/show.html.erb +19 -0
- data/app/views/binda/categories/_form.html.erb +58 -0
- data/app/views/binda/categories/edit.html.erb +8 -0
- data/app/views/binda/categories/index.html.erb +34 -0
- data/app/views/binda/categories/new.html.erb +8 -0
- data/app/views/binda/components/_form_body.html.erb +86 -0
- data/app/views/binda/components/_form_item_asset.html.erb +20 -0
- data/app/views/binda/components/_form_item_date.html.erb +16 -0
- data/app/views/binda/components/_form_item_gallery.html.erb +0 -0
- data/app/views/binda/components/_form_item_new_repeater.html.erb +33 -0
- data/app/views/binda/components/_form_item_repeater.html.erb +81 -0
- data/app/views/binda/components/_form_item_text.html.erb +28 -0
- data/app/views/binda/components/_form_section.html.erb +37 -0
- data/app/views/binda/components/_form_section_repeater.html.erb +31 -0
- data/app/views/binda/components/_form_sidebar.html.erb +34 -0
- data/app/views/binda/components/edit.html.erb +8 -0
- data/app/views/binda/components/index.html.erb +43 -0
- data/app/views/binda/components/new.html.erb +8 -0
- data/app/views/binda/dates/_form.html.erb +22 -0
- data/app/views/binda/dates/edit.html.erb +6 -0
- data/app/views/binda/dates/index.html.erb +27 -0
- data/app/views/binda/dates/new.html.erb +5 -0
- data/app/views/binda/dates/show.html.erb +9 -0
- data/app/views/binda/field_groups/_form_body.html.erb +71 -0
- data/app/views/binda/field_groups/_form_item.html.erb +62 -0
- data/app/views/binda/field_groups/_form_section.html.erb +37 -0
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +25 -0
- data/app/views/binda/field_groups/edit.html.erb +8 -0
- data/app/views/binda/field_groups/index.html.erb +34 -0
- data/app/views/binda/field_groups/new.html.erb +8 -0
- data/app/views/binda/field_settings/_form_body.html.erb +60 -0
- data/app/views/binda/field_settings/edit.html.erb +8 -0
- data/app/views/binda/field_settings/index.html.erb +31 -0
- data/app/views/binda/field_settings/new.html.erb +8 -0
- data/app/views/binda/galleries/_form.html.erb +27 -0
- data/app/views/binda/galleries/edit.html.erb +6 -0
- data/app/views/binda/galleries/index.html.erb +29 -0
- data/app/views/binda/galleries/new.html.erb +5 -0
- data/app/views/binda/galleries/show.html.erb +14 -0
- data/app/views/binda/manage/users/_admin_manage_user.json.jbuilder +2 -0
- data/app/views/binda/manage/users/_form_body.html.erb +58 -0
- data/app/views/binda/manage/users/edit.html.erb +8 -0
- data/app/views/binda/manage/users/index.html.erb +38 -0
- data/app/views/binda/manage/users/index.json.jbuilder +1 -0
- data/app/views/binda/manage/users/new.html.erb +8 -0
- data/app/views/binda/manage/users/show.json.jbuilder +1 -0
- data/app/views/binda/repeaters/_form.html.erb +27 -0
- data/app/views/binda/repeaters/edit.html.erb +6 -0
- data/app/views/binda/repeaters/index.html.erb +29 -0
- data/app/views/binda/repeaters/new.html.erb +5 -0
- data/app/views/binda/repeaters/show.html.erb +14 -0
- data/app/views/binda/settings/_dashboard_form.html.erb +51 -0
- data/app/views/binda/settings/_form.html.erb +52 -0
- data/app/views/binda/settings/dashboard.html.erb +9 -0
- data/app/views/binda/settings/edit.html.erb +8 -0
- data/app/views/binda/settings/index.html.erb +34 -0
- data/app/views/binda/settings/new.html.erb +8 -0
- data/app/views/binda/structures/_form_body.html.erb +56 -0
- data/app/views/binda/structures/_form_section.html.erb +64 -0
- data/app/views/binda/structures/add_child.html.erb +0 -0
- data/app/views/binda/structures/edit.html.erb +8 -0
- data/app/views/binda/structures/index.html.erb +34 -0
- data/app/views/binda/structures/new.html.erb +8 -0
- data/app/views/binda/texts/_form.html.erb +22 -0
- data/app/views/binda/texts/edit.html.erb +6 -0
- data/app/views/binda/texts/index.html.erb +27 -0
- data/app/views/binda/texts/new.html.erb +5 -0
- data/app/views/binda/texts/show.html.erb +9 -0
- data/app/views/layouts/binda/_flash.html.erb +26 -0
- data/app/views/layouts/binda/_header.html.erb +9 -0
- data/app/views/layouts/binda/_sidebar.html.erb +50 -0
- data/app/views/layouts/binda/application.html.erb +29 -0
- data/app/views/users/confirmations/new.html.erb +16 -0
- data/app/views/users/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/users/mailer/password_change.html.erb +3 -0
- data/app/views/users/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/users/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/users/passwords/edit.html.erb +31 -0
- data/app/views/users/passwords/new.html.erb +28 -0
- data/app/views/users/registrations/edit.html.erb +27 -0
- data/app/views/users/registrations/new.html.erb +17 -0
- data/app/views/users/sessions/new.html.erb +27 -0
- data/app/views/users/shared/_links.html.erb +25 -0
- data/app/views/users/unlocks/new.html.erb +16 -0
- data/config/initializers/assets.rb +3 -0
- data/config/initializers/devise.rb +278 -0
- data/config/initializers/devise_patch.rb +50 -0
- data/config/initializers/friendly_id.rb +88 -0
- data/config/initializers/simple_form.rb +165 -0
- data/config/initializers/simple_form_bootstrap.rb +149 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/locales/en.yml +37 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +67 -0
- data/config/tinymce.yml +15 -0
- data/db/migrate/1_create_binda_tables.rb +172 -0
- data/lib/binda.rb +5 -0
- data/lib/binda/engine.rb +30 -0
- data/lib/binda/version.rb +3 -0
- data/lib/generators/binda/install/USAGE +9 -0
- data/lib/generators/binda/install/install_generator.rb +107 -0
- data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +32 -0
- data/lib/generators/binda/install/templates/config/initializers/devise.rb +280 -0
- data/lib/generators/binda/setup/USAGE +8 -0
- data/lib/generators/binda/setup/setup_generator.rb +43 -0
- data/lib/tasks/binda.rake +25 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- metadata +637 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# - - - - - - - - - - - - - - - - - - - -
|
|
2
|
+
# DEVISE MONKEY PATCH
|
|
3
|
+
# - - - - - - - - - - - - - - - - - - - -
|
|
4
|
+
# - https://github.com/plataformatec/devise/issues/4127#issuecomment-309010663
|
|
5
|
+
# - https://github.com/plataformatec/devise/blob/88724e10adaf9ffd1d8dbfbaadda2b9d40de756a/lib/devise/controllers/helpers.rb#L110-L130
|
|
6
|
+
# - https://github.com/plataformatec/devise/blob/cbbe932ee22947fb7fc741a4da3e6783091c88b0/lib/devise/failure_app.rb#L157
|
|
7
|
+
# - https://github.com/plataformatec/devise/commit/cbbe932ee22947fb7fc741a4da3e6783091c88b0
|
|
8
|
+
|
|
9
|
+
require "action_controller/metal"
|
|
10
|
+
|
|
11
|
+
module Devise
|
|
12
|
+
# Failure application that will be called every time :warden is thrown from
|
|
13
|
+
# any strategy or hook. Responsible for redirect the user to the sign in
|
|
14
|
+
# page based on current scope and mapping. If no scope is given, redirect
|
|
15
|
+
# to the default_url.
|
|
16
|
+
class FailureApp < ActionController::Metal
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
|
|
20
|
+
def scope_url
|
|
21
|
+
opts = {}
|
|
22
|
+
|
|
23
|
+
# Initialize script_name with nil to prevent infinite loops in
|
|
24
|
+
# authenticated mounted engines in rails 4.2 and 5.0
|
|
25
|
+
opts[:script_name] = nil
|
|
26
|
+
|
|
27
|
+
route = route(scope)
|
|
28
|
+
|
|
29
|
+
opts[:format] = request_format unless skip_format?
|
|
30
|
+
|
|
31
|
+
config = Rails.application.config
|
|
32
|
+
|
|
33
|
+
if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
|
|
34
|
+
opts[:script_name] = config.relative_url_root
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
|
|
38
|
+
|
|
39
|
+
context = send(router_name)
|
|
40
|
+
|
|
41
|
+
if context.respond_to?(route)
|
|
42
|
+
context.send(route)
|
|
43
|
+
elsif respond_to?(:root_url)
|
|
44
|
+
root_url(opts)
|
|
45
|
+
else
|
|
46
|
+
"/"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# FriendlyId Global Configuration
|
|
2
|
+
#
|
|
3
|
+
# Use this to set up shared configuration options for your entire application.
|
|
4
|
+
# Any of the configuration options shown here can also be applied to single
|
|
5
|
+
# models by passing arguments to the `friendly_id` class method or defining
|
|
6
|
+
# methods in your model.
|
|
7
|
+
#
|
|
8
|
+
# To learn more, check out the guide:
|
|
9
|
+
#
|
|
10
|
+
# http://norman.github.io/friendly_id/file.Guide.html
|
|
11
|
+
|
|
12
|
+
FriendlyId.defaults do |config|
|
|
13
|
+
# ## Reserved Words
|
|
14
|
+
#
|
|
15
|
+
# Some words could conflict with Rails's routes when used as slugs, or are
|
|
16
|
+
# undesirable to allow as slugs. Edit this list as needed for your app.
|
|
17
|
+
config.use :reserved
|
|
18
|
+
|
|
19
|
+
config.reserved_words = %w(new edit index session login logout users admin
|
|
20
|
+
stylesheets assets javascripts images)
|
|
21
|
+
|
|
22
|
+
# ## Friendly Finders
|
|
23
|
+
#
|
|
24
|
+
# Uncomment this to use friendly finders in all models. By default, if
|
|
25
|
+
# you wish to find a record by its friendly id, you must do:
|
|
26
|
+
#
|
|
27
|
+
# MyModel.friendly.find('foo')
|
|
28
|
+
#
|
|
29
|
+
# If you uncomment this, you can do:
|
|
30
|
+
#
|
|
31
|
+
# MyModel.find('foo')
|
|
32
|
+
#
|
|
33
|
+
# This is significantly more convenient but may not be appropriate for
|
|
34
|
+
# all applications, so you must explicity opt-in to this behavior. You can
|
|
35
|
+
# always also configure it on a per-model basis if you prefer.
|
|
36
|
+
#
|
|
37
|
+
# Something else to consider is that using the :finders addon boosts
|
|
38
|
+
# performance because it will avoid Rails-internal code that makes runtime
|
|
39
|
+
# calls to `Module.extend`.
|
|
40
|
+
#
|
|
41
|
+
# config.use :finders
|
|
42
|
+
#
|
|
43
|
+
# ## Slugs
|
|
44
|
+
#
|
|
45
|
+
# Most applications will use the :slugged module everywhere. If you wish
|
|
46
|
+
# to do so, uncomment the following line.
|
|
47
|
+
#
|
|
48
|
+
# config.use :slugged
|
|
49
|
+
#
|
|
50
|
+
# By default, FriendlyId's :slugged addon expects the slug column to be named
|
|
51
|
+
# 'slug', but you can change it if you wish.
|
|
52
|
+
#
|
|
53
|
+
# config.slug_column = 'slug'
|
|
54
|
+
#
|
|
55
|
+
# When FriendlyId can not generate a unique ID from your base method, it appends
|
|
56
|
+
# a UUID, separated by a single dash. You can configure the character used as the
|
|
57
|
+
# separator. If you're upgrading from FriendlyId 4, you may wish to replace this
|
|
58
|
+
# with two dashes.
|
|
59
|
+
#
|
|
60
|
+
# config.sequence_separator = '-'
|
|
61
|
+
#
|
|
62
|
+
# ## Tips and Tricks
|
|
63
|
+
#
|
|
64
|
+
# ### Controlling when slugs are generated
|
|
65
|
+
#
|
|
66
|
+
# As of FriendlyId 5.0, new slugs are generated only when the slug field is
|
|
67
|
+
# nil, but if you're using a column as your base method can change this
|
|
68
|
+
# behavior by overriding the `should_generate_new_friendly_id` method that
|
|
69
|
+
# FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
|
|
70
|
+
# more like 4.0.
|
|
71
|
+
#
|
|
72
|
+
# config.use Module.new {
|
|
73
|
+
# def should_generate_new_friendly_id?
|
|
74
|
+
# slug.blank? || <your_column_name_here>_changed?
|
|
75
|
+
# end
|
|
76
|
+
# }
|
|
77
|
+
#
|
|
78
|
+
# FriendlyId uses Rails's `parameterize` method to generate slugs, but for
|
|
79
|
+
# languages that don't use the Roman alphabet, that's not usually sufficient.
|
|
80
|
+
# Here we use the Babosa library to transliterate Russian Cyrillic slugs to
|
|
81
|
+
# ASCII. If you use this, don't forget to add "babosa" to your Gemfile.
|
|
82
|
+
#
|
|
83
|
+
# config.use Module.new {
|
|
84
|
+
# def normalize_friendly_id(text)
|
|
85
|
+
# text.to_slug.normalize! :transliterations => [:russian, :latin]
|
|
86
|
+
# end
|
|
87
|
+
# }
|
|
88
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
|
2
|
+
SimpleForm.setup do |config|
|
|
3
|
+
# Wrappers are used by the form builder to generate a
|
|
4
|
+
# complete input. You can remove any component from the
|
|
5
|
+
# wrapper, change the order or even add your own to the
|
|
6
|
+
# stack. The options given below are used to wrap the
|
|
7
|
+
# whole input.
|
|
8
|
+
config.wrappers :default, class: :input,
|
|
9
|
+
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
|
10
|
+
## Extensions enabled by default
|
|
11
|
+
# Any of these extensions can be disabled for a
|
|
12
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
|
13
|
+
# You can make any of these extensions optional by
|
|
14
|
+
# renaming `b.use` to `b.optional`.
|
|
15
|
+
|
|
16
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
|
17
|
+
# and required attributes
|
|
18
|
+
b.use :html5
|
|
19
|
+
|
|
20
|
+
# Calculates placeholders automatically from I18n
|
|
21
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
|
22
|
+
b.use :placeholder
|
|
23
|
+
|
|
24
|
+
## Optional extensions
|
|
25
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
|
26
|
+
# to the input. If so, they will retrieve the values from the model
|
|
27
|
+
# if any exists. If you want to enable any of those
|
|
28
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
|
29
|
+
|
|
30
|
+
# Calculates maxlength from length validations for string inputs
|
|
31
|
+
b.optional :maxlength
|
|
32
|
+
|
|
33
|
+
# Calculates pattern from format validations for string inputs
|
|
34
|
+
b.optional :pattern
|
|
35
|
+
|
|
36
|
+
# Calculates min and max from length validations for numeric inputs
|
|
37
|
+
b.optional :min_max
|
|
38
|
+
|
|
39
|
+
# Calculates readonly automatically from readonly attributes
|
|
40
|
+
b.optional :readonly
|
|
41
|
+
|
|
42
|
+
## Inputs
|
|
43
|
+
b.use :label_input
|
|
44
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
|
45
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
|
46
|
+
|
|
47
|
+
## full_messages_for
|
|
48
|
+
# If you want to display the full error message for the attribute, you can
|
|
49
|
+
# use the component :full_error, like:
|
|
50
|
+
#
|
|
51
|
+
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The default wrapper to be used by the FormBuilder.
|
|
55
|
+
config.default_wrapper = :default
|
|
56
|
+
|
|
57
|
+
# Define the way to render check boxes / radio buttons with labels.
|
|
58
|
+
# Defaults to :nested for bootstrap config.
|
|
59
|
+
# inline: input + label
|
|
60
|
+
# nested: label > input
|
|
61
|
+
config.boolean_style = :nested
|
|
62
|
+
|
|
63
|
+
# Default class for buttons
|
|
64
|
+
config.button_class = 'btn'
|
|
65
|
+
|
|
66
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
|
67
|
+
# :first lists the first message for each field.
|
|
68
|
+
# Use :to_sentence to list all errors for each field.
|
|
69
|
+
# config.error_method = :first
|
|
70
|
+
|
|
71
|
+
# Default tag used for error notification helper.
|
|
72
|
+
config.error_notification_tag = :div
|
|
73
|
+
|
|
74
|
+
# CSS class to add for error notification helper.
|
|
75
|
+
config.error_notification_class = 'error_notification'
|
|
76
|
+
|
|
77
|
+
# ID to add for error notification helper.
|
|
78
|
+
# config.error_notification_id = nil
|
|
79
|
+
|
|
80
|
+
# Series of attempts to detect a default label method for collection.
|
|
81
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
|
82
|
+
|
|
83
|
+
# Series of attempts to detect a default value method for collection.
|
|
84
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
|
85
|
+
|
|
86
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
|
87
|
+
# config.collection_wrapper_tag = nil
|
|
88
|
+
|
|
89
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
|
90
|
+
# config.collection_wrapper_class = nil
|
|
91
|
+
|
|
92
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
|
93
|
+
# defaulting to :span.
|
|
94
|
+
# config.item_wrapper_tag = :span
|
|
95
|
+
|
|
96
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
|
97
|
+
# config.item_wrapper_class = nil
|
|
98
|
+
|
|
99
|
+
# How the label text should be generated altogether with the required text.
|
|
100
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
|
101
|
+
|
|
102
|
+
# You can define the class to use on all labels. Default is nil.
|
|
103
|
+
# config.label_class = nil
|
|
104
|
+
|
|
105
|
+
# You can define the default class to be used on forms. Can be overriden
|
|
106
|
+
# with `html: { :class }`. Defaulting to none.
|
|
107
|
+
# config.default_form_class = nil
|
|
108
|
+
|
|
109
|
+
# You can define which elements should obtain additional classes
|
|
110
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
|
111
|
+
|
|
112
|
+
# Whether attributes are required by default (or not). Default is true.
|
|
113
|
+
# config.required_by_default = true
|
|
114
|
+
|
|
115
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
|
116
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
|
117
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
|
118
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
|
119
|
+
# change this configuration to true.
|
|
120
|
+
config.browser_validations = false
|
|
121
|
+
|
|
122
|
+
# Collection of methods to detect if a file type was given.
|
|
123
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
|
124
|
+
|
|
125
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
|
126
|
+
# to match as key, and the input type that will be used when the field name
|
|
127
|
+
# matches the regexp as value.
|
|
128
|
+
# config.input_mappings = { /count/ => :integer }
|
|
129
|
+
|
|
130
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
|
131
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
|
132
|
+
# config.wrapper_mappings = { string: :prepend }
|
|
133
|
+
|
|
134
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
|
135
|
+
# override default inputs.
|
|
136
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
|
137
|
+
|
|
138
|
+
# Default priority for time_zone inputs.
|
|
139
|
+
# config.time_zone_priority = nil
|
|
140
|
+
|
|
141
|
+
# Default priority for country inputs.
|
|
142
|
+
# config.country_priority = nil
|
|
143
|
+
|
|
144
|
+
# When false, do not use translations for labels.
|
|
145
|
+
# config.translate_labels = true
|
|
146
|
+
|
|
147
|
+
# Automatically discover new inputs in Rails' autoload path.
|
|
148
|
+
# config.inputs_discovery = true
|
|
149
|
+
|
|
150
|
+
# Cache SimpleForm inputs discovery
|
|
151
|
+
# config.cache_discovery = !Rails.env.development?
|
|
152
|
+
|
|
153
|
+
# Default class for inputs
|
|
154
|
+
# config.input_class = nil
|
|
155
|
+
|
|
156
|
+
# Define the default class of the input wrapper of the boolean input.
|
|
157
|
+
config.boolean_label_class = 'checkbox'
|
|
158
|
+
|
|
159
|
+
# Defines if the default input wrapper class should be included in radio
|
|
160
|
+
# collection wrappers.
|
|
161
|
+
# config.include_default_input_wrapper_class = true
|
|
162
|
+
|
|
163
|
+
# Defines which i18n scope will be used in Simple Form.
|
|
164
|
+
# config.i18n_scope = 'simple_form'
|
|
165
|
+
end
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
|
2
|
+
SimpleForm.setup do |config|
|
|
3
|
+
config.error_notification_class = 'alert alert-danger'
|
|
4
|
+
config.button_class = 'btn btn-default'
|
|
5
|
+
config.boolean_label_class = nil
|
|
6
|
+
|
|
7
|
+
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
8
|
+
b.use :html5
|
|
9
|
+
b.use :placeholder
|
|
10
|
+
b.optional :maxlength
|
|
11
|
+
b.optional :pattern
|
|
12
|
+
b.optional :min_max
|
|
13
|
+
b.optional :readonly
|
|
14
|
+
b.use :label, class: 'control-label'
|
|
15
|
+
|
|
16
|
+
b.use :input, class: 'form-control'
|
|
17
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
18
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
22
|
+
b.use :html5
|
|
23
|
+
b.use :placeholder
|
|
24
|
+
b.optional :maxlength
|
|
25
|
+
b.optional :readonly
|
|
26
|
+
b.use :label, class: 'control-label'
|
|
27
|
+
|
|
28
|
+
b.use :input
|
|
29
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
30
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
34
|
+
b.use :html5
|
|
35
|
+
b.optional :readonly
|
|
36
|
+
|
|
37
|
+
b.wrapper tag: 'div', class: 'checkbox' do |ba|
|
|
38
|
+
ba.use :label_input
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
42
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
46
|
+
b.use :html5
|
|
47
|
+
b.optional :readonly
|
|
48
|
+
b.use :label, class: 'control-label'
|
|
49
|
+
b.use :input
|
|
50
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
51
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
55
|
+
b.use :html5
|
|
56
|
+
b.use :placeholder
|
|
57
|
+
b.optional :maxlength
|
|
58
|
+
b.optional :pattern
|
|
59
|
+
b.optional :min_max
|
|
60
|
+
b.optional :readonly
|
|
61
|
+
b.use :label, class: 'col-sm-3 control-label'
|
|
62
|
+
|
|
63
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
|
64
|
+
ba.use :input, class: 'form-control'
|
|
65
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
66
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
71
|
+
b.use :html5
|
|
72
|
+
b.use :placeholder
|
|
73
|
+
b.optional :maxlength
|
|
74
|
+
b.optional :readonly
|
|
75
|
+
b.use :label, class: 'col-sm-3 control-label'
|
|
76
|
+
|
|
77
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
|
78
|
+
ba.use :input
|
|
79
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
80
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
85
|
+
b.use :html5
|
|
86
|
+
b.optional :readonly
|
|
87
|
+
|
|
88
|
+
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
|
|
89
|
+
wr.wrapper tag: 'div', class: 'checkbox' do |ba|
|
|
90
|
+
ba.use :label_input
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
94
|
+
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
99
|
+
b.use :html5
|
|
100
|
+
b.optional :readonly
|
|
101
|
+
|
|
102
|
+
b.use :label, class: 'col-sm-3 control-label'
|
|
103
|
+
|
|
104
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
|
105
|
+
ba.use :input
|
|
106
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
107
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
112
|
+
b.use :html5
|
|
113
|
+
b.use :placeholder
|
|
114
|
+
b.optional :maxlength
|
|
115
|
+
b.optional :pattern
|
|
116
|
+
b.optional :min_max
|
|
117
|
+
b.optional :readonly
|
|
118
|
+
b.use :label, class: 'sr-only'
|
|
119
|
+
|
|
120
|
+
b.use :input, class: 'form-control'
|
|
121
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
122
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
|
126
|
+
b.use :html5
|
|
127
|
+
b.optional :readonly
|
|
128
|
+
b.use :label, class: 'control-label'
|
|
129
|
+
b.wrapper tag: 'div', class: 'form-inline' do |ba|
|
|
130
|
+
ba.use :input, class: 'form-control'
|
|
131
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
|
132
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
# Wrappers for forms and inputs using the Bootstrap toolkit.
|
|
136
|
+
# Check the Bootstrap docs (http://getbootstrap.com)
|
|
137
|
+
# to learn about the different styles for forms and inputs,
|
|
138
|
+
# buttons and other elements.
|
|
139
|
+
config.default_wrapper = :vertical_form
|
|
140
|
+
config.wrapper_mappings = {
|
|
141
|
+
check_boxes: :vertical_radio_and_checkboxes,
|
|
142
|
+
radio_buttons: :vertical_radio_and_checkboxes,
|
|
143
|
+
file: :vertical_file_input,
|
|
144
|
+
boolean: :vertical_boolean,
|
|
145
|
+
datetime: :multi_select,
|
|
146
|
+
date: :multi_select,
|
|
147
|
+
time: :multi_select
|
|
148
|
+
}
|
|
149
|
+
end
|