notify_on 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +37 -0
- data/app/assets/config/notify_on_manifest.js +2 -0
- data/app/assets/javascripts/notify_on/application.js +13 -0
- data/app/assets/stylesheets/notify_on/application.css +15 -0
- data/app/controllers/notify_on/application_controller.rb +5 -0
- data/app/helpers/notify_on/application_helper.rb +4 -0
- data/app/helpers/notify_on/mailer_helper.rb +9 -0
- data/app/jobs/notify_on/application_job.rb +4 -0
- data/app/mailers/notify_on/application_mailer.rb +6 -0
- data/app/mailers/notify_on/notification_mailer.rb +26 -0
- data/app/models/concerns/notify_on/email_support.rb +97 -0
- data/app/models/concerns/notify_on/pusher_support.rb +66 -0
- data/app/models/concerns/notify_on/string_interpolation.rb +39 -0
- data/app/models/notify_on/application_record.rb +5 -0
- data/app/models/notify_on/notification.rb +86 -0
- data/app/views/layouts/notify_on/application.html.erb +17 -0
- data/app/views/notifications/notify.html.erb +9 -0
- data/config/database.travis.yml +4 -0
- data/config/routes.rb +2 -0
- data/lib/generators/notify_on/install_generator.rb +29 -0
- data/lib/generators/templates/notifications.yml +19 -0
- data/lib/generators/templates/notify_on.rb +64 -0
- data/lib/notify_on.rb +29 -0
- data/lib/notify_on/bulk_config.rb +36 -0
- data/lib/notify_on/configuration.rb +22 -0
- data/lib/notify_on/creator.rb +85 -0
- data/lib/notify_on/engine.rb +19 -0
- data/lib/notify_on/notify_on.rb +36 -0
- data/lib/notify_on/receives_notifications.rb +11 -0
- data/lib/notify_on/utilities.rb +13 -0
- data/lib/notify_on/version.rb +3 -0
- data/lib/tasks/notify_on_tasks.rake +4 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/javascripts/application.js +7 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.scss +28 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/controllers/messages_controller.rb +31 -0
- data/spec/dummy/app/helpers/application_helper.rb +8 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/mailers/notification_mailer.rb +15 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/comment.rb +10 -0
- data/spec/dummy/app/models/message.rb +45 -0
- data/spec/dummy/app/models/post.rb +11 -0
- data/spec/dummy/app/models/user.rb +21 -0
- data/spec/dummy/app/views/application/_header.html.erb +44 -0
- data/spec/dummy/app/views/application/home.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +19 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/app/views/messages/_message.html.erb +6 -0
- data/spec/dummy/app/views/messages/index.html.erb +33 -0
- data/spec/dummy/app/views/messages/new.html.erb +5 -0
- data/spec/dummy/app/views/messages/show.html.erb +7 -0
- data/spec/dummy/app/views/notifications/new_message.html.erb +9 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +35 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +12 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +58 -0
- data/spec/dummy/config/environments/production.rb +86 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/devise.rb +274 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy/config/initializers/notify_on.rb +64 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/simple_form.rb +165 -0
- data/spec/dummy/config/initializers/simple_form_bootstrap.rb +149 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +62 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/locales/simple_form.en.yml +31 -0
- data/spec/dummy/config/notifications.yml +20 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +14 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/db/migrate/20160801112429_devise_create_users.rb +42 -0
- data/spec/dummy/db/migrate/20160801130804_create_messages.rb +11 -0
- data/spec/dummy/db/migrate/20160823102904_create_notify_on_notifications.rb +20 -0
- data/spec/dummy/db/migrate/20161021100707_create_comments.rb +11 -0
- data/spec/dummy/db/migrate/20161021100842_create_posts.rb +11 -0
- data/spec/dummy/db/schema.rb +77 -0
- data/spec/dummy/db/seeds.rb +4 -0
- data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/controllers/messages_controller_spec.rb +5 -0
- data/spec/dummy/spec/factories/comments.rb +7 -0
- data/spec/dummy/spec/factories/messages.rb +7 -0
- data/spec/dummy/spec/factories/posts.rb +6 -0
- data/spec/dummy/spec/factories/users.rb +6 -0
- data/spec/dummy/spec/features/send_message_spec.rb +25 -0
- data/spec/dummy/spec/mailers/notify_on/notification_mailer_spec.rb +30 -0
- data/spec/dummy/spec/mailers/previews/notification_mailer_preview.rb +4 -0
- data/spec/dummy/spec/models/comment_spec.rb +22 -0
- data/spec/dummy/spec/models/message_spec.rb +60 -0
- data/spec/dummy/spec/models/post_spec.rb +23 -0
- data/spec/dummy/spec/models/user_spec.rb +21 -0
- data/spec/factories/notify_on_notifications.rb +10 -0
- data/spec/lib/notify_on/configuration_spec.rb +53 -0
- data/spec/mailers/notify_on/notification_mailer_spec.rb +6 -0
- data/spec/mailers/previews/notify_on/notification_mailer_preview.rb +6 -0
- data/spec/models/notify_on/notification_spec.rb +335 -0
- data/spec/rails_helper.rb +95 -0
- data/spec/spec_helper.rb +103 -0
- data/spec/support/feature_helpers.rb +19 -0
- data/spec/support/general_helpers.rb +19 -0
- metadata +543 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains migration options to ease your Rails 5.0 upgrade.
|
4
|
+
#
|
5
|
+
# Read the Rails 5.0 release notes for more info on each option.
|
6
|
+
|
7
|
+
# Enable per-form CSRF tokens. Previous versions had false.
|
8
|
+
Rails.application.config.action_controller.per_form_csrf_tokens = true
|
9
|
+
|
10
|
+
# Enable origin-checking CSRF mitigation. Previous versions had false.
|
11
|
+
Rails.application.config.action_controller.forgery_protection_origin_check = true
|
12
|
+
|
13
|
+
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
|
14
|
+
# Previous versions had false.
|
15
|
+
ActiveSupport.to_time_preserves_timezone = true
|
16
|
+
|
17
|
+
# Require `belongs_to` associations by default. Previous versions had false.
|
18
|
+
Rails.application.config.active_record.belongs_to_required_by_default = true
|
19
|
+
|
20
|
+
# Do not halt callback chains when a callback returns false. Previous versions had true.
|
21
|
+
ActiveSupport.halt_callback_chains_on_return_false = false
|
22
|
+
|
23
|
+
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
|
24
|
+
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Use this file to set your application's configuration for NotifyOn.
|
2
|
+
NotifyOn.configure do |config|
|
3
|
+
|
4
|
+
# ---------------------------------------- Email
|
5
|
+
|
6
|
+
# Email messages are a common way to let a user know they have a new
|
7
|
+
# notification. In some cases, you want that notification to come from another
|
8
|
+
# user. Other times, your system may handle it. Defining a default email
|
9
|
+
# address means that if you don't specify "to" when calling "notify_on", the
|
10
|
+
# default email address will be used.
|
11
|
+
#
|
12
|
+
# config.default_email = 'No Reply <noreply@yourdomain.com>'
|
13
|
+
#
|
14
|
+
# Note: You can use NotifyOn's string interpolation here. It will first
|
15
|
+
# attempt methods on the trigger, and then fallback to the notification.
|
16
|
+
# Therefore, you have access to the "sender" object, and could choose to
|
17
|
+
# default to the sender's email address, like so:
|
18
|
+
#
|
19
|
+
config.default_email = 'NotifyOn <noreply@example.com>'
|
20
|
+
#
|
21
|
+
# You can also override the notification mailer class if you need to add
|
22
|
+
# custom functionality not supported in NotifyOn's NotificationMailer class.
|
23
|
+
#
|
24
|
+
# config.mailer_class = 'NotifyOn::NotificationMailer'
|
25
|
+
#
|
26
|
+
# NotifyOn's email notification service provides the option to use Active Job
|
27
|
+
# to send email messages in the background instead of during the request. If
|
28
|
+
# you enable Active Job, NotifyOn will use your application settings for
|
29
|
+
# Active Job. Learn more at
|
30
|
+
# http://guides.rubyonrails.org/active_job_basics.html
|
31
|
+
#
|
32
|
+
# config.deliver_mail = :now # or :later
|
33
|
+
|
34
|
+
# ---------------------------------------- Pusher
|
35
|
+
|
36
|
+
# Pusher enables you to send notifications in real-time. Learn more about
|
37
|
+
# Pusher at https://pusher.com. If you are going to use Pusher, you need to
|
38
|
+
# include the following values:
|
39
|
+
#
|
40
|
+
config.pusher_app_id = 'my_app_id'
|
41
|
+
config.pusher_key = 'my_key'
|
42
|
+
config.pusher_secret = 'my_secret'
|
43
|
+
#
|
44
|
+
# Note: You may want to use environment-dependent values, not tracked by git,
|
45
|
+
# so your secrets are not exposed. You may choose to use Rails' secrets for
|
46
|
+
# this. For example:
|
47
|
+
#
|
48
|
+
# config.pusher_app_id = Rails.application.secrets.pusher_app_id
|
49
|
+
# config.pusher_key = Rails.application.secrets.pusher_key
|
50
|
+
# config.pusher_secret = Rails.application.secrets.pusher_secret
|
51
|
+
#
|
52
|
+
# While you can configure your Pusher event in each "notify_on" call, you can
|
53
|
+
# also set your default configuration so you don't have to restate it for
|
54
|
+
# every notification.
|
55
|
+
#
|
56
|
+
# config.default_pusher_channel = 'presence_{:env}_notification_{:recipient_id}'
|
57
|
+
# config.default_pusher_event = 'new_notification'
|
58
|
+
#
|
59
|
+
# You can use Pusher by default (which requires the channel and event be set
|
60
|
+
# above). Uncomment the following setting to do so.
|
61
|
+
#
|
62
|
+
# config.use_pusher_by_default = true
|
63
|
+
|
64
|
+
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 = true
|
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
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|