standard_view 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -10
- data/Rakefile +3 -8
- data/app/helpers/standard_view/application_helper.rb +38 -0
- data/app/helpers/standard_view/badge_helper.rb +22 -0
- data/app/helpers/standard_view/flash_helper.rb +16 -0
- data/app/helpers/standard_view/formatting_helper.rb +21 -0
- data/app/helpers/standard_view/masthead_helper.rb +27 -0
- data/app/helpers/standard_view/navigation_helper.rb +51 -0
- data/app/views/application/_attributes_card.html.erb +32 -0
- data/app/views/application/_flash_messages.html.erb +7 -0
- data/app/views/application/_icon.html.erb +5 -0
- data/app/views/application/_javascripts.html.erb +25 -0
- data/app/views/application/_list_item.html.erb +11 -0
- data/app/views/application/_masthead.html.erb +21 -0
- data/app/views/application/_masthead_brand.html.erb +1 -0
- data/app/views/application/_masthead_nav.html.erb +6 -0
- data/app/views/application/_masthead_nav_items.html.erb +8 -0
- data/app/views/application/_masthead_nav_menu.html.erb +8 -0
- data/app/views/application/_masthead_nav_menu_icon.html.erb +1 -0
- data/app/views/application/_masthead_nav_menu_items.html.erb +10 -0
- data/app/views/application/_stylesheet_font_awesome.html.erb +6 -0
- data/app/views/application/_stylesheets.html.erb +12 -0
- data/app/views/application/index.html.erb +1 -0
- data/app/views/application/show.html.erb +1 -0
- data/app/views/layouts/standard_view/application.html.erb +8 -7
- data/app/views/standard_view/_breadcrumbs.html.erb +48 -0
- data/app/views/standard_view/_index.html.erb +83 -0
- data/app/views/standard_view/_list_item.html.erb +29 -0
- data/app/views/standard_view/_navigation_aside.html.erb +5 -0
- data/app/views/standard_view/_navigation_tabs.html.erb +5 -0
- data/app/views/standard_view/_page_content.html.erb +8 -0
- data/app/views/standard_view/_paginated_collection.html.erb +8 -0
- data/app/views/standard_view/_show.html.erb +48 -0
- data/config/initializers/material.rb +9 -0
- data/config/initializers/simple_form.rb +184 -0
- data/config/initializers/simple_form_bootstrap.rb +457 -0
- data/config/initializers/will_paginate.rb +57 -0
- data/config/locales/en.yml +12 -0
- data/lib/standard_view/engine.rb +11 -0
- data/lib/standard_view/version.rb +3 -1
- data/lib/standard_view.rb +7 -3
- metadata +169 -21
- data/app/assets/config/standard_view_manifest.js +0 -2
- data/app/assets/javascripts/standard_view/application.js +0 -14
- data/app/assets/stylesheets/standard_view/application.css +0 -15
- data/app/controllers/standard_view/application_controller.rb +0 -5
- data/app/jobs/standard_view/application_job.rb +0 -4
- data/app/mailers/standard_view/application_mailer.rb +0 -6
- data/app/models/standard_view/application_record.rb +0 -5
@@ -0,0 +1,457 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "simple_form"
|
4
|
+
|
5
|
+
# Please do not make direct changes to this file!
|
6
|
+
# This generator is maintained by the community around simple_form-bootstrap:
|
7
|
+
# https://github.com/rafaelfranca/simple_form-bootstrap
|
8
|
+
# All future development, tests, and organization should happen there.
|
9
|
+
# Background history: https://github.com/plataformatec/simple_form/issues/1561
|
10
|
+
|
11
|
+
# Uncomment this and change the path if necessary to include your own
|
12
|
+
# components.
|
13
|
+
# See https://github.com/plataformatec/simple_form#custom-components
|
14
|
+
# to know more about custom components.
|
15
|
+
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
16
|
+
|
17
|
+
# Use this setup block to configure all options available in SimpleForm.
|
18
|
+
SimpleForm.setup do |config|
|
19
|
+
# Default class for buttons
|
20
|
+
config.button_class = 'btn'
|
21
|
+
|
22
|
+
# Define the default class of the input wrapper of the boolean input.
|
23
|
+
config.boolean_label_class = 'form-check-label'
|
24
|
+
|
25
|
+
# How the label text should be generated altogether with the required text.
|
26
|
+
config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
|
27
|
+
|
28
|
+
# Define the way to render check boxes / radio buttons with labels.
|
29
|
+
config.boolean_style = :inline
|
30
|
+
|
31
|
+
# You can wrap each item in a collection of radio/check boxes with a tag
|
32
|
+
config.item_wrapper_tag = :div
|
33
|
+
|
34
|
+
# Defines if the default input wrapper class should be included in radio
|
35
|
+
# collection wrappers.
|
36
|
+
config.include_default_input_wrapper_class = false
|
37
|
+
|
38
|
+
# CSS class to add for error notification helper.
|
39
|
+
config.error_notification_class = 'alert alert-danger'
|
40
|
+
|
41
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
42
|
+
# :first lists the first message for each field.
|
43
|
+
# :to_sentence to list all errors for each field.
|
44
|
+
config.error_method = :to_sentence
|
45
|
+
|
46
|
+
# add validation classes to `input_field`
|
47
|
+
config.input_field_error_class = 'is-invalid'
|
48
|
+
config.input_field_valid_class = 'is-valid'
|
49
|
+
|
50
|
+
|
51
|
+
# vertical forms
|
52
|
+
#
|
53
|
+
# vertical default_wrapper
|
54
|
+
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
55
|
+
b.use :html5
|
56
|
+
b.use :placeholder
|
57
|
+
b.optional :maxlength
|
58
|
+
b.optional :minlength
|
59
|
+
b.optional :pattern
|
60
|
+
b.optional :min_max
|
61
|
+
b.optional :readonly
|
62
|
+
b.use :label, class: 'form-control-label'
|
63
|
+
b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
64
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
65
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
66
|
+
end
|
67
|
+
|
68
|
+
# vertical input for boolean
|
69
|
+
config.wrappers :vertical_boolean, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
70
|
+
b.use :html5
|
71
|
+
b.optional :readonly
|
72
|
+
b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check' do |bb|
|
73
|
+
bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
74
|
+
bb.use :label, class: 'form-check-label'
|
75
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
76
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# vertical input for radio buttons and check boxes
|
81
|
+
config.wrappers :vertical_collection, item_wrapper_class: 'form-check', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
82
|
+
b.use :html5
|
83
|
+
b.optional :readonly
|
84
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
85
|
+
ba.use :label_text
|
86
|
+
end
|
87
|
+
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
88
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
89
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
90
|
+
end
|
91
|
+
|
92
|
+
# vertical input for inline radio buttons and check boxes
|
93
|
+
config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
94
|
+
b.use :html5
|
95
|
+
b.optional :readonly
|
96
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
97
|
+
ba.use :label_text
|
98
|
+
end
|
99
|
+
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
100
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
101
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
102
|
+
end
|
103
|
+
|
104
|
+
# vertical file input
|
105
|
+
config.wrappers :vertical_file, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
106
|
+
b.use :html5
|
107
|
+
b.use :placeholder
|
108
|
+
b.optional :maxlength
|
109
|
+
b.optional :minlength
|
110
|
+
b.optional :readonly
|
111
|
+
b.use :label
|
112
|
+
b.use :input, class: 'form-control-file', error_class: 'is-invalid', valid_class: 'is-valid'
|
113
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
114
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
115
|
+
end
|
116
|
+
|
117
|
+
# vertical multi select
|
118
|
+
config.wrappers :vertical_multi_select, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
119
|
+
b.use :html5
|
120
|
+
b.optional :readonly
|
121
|
+
b.use :label, class: 'form-control-label'
|
122
|
+
b.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
|
123
|
+
ba.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
|
124
|
+
end
|
125
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
126
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
127
|
+
end
|
128
|
+
|
129
|
+
# vertical range input
|
130
|
+
config.wrappers :vertical_range, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
131
|
+
b.use :html5
|
132
|
+
b.use :placeholder
|
133
|
+
b.optional :readonly
|
134
|
+
b.optional :step
|
135
|
+
b.use :label
|
136
|
+
b.use :input, class: 'form-control-range', error_class: 'is-invalid', valid_class: 'is-valid'
|
137
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
138
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
# horizontal forms
|
143
|
+
#
|
144
|
+
# horizontal default_wrapper
|
145
|
+
config.wrappers :horizontal_form, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
146
|
+
b.use :html5
|
147
|
+
b.use :placeholder
|
148
|
+
b.optional :maxlength
|
149
|
+
b.optional :minlength
|
150
|
+
b.optional :pattern
|
151
|
+
b.optional :min_max
|
152
|
+
b.optional :readonly
|
153
|
+
b.use :label, class: 'col-sm-3 col-form-label'
|
154
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
155
|
+
ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
156
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
157
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# horizontal input for boolean
|
162
|
+
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
163
|
+
b.use :html5
|
164
|
+
b.optional :readonly
|
165
|
+
b.wrapper tag: 'label', class: 'col-sm-3' do |ba|
|
166
|
+
ba.use :label_text
|
167
|
+
end
|
168
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |wr|
|
169
|
+
wr.wrapper :form_check_wrapper, tag: 'div', class: 'form-check' do |bb|
|
170
|
+
bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
171
|
+
bb.use :label, class: 'form-check-label'
|
172
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
173
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# horizontal input for radio buttons and check boxes
|
179
|
+
config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
180
|
+
b.use :html5
|
181
|
+
b.optional :readonly
|
182
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
183
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
184
|
+
ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
185
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
186
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# horizontal input for inline radio buttons and check boxes
|
191
|
+
config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
192
|
+
b.use :html5
|
193
|
+
b.optional :readonly
|
194
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
195
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
196
|
+
ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
197
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
198
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# horizontal file input
|
203
|
+
config.wrappers :horizontal_file, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
204
|
+
b.use :html5
|
205
|
+
b.use :placeholder
|
206
|
+
b.optional :maxlength
|
207
|
+
b.optional :minlength
|
208
|
+
b.optional :readonly
|
209
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
210
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
211
|
+
ba.use :input, error_class: 'is-invalid', valid_class: 'is-valid'
|
212
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
213
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
# horizontal multi select
|
218
|
+
config.wrappers :horizontal_multi_select, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
219
|
+
b.use :html5
|
220
|
+
b.optional :readonly
|
221
|
+
b.use :label, class: 'col-sm-3 control-label'
|
222
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
223
|
+
ba.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |bb|
|
224
|
+
bb.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
|
225
|
+
end
|
226
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
227
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# horizontal range input
|
232
|
+
config.wrappers :horizontal_range, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
233
|
+
b.use :html5
|
234
|
+
b.use :placeholder
|
235
|
+
b.optional :readonly
|
236
|
+
b.optional :step
|
237
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
238
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
239
|
+
ba.use :input, class: 'form-control-range', error_class: 'is-invalid', valid_class: 'is-valid'
|
240
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
241
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
|
246
|
+
# inline forms
|
247
|
+
#
|
248
|
+
# inline default_wrapper
|
249
|
+
config.wrappers :inline_form, tag: 'span', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
250
|
+
b.use :html5
|
251
|
+
b.use :placeholder
|
252
|
+
b.optional :maxlength
|
253
|
+
b.optional :minlength
|
254
|
+
b.optional :pattern
|
255
|
+
b.optional :min_max
|
256
|
+
b.optional :readonly
|
257
|
+
b.use :label, class: 'sr-only'
|
258
|
+
|
259
|
+
b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
260
|
+
b.use :error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
261
|
+
b.optional :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
262
|
+
end
|
263
|
+
|
264
|
+
# inline input for boolean
|
265
|
+
config.wrappers :inline_boolean, tag: 'span', class: 'form-check flex-wrap justify-content-start mr-sm-2', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
266
|
+
b.use :html5
|
267
|
+
b.optional :readonly
|
268
|
+
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
269
|
+
b.use :label, class: 'form-check-label'
|
270
|
+
b.use :error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
271
|
+
b.optional :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
272
|
+
end
|
273
|
+
|
274
|
+
|
275
|
+
# bootstrap custom forms
|
276
|
+
#
|
277
|
+
# custom input for boolean
|
278
|
+
config.wrappers :custom_boolean, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
279
|
+
b.use :html5
|
280
|
+
b.optional :readonly
|
281
|
+
b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom-checkbox' do |bb|
|
282
|
+
bb.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
283
|
+
bb.use :label, class: 'custom-control-label'
|
284
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
285
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
config.wrappers :custom_boolean_switch, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
290
|
+
b.use :html5
|
291
|
+
b.optional :readonly
|
292
|
+
b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom-checkbox-switch' do |bb|
|
293
|
+
bb.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
294
|
+
bb.use :label, class: 'custom-control-label'
|
295
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
296
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
# custom input for radio buttons and check boxes
|
301
|
+
config.wrappers :custom_collection, item_wrapper_class: 'custom-control', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
302
|
+
b.use :html5
|
303
|
+
b.optional :readonly
|
304
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
305
|
+
ba.use :label_text
|
306
|
+
end
|
307
|
+
b.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
308
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
309
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
310
|
+
end
|
311
|
+
|
312
|
+
# custom input for inline radio buttons and check boxes
|
313
|
+
config.wrappers :custom_collection_inline, item_wrapper_class: 'custom-control custom-control-inline', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
314
|
+
b.use :html5
|
315
|
+
b.optional :readonly
|
316
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
317
|
+
ba.use :label_text
|
318
|
+
end
|
319
|
+
b.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
320
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
321
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
322
|
+
end
|
323
|
+
|
324
|
+
# custom file input
|
325
|
+
config.wrappers :custom_file, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
326
|
+
b.use :html5
|
327
|
+
b.use :placeholder
|
328
|
+
b.optional :maxlength
|
329
|
+
b.optional :minlength
|
330
|
+
b.optional :readonly
|
331
|
+
b.use :label, class: 'form-control-label'
|
332
|
+
b.wrapper :custom_file_wrapper, tag: 'div', class: 'custom-file' do |ba|
|
333
|
+
ba.use :input, class: 'custom-file-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
334
|
+
ba.use :label, class: 'custom-file-label'
|
335
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
336
|
+
end
|
337
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
338
|
+
end
|
339
|
+
|
340
|
+
# custom multi select
|
341
|
+
config.wrappers :custom_multi_select, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
342
|
+
b.use :html5
|
343
|
+
b.optional :readonly
|
344
|
+
b.use :label, class: 'form-control-label'
|
345
|
+
b.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
|
346
|
+
ba.use :input, class: 'custom-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
|
347
|
+
end
|
348
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
349
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
350
|
+
end
|
351
|
+
|
352
|
+
# custom range input
|
353
|
+
config.wrappers :custom_range, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
354
|
+
b.use :html5
|
355
|
+
b.use :placeholder
|
356
|
+
b.optional :readonly
|
357
|
+
b.optional :step
|
358
|
+
b.use :label, class: 'form-control-label'
|
359
|
+
b.use :input, class: 'custom-range', error_class: 'is-invalid', valid_class: 'is-valid'
|
360
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
361
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
362
|
+
end
|
363
|
+
|
364
|
+
|
365
|
+
# Input Group - custom component
|
366
|
+
# see example app and config at https://github.com/rafaelfranca/simple_form-bootstrap
|
367
|
+
config.wrappers :input_group, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
368
|
+
b.use :html5
|
369
|
+
b.use :placeholder
|
370
|
+
b.optional :maxlength
|
371
|
+
b.optional :minlength
|
372
|
+
b.optional :pattern
|
373
|
+
b.optional :min_max
|
374
|
+
b.optional :readonly
|
375
|
+
b.use :label, class: 'form-control-label'
|
376
|
+
b.wrapper :input_group_tag, tag: 'div', class: 'input-group' do |ba|
|
377
|
+
ba.optional :prepend
|
378
|
+
ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
379
|
+
ba.optional :append
|
380
|
+
end
|
381
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
382
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
383
|
+
end
|
384
|
+
|
385
|
+
|
386
|
+
# Floating Labels form
|
387
|
+
#
|
388
|
+
# floating labels default_wrapper
|
389
|
+
config.wrappers :floating_labels_form, tag: 'div', class: 'form-label-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
390
|
+
b.use :html5
|
391
|
+
b.use :placeholder
|
392
|
+
b.optional :maxlength
|
393
|
+
b.optional :minlength
|
394
|
+
b.optional :pattern
|
395
|
+
b.optional :min_max
|
396
|
+
b.optional :readonly
|
397
|
+
b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
398
|
+
b.use :label, class: 'form-control-label'
|
399
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
400
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
401
|
+
end
|
402
|
+
|
403
|
+
# custom multi select
|
404
|
+
config.wrappers :floating_labels_select, tag: 'div', class: 'form-label-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
405
|
+
b.use :html5
|
406
|
+
b.optional :readonly
|
407
|
+
b.use :input, class: 'custom-select custom-select-lg', error_class: 'is-invalid', valid_class: 'is-valid'
|
408
|
+
b.use :label, class: 'form-control-label'
|
409
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
410
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
# The default wrapper to be used by the FormBuilder.
|
415
|
+
config.default_wrapper = :vertical_form
|
416
|
+
|
417
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
418
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
419
|
+
config.wrapper_mappings = {
|
420
|
+
boolean: :vertical_boolean,
|
421
|
+
check_boxes: :vertical_collection,
|
422
|
+
date: :vertical_multi_select,
|
423
|
+
datetime: :vertical_multi_select,
|
424
|
+
file: :vertical_file,
|
425
|
+
radio_buttons: :vertical_collection,
|
426
|
+
range: :vertical_range,
|
427
|
+
time: :vertical_multi_select
|
428
|
+
}
|
429
|
+
|
430
|
+
# enable custom form wrappers
|
431
|
+
# config.wrapper_mappings = {
|
432
|
+
# boolean: :custom_boolean,
|
433
|
+
# check_boxes: :custom_collection,
|
434
|
+
# date: :custom_multi_select,
|
435
|
+
# datetime: :custom_multi_select,
|
436
|
+
# file: :custom_file,
|
437
|
+
# radio_buttons: :custom_collection,
|
438
|
+
# range: :custom_range,
|
439
|
+
# time: :custom_multi_select
|
440
|
+
# }
|
441
|
+
end
|
442
|
+
|
443
|
+
# custom component requires input group wrapper
|
444
|
+
module InputGroup
|
445
|
+
def prepend(wrapper_options = nil)
|
446
|
+
span_tag = content_tag(:span, options[:prepend], class: "input-group-text")
|
447
|
+
template.content_tag(:div, span_tag, class: "input-group-prepend")
|
448
|
+
end
|
449
|
+
|
450
|
+
def append(wrapper_options = nil)
|
451
|
+
span_tag = content_tag(:span, options[:append], class: "input-group-text")
|
452
|
+
template.content_tag(:div, span_tag, class: "input-group-append")
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
# Register the component in Simple Form.
|
457
|
+
SimpleForm.include_component(InputGroup)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# config/initializers/will_paginate.rb
|
4
|
+
#
|
5
|
+
# This extension code was written by Isaac Bowen, originally found
|
6
|
+
# at http://isaacbowen.com/blog/using-will_paginate-action_view-and-bootstrap/
|
7
|
+
|
8
|
+
require "will_paginate/view_helpers/action_view"
|
9
|
+
|
10
|
+
module WillPaginate
|
11
|
+
module ActionView
|
12
|
+
def will_paginate(collection = nil, options = {})
|
13
|
+
options, collection = collection, nil if collection.is_a? Hash
|
14
|
+
# Taken from original will_paginate code to handle if the helper is not passed a collection object.
|
15
|
+
collection ||= infer_collection_from_controller
|
16
|
+
options[:renderer] ||= BootstrapLinkRenderer
|
17
|
+
super.try :html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
class Bootstrap4LinkRenderer < LinkRenderer
|
21
|
+
protected
|
22
|
+
|
23
|
+
def html_container(html)
|
24
|
+
tag :nav, tag(:ul, html, class: ul_class)
|
25
|
+
end
|
26
|
+
|
27
|
+
def page_number(page)
|
28
|
+
item_class = if(page == current_page)
|
29
|
+
"active page-item"
|
30
|
+
else
|
31
|
+
"page-item"
|
32
|
+
end
|
33
|
+
|
34
|
+
tag :li, link(page, page, :rel => rel_value(page), class: "page-link"), class: item_class
|
35
|
+
end
|
36
|
+
|
37
|
+
def gap
|
38
|
+
tag :li, link("…".html_safe, "#", class: "page-link"), class: "page-item disabled"
|
39
|
+
end
|
40
|
+
|
41
|
+
def previous_or_next_page(page, text, classname)
|
42
|
+
tag :li,
|
43
|
+
link(text, page || "#", class: "page-link"),
|
44
|
+
class: [
|
45
|
+
(classname[0..3] if @options[:page_links]),
|
46
|
+
(classname if @options[:page_links]),
|
47
|
+
("disabled" unless page),
|
48
|
+
"page-item"
|
49
|
+
].join(" ")
|
50
|
+
end
|
51
|
+
|
52
|
+
def ul_class
|
53
|
+
["pagination", container_attributes[:class]].compact.join(" ")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/standard_view/engine.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module StandardView
|
2
4
|
class Engine < ::Rails::Engine
|
3
5
|
isolate_namespace StandardView
|
6
|
+
|
7
|
+
config.to_prepare do
|
8
|
+
ApplicationController.helper(StandardView::ApplicationHelper)
|
9
|
+
ApplicationController.helper(StandardView::FlashHelper)
|
10
|
+
ApplicationController.helper(StandardView::FormattingHelper)
|
11
|
+
ApplicationController.helper(StandardView::MastheadHelper)
|
12
|
+
ApplicationController.helper(StandardView::BadgeHelper)
|
13
|
+
ApplicationController.helper(StandardView::NavigationHelper)
|
14
|
+
end
|
4
15
|
end
|
5
16
|
end
|
data/lib/standard_view.rb
CHANGED