dry_crud 6.0.0 → 7.1.0
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 +4 -4
- data/MIT-LICENSE +2 -2
- data/README.rdoc +7 -6
- data/VERSION +1 -1
- data/app/assets/stylesheets/sample.scss +45 -24
- data/app/controllers/crud_controller.rb +19 -19
- data/app/controllers/dry_crud/generic_model.rb +2 -4
- data/app/controllers/dry_crud/render_callbacks.rb +3 -3
- data/app/controllers/list_controller.rb +1 -1
- data/app/helpers/actions_helper.rb +7 -7
- data/app/helpers/dry_crud/form/builder.rb +40 -43
- data/app/helpers/dry_crud/form/control.rb +8 -11
- data/app/helpers/dry_crud/table/actions.rb +12 -12
- data/app/helpers/dry_crud/table/builder.rb +10 -10
- data/app/helpers/dry_crud/table/col.rb +4 -4
- data/app/helpers/form_helper.rb +6 -8
- data/app/helpers/format_helper.rb +7 -7
- data/app/helpers/i18n_helper.rb +5 -5
- data/app/helpers/table_helper.rb +15 -16
- data/app/helpers/utility_helper.rb +3 -3
- data/app/views/crud/new.html.erb +1 -1
- data/app/views/crud/new.html.haml +1 -1
- data/app/views/layouts/application.html.erb +8 -6
- data/app/views/layouts/application.html.haml +6 -5
- data/app/views/list/_search.html.erb +1 -3
- data/app/views/list/_search.html.haml +1 -2
- data/app/views/shared/_error_messages.html.erb +2 -2
- data/lib/generators/dry_crud/dry_crud_generator.rb +1 -1
- data/lib/generators/dry_crud/templates/spec/controllers/crud_test_models_controller_spec.rb +4 -4
- data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/form/builder_spec.rb +3 -3
- data/lib/generators/dry_crud/templates/spec/helpers/dry_crud/table/builder_spec.rb +1 -1
- data/lib/generators/dry_crud/templates/spec/helpers/form_helper_spec.rb +6 -5
- data/lib/generators/dry_crud/templates/spec/helpers/format_helper_spec.rb +2 -2
- data/lib/generators/dry_crud/templates/spec/helpers/table_helper_spec.rb +6 -6
- data/lib/generators/dry_crud/templates/spec/helpers/utility_helper_spec.rb +2 -2
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +4 -6
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +3 -3
- data/lib/generators/dry_crud/templates/test/controllers/crud_test_models_controller_test.rb +1 -1
- data/lib/generators/dry_crud/templates/test/helpers/custom_assertions_test.rb +5 -5
- data/lib/generators/dry_crud/templates/test/helpers/dry_crud/form/builder_test.rb +3 -3
- data/lib/generators/dry_crud/templates/test/helpers/form_helper_test.rb +8 -8
- data/lib/generators/dry_crud/templates/test/helpers/table_helper_test.rb +7 -7
- data/lib/generators/dry_crud/templates/test/helpers/utility_helper_test.rb +2 -2
- data/lib/generators/dry_crud/templates/test/support/crud_test_helper.rb +6 -6
- data/lib/generators/dry_crud/templates/test/support/crud_test_model.rb +2 -3
- data/lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb +4 -6
- data/lib/generators/dry_crud/templates/test/support/custom_assertions.rb +6 -6
- metadata +9 -10
@@ -8,7 +8,7 @@ module DryCrud
|
|
8
8
|
|
9
9
|
attr_reader :builder, :attr, :args, :options, :addon, :help
|
10
10
|
|
11
|
-
delegate :
|
11
|
+
delegate :tag, :object, :add_css_class,
|
12
12
|
to: :builder
|
13
13
|
|
14
14
|
# Html displayed to mark an input as required.
|
@@ -39,10 +39,10 @@ module DryCrud
|
|
39
39
|
# (The value for this option usually is 'required').
|
40
40
|
#
|
41
41
|
# All the other options will go to the field_method.
|
42
|
-
def initialize(builder, attr, *args)
|
42
|
+
def initialize(builder, attr, *args, **options)
|
43
43
|
@builder = builder
|
44
44
|
@attr = attr
|
45
|
-
@options =
|
45
|
+
@options = options
|
46
46
|
@args = args
|
47
47
|
|
48
48
|
@addon = options.delete(:addon)
|
@@ -70,11 +70,9 @@ module DryCrud
|
|
70
70
|
|
71
71
|
# Create the HTML markup for any labeled content.
|
72
72
|
def labeled
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
builder.label(attr, caption, class: 'col-md-2 control-label') +
|
77
|
-
content_tag(:div, content, class: "col-md-#{span}")
|
73
|
+
tag.div(class: 'row mb-3') do
|
74
|
+
builder.label(attr, caption, class: 'col-md-2 col-form-label') +
|
75
|
+
tag.div(content, class: "col-md-#{span}")
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
@@ -101,7 +99,8 @@ module DryCrud
|
|
101
99
|
def input
|
102
100
|
@input ||= begin
|
103
101
|
options[:required] = 'required' if required
|
104
|
-
|
102
|
+
add_css_class(options, 'is-invalid') if errors?
|
103
|
+
builder.send(field_method, attr, *args, **options)
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
@@ -137,7 +136,6 @@ module DryCrud
|
|
137
136
|
|
138
137
|
# Defines the field method to use based on the attribute
|
139
138
|
# type, association or name.
|
140
|
-
# rubocop:disable PerceivedComplexity
|
141
139
|
def detect_field_method
|
142
140
|
if type == :text
|
143
141
|
:text_area
|
@@ -155,7 +153,6 @@ module DryCrud
|
|
155
153
|
:text_field
|
156
154
|
end
|
157
155
|
end
|
158
|
-
# rubocop:enable PerceivedComplexity
|
159
156
|
|
160
157
|
# The column type of the attribute.
|
161
158
|
def type
|
@@ -26,13 +26,13 @@ module DryCrud
|
|
26
26
|
# Action column to show the row entry.
|
27
27
|
# A block may be given to define the link path for the row entry.
|
28
28
|
# If the block returns nil, no link is rendered.
|
29
|
-
def show_action_col(html_options
|
29
|
+
def show_action_col(**html_options, &block)
|
30
30
|
action_col do |entry|
|
31
31
|
path = action_path(entry, &block)
|
32
32
|
if path
|
33
33
|
table_action_link('zoom-in',
|
34
34
|
path,
|
35
|
-
html_options.clone)
|
35
|
+
**html_options.clone)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -40,12 +40,12 @@ module DryCrud
|
|
40
40
|
# Action column to edit the row entry.
|
41
41
|
# A block may be given to define the link path for the row entry.
|
42
42
|
# If the block returns nil, no link is rendered.
|
43
|
-
def edit_action_col(html_options
|
43
|
+
def edit_action_col(**html_options, &block)
|
44
44
|
action_col do |entry|
|
45
45
|
path = action_path(entry, &block)
|
46
46
|
if path
|
47
|
-
path = path.is_a?(String)
|
48
|
-
table_action_link('pencil', path, html_options.clone)
|
47
|
+
path = edit_polymorphic_path(path) unless path.is_a?(String)
|
48
|
+
table_action_link('pencil', path, **html_options.clone)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -53,15 +53,15 @@ module DryCrud
|
|
53
53
|
# Action column to destroy the row entry.
|
54
54
|
# A block may be given to define the link path for the row entry.
|
55
55
|
# If the block returns nil, no link is rendered.
|
56
|
-
def destroy_action_col(html_options
|
56
|
+
def destroy_action_col(**html_options, &block)
|
57
57
|
action_col do |entry|
|
58
58
|
path = action_path(entry, &block)
|
59
59
|
if path
|
60
|
-
table_action_link('
|
60
|
+
table_action_link('trash',
|
61
61
|
path,
|
62
|
-
html_options.merge(
|
63
|
-
data: { confirm: ti(:confirm_delete),
|
64
|
-
method: :delete }
|
62
|
+
**html_options.merge(
|
63
|
+
data: { 'turbo-confirm': ti(:confirm_delete),
|
64
|
+
'turbo-method': :delete }
|
65
65
|
))
|
66
66
|
end
|
67
67
|
end
|
@@ -74,8 +74,8 @@ module DryCrud
|
|
74
74
|
end
|
75
75
|
|
76
76
|
# Generic action link inside a table.
|
77
|
-
def table_action_link(icon, url, html_options
|
78
|
-
add_css_class(html_options, "
|
77
|
+
def table_action_link(icon, url, **html_options)
|
78
|
+
add_css_class(html_options, "bi-#{icon}")
|
79
79
|
link_to('', url, html_options)
|
80
80
|
end
|
81
81
|
|
@@ -16,11 +16,11 @@ module DryCrud
|
|
16
16
|
|
17
17
|
attr_reader :entries, :cols, :options, :template
|
18
18
|
|
19
|
-
delegate :
|
19
|
+
delegate :tag, :format_attr, :column_type, :association, :dom_id,
|
20
20
|
:captionize, :add_css_class, :content_tag_nested,
|
21
21
|
to: :template
|
22
22
|
|
23
|
-
def initialize(entries, template, options
|
23
|
+
def initialize(entries, template, **options)
|
24
24
|
@entries = entries
|
25
25
|
@template = template
|
26
26
|
@options = options
|
@@ -30,8 +30,8 @@ module DryCrud
|
|
30
30
|
# Convenience method to directly generate a table. Renders a row for each
|
31
31
|
# entry in entries. Takes a block that gets the table object as parameter
|
32
32
|
# for configuration. Returns the generated html for the table.
|
33
|
-
def self.table(entries, template, options
|
34
|
-
t = new(entries, template, options)
|
33
|
+
def self.table(entries, template, **options)
|
34
|
+
t = new(entries, template, **options)
|
35
35
|
yield t
|
36
36
|
t.to_html
|
37
37
|
end
|
@@ -39,7 +39,7 @@ module DryCrud
|
|
39
39
|
# Define a column for the table with the given header, the html_options
|
40
40
|
# used for each td and a block rendering the contents of a cell for the
|
41
41
|
# current entry. The columns appear in the order they are defined.
|
42
|
-
def col(header = '', html_options
|
42
|
+
def col(header = '', **html_options, &block)
|
43
43
|
@cols << Col.new(header, html_options, @template, block)
|
44
44
|
end
|
45
45
|
|
@@ -55,17 +55,17 @@ module DryCrud
|
|
55
55
|
# Define a column for the given attribute and an optional header.
|
56
56
|
# If no header is given, the attribute name is used. The cell will
|
57
57
|
# contain the formatted attribute value for the current entry.
|
58
|
-
def attr(attr, header = nil, html_options
|
58
|
+
def attr(attr, header = nil, **html_options, &block)
|
59
59
|
header ||= attr_header(attr)
|
60
60
|
block ||= ->(e) { format_attr(e, attr) }
|
61
61
|
add_css_class(html_options, align_class(attr))
|
62
|
-
col(header, html_options, &block)
|
62
|
+
col(header, **html_options, &block)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Renders the table as HTML.
|
66
66
|
def to_html
|
67
|
-
|
68
|
-
|
67
|
+
tag.table(**options) do
|
68
|
+
tag.thead(html_header) +
|
69
69
|
content_tag_nested(:tbody, entries) { |e| html_row(e) }
|
70
70
|
end
|
71
71
|
end
|
@@ -98,7 +98,7 @@ module DryCrud
|
|
98
98
|
def html_row(entry)
|
99
99
|
attrs = {}
|
100
100
|
attrs[:id] = dom_id(entry) if entry.respond_to?(:to_key)
|
101
|
-
content_tag_nested(:tr, cols, attrs) { |c| c.html_cell(entry) }
|
101
|
+
content_tag_nested(:tr, cols, **attrs) { |c| c.html_cell(entry) }
|
102
102
|
end
|
103
103
|
|
104
104
|
# Determines the class of the table entries.
|
@@ -2,9 +2,9 @@ module DryCrud
|
|
2
2
|
module Table
|
3
3
|
|
4
4
|
# Helper class to store column information.
|
5
|
-
class Col
|
5
|
+
class Col # :nodoc:
|
6
6
|
|
7
|
-
delegate :
|
7
|
+
delegate :tag, :capture, to: :template
|
8
8
|
|
9
9
|
attr_reader :header, :html_options, :template, :block
|
10
10
|
|
@@ -22,12 +22,12 @@ module DryCrud
|
|
22
22
|
|
23
23
|
# Renders the header cell of the Col.
|
24
24
|
def html_header
|
25
|
-
|
25
|
+
tag.th(header, **html_options)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Renders a table cell for the given entry.
|
29
29
|
def html_cell(entry)
|
30
|
-
|
30
|
+
tag.td(content(entry), **html_options)
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
data/app/helpers/form_helper.rb
CHANGED
@@ -8,14 +8,14 @@
|
|
8
8
|
module FormHelper
|
9
9
|
|
10
10
|
# Renders a form using Crud::FormBuilder.
|
11
|
-
def plain_form(object, options
|
11
|
+
def plain_form(object, **options, &block)
|
12
12
|
options[:html] ||= {}
|
13
13
|
add_css_class(options[:html], 'form-horizontal')
|
14
14
|
options[:html][:role] ||= 'form'
|
15
15
|
options[:builder] ||= DryCrud::Form::Builder
|
16
16
|
options[:cancel_url] ||= polymorphic_path(object, returning: true)
|
17
17
|
|
18
|
-
form_for(object, options, &block)
|
18
|
+
form_for(object, **options, &block)
|
19
19
|
end
|
20
20
|
|
21
21
|
# Renders a standard form for the given entry and attributes.
|
@@ -23,8 +23,8 @@ module FormHelper
|
|
23
23
|
# If a block is given, custom input fields may be rendered and attrs is
|
24
24
|
# ignored. Before the input fields, the error messages are rendered,
|
25
25
|
# if present. An options hash may be given as the last argument.
|
26
|
-
def standard_form(object, *attrs, &block)
|
27
|
-
plain_form(object,
|
26
|
+
def standard_form(object, *attrs, **options, &block)
|
27
|
+
plain_form(object, **options) do |form|
|
28
28
|
content = [form.error_messages]
|
29
29
|
|
30
30
|
content << if block_given?
|
@@ -41,11 +41,9 @@ module FormHelper
|
|
41
41
|
# Renders a crud form for the current entry with default_crud_attrs or the
|
42
42
|
# given attribute array. An options hash may be given as the last argument.
|
43
43
|
# If a block is given, a custom form may be rendered and attrs is ignored.
|
44
|
-
def crud_form(*attrs, &block)
|
45
|
-
options = attrs.extract_options!
|
44
|
+
def crud_form(*attrs, **options, &block)
|
46
45
|
attrs = default_crud_attrs - %i[created_at updated_at] if attrs.blank?
|
47
|
-
attrs
|
48
|
-
standard_form(path_args(entry), *attrs, &block)
|
46
|
+
standard_form(path_args(entry), *attrs, **options, &block)
|
49
47
|
end
|
50
48
|
|
51
49
|
end
|
@@ -10,10 +10,10 @@ module FormatHelper
|
|
10
10
|
# Formats a basic value based on its Ruby class.
|
11
11
|
def f(value)
|
12
12
|
case value
|
13
|
-
when Float, BigDecimal
|
13
|
+
when Float, BigDecimal
|
14
14
|
number_with_precision(value, precision: t('number.format.precision'),
|
15
15
|
delimiter: t('number.format.delimiter'))
|
16
|
-
when Integer
|
16
|
+
when Integer
|
17
17
|
number_with_delimiter(value, delimiter: t('number.format.delimiter'))
|
18
18
|
when Date then l(value)
|
19
19
|
when Time then "#{l(value.to_date)} #{l(value, format: :time)}"
|
@@ -38,9 +38,9 @@ module FormatHelper
|
|
38
38
|
# Renders a simple unordered list, which will
|
39
39
|
# simply render all passed items or yield them
|
40
40
|
# to your block.
|
41
|
-
def simple_list(items, ul_options
|
42
|
-
content_tag_nested(:ul, items, ul_options) do |item|
|
43
|
-
|
41
|
+
def simple_list(items, **ul_options)
|
42
|
+
content_tag_nested(:ul, items, **ul_options) do |item|
|
43
|
+
tag.li(block_given? ? yield(item) : f(item))
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -119,8 +119,8 @@ module FormatHelper
|
|
119
119
|
when :time then l(val, format: :time)
|
120
120
|
when :date then f(val.to_date)
|
121
121
|
when :datetime, :timestamp then f(val.time)
|
122
|
-
when :text
|
123
|
-
when :decimal
|
122
|
+
when :text then simple_format(h(val))
|
123
|
+
when :decimal
|
124
124
|
number_with_precision(val.to_s.to_f,
|
125
125
|
precision: column_property(obj, attr, :scale),
|
126
126
|
delimiter: t('number.format.delimiter'))
|
data/app/helpers/i18n_helper.rb
CHANGED
@@ -12,11 +12,11 @@ module I18nHelper
|
|
12
12
|
# - {parent_controller}.global.{key}
|
13
13
|
# - ...
|
14
14
|
# - global.{key}
|
15
|
-
def translate_inheritable(key, variables
|
15
|
+
def translate_inheritable(key, **variables)
|
16
16
|
partial = defined?(@virtual_path) ? @virtual_path.gsub(/.*\/_?/, '') : nil
|
17
17
|
defaults = inheritable_translation_defaults(key, partial)
|
18
18
|
variables[:default] ||= defaults
|
19
|
-
t(defaults.shift, variables)
|
19
|
+
t(defaults.shift, **variables)
|
20
20
|
end
|
21
21
|
|
22
22
|
alias ti translate_inheritable
|
@@ -28,13 +28,13 @@ module I18nHelper
|
|
28
28
|
# - activerecord.associations.models.{model_name}.{association_name}.{key}
|
29
29
|
# - activerecord.associations.{association_model_name}.{key}
|
30
30
|
# - global.associations.{key}
|
31
|
-
def translate_association(key, assoc = nil, variables
|
31
|
+
def translate_association(key, assoc = nil, **variables)
|
32
32
|
if assoc && assoc.options[:polymorphic].nil?
|
33
33
|
variables[:default] ||= [association_klass_key(assoc, key).to_sym,
|
34
34
|
:"global.associations.#{key}"]
|
35
|
-
t(association_owner_key(assoc, key), variables)
|
35
|
+
t(association_owner_key(assoc, key), **variables)
|
36
36
|
else
|
37
|
-
t("global.associations.#{key}", variables)
|
37
|
+
t("global.associations.#{key}", **variables)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/app/helpers/table_helper.rb
CHANGED
@@ -13,11 +13,10 @@ module TableHelper
|
|
13
13
|
# appended to the attribute columns.
|
14
14
|
# If entries is empty, an appropriate message is rendered.
|
15
15
|
# An options hash may be given as the last argument.
|
16
|
-
def plain_table(entries, *attrs)
|
17
|
-
options = attrs.extract_options!
|
16
|
+
def plain_table(entries, *attrs, **options)
|
18
17
|
add_css_class(options, 'table table-striped table-hover')
|
19
18
|
builder = options.delete(:builder) || DryCrud::Table::Builder
|
20
|
-
builder.table(entries, self, options) do |t|
|
19
|
+
builder.table(entries, self, **options) do |t|
|
21
20
|
t.attrs(*attrs)
|
22
21
|
yield t if block_given?
|
23
22
|
end
|
@@ -25,21 +24,21 @@ module TableHelper
|
|
25
24
|
|
26
25
|
# Renders a #plain_table for the given entries.
|
27
26
|
# If entries is empty, an appropriate message is rendered.
|
28
|
-
def plain_table_or_message(entries, *attrs, &block)
|
27
|
+
def plain_table_or_message(entries, *attrs, **options, &block)
|
29
28
|
entries.to_a # force evaluation of relations
|
30
29
|
if entries.present?
|
31
|
-
plain_table(entries, *attrs, &block)
|
30
|
+
plain_table(entries, *attrs, **options, &block)
|
32
31
|
else
|
33
|
-
|
32
|
+
tag.div(ti(:no_list_entries), class: 'table')
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
36
|
# Create a table of the +entries+ with the default or
|
38
37
|
# the passed attributes in its columns. An options hash may be given
|
39
38
|
# as the last argument.
|
40
|
-
def list_table(*attrs, &block)
|
41
|
-
attrs
|
42
|
-
plain_table_or_message(entries, options) do |t|
|
39
|
+
def list_table(*attrs, **options, &block)
|
40
|
+
attrs = attrs_or_default(attrs, &block)
|
41
|
+
plain_table_or_message(entries, **options) do |t|
|
43
42
|
t.sortable_attrs(*attrs)
|
44
43
|
yield t if block_given?
|
45
44
|
end
|
@@ -52,10 +51,10 @@ module TableHelper
|
|
52
51
|
# If a block is given, the column defined there will be inserted
|
53
52
|
# between the given attributes and the actions.
|
54
53
|
# An options hash for the table builder may be given as the last argument.
|
55
|
-
def crud_table(*attrs, &block)
|
56
|
-
attrs
|
54
|
+
def crud_table(*attrs, **options, &block)
|
55
|
+
attrs = attrs_or_default(attrs, &block)
|
57
56
|
first = attrs.shift
|
58
|
-
plain_table_or_message(entries, options) do |t|
|
57
|
+
plain_table_or_message(entries, **options) do |t|
|
59
58
|
t.attr_with_show_link(first) if first
|
60
59
|
t.sortable_attrs(*attrs)
|
61
60
|
yield t if block_given?
|
@@ -71,12 +70,12 @@ module TableHelper
|
|
71
70
|
|
72
71
|
private
|
73
72
|
|
74
|
-
def
|
75
|
-
options = attrs.extract_options!
|
73
|
+
def attrs_or_default(attrs)
|
76
74
|
if !block_given? && attrs.blank?
|
77
|
-
|
75
|
+
default_crud_attrs
|
76
|
+
else
|
77
|
+
attrs
|
78
78
|
end
|
79
|
-
[attrs, options]
|
80
79
|
end
|
81
80
|
|
82
81
|
end
|
@@ -8,8 +8,8 @@ module UtilityHelper
|
|
8
8
|
|
9
9
|
# Render a content tag with the collected contents rendered
|
10
10
|
# by &block for each item in collection.
|
11
|
-
def content_tag_nested(tag, collection, options
|
12
|
-
content_tag(tag, safe_join(collection, &block), options)
|
11
|
+
def content_tag_nested(tag, collection, **options, &block)
|
12
|
+
content_tag(tag, safe_join(collection, &block), **options)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Overridden method that takes a block that is executed for each item in
|
@@ -30,7 +30,7 @@ module UtilityHelper
|
|
30
30
|
# Adds a class to the given options, even if there are already classes.
|
31
31
|
def add_css_class(options, classes)
|
32
32
|
if options[:class]
|
33
|
-
options[:class] +=
|
33
|
+
options[:class] += " #{classes}" if classes
|
34
34
|
else
|
35
35
|
options[:class] = classes
|
36
36
|
end
|
data/app/views/crud/new.html.erb
CHANGED
@@ -5,31 +5,33 @@
|
|
5
5
|
<meta charset="utf-8" />
|
6
6
|
<title><%= strip_tags(@title) %> - MyApp</title>
|
7
7
|
|
8
|
-
<meta name="viewport" content="width=device-width,
|
8
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
9
9
|
<%= csrf_meta_tag %>
|
10
10
|
<%= csp_meta_tag %>
|
11
11
|
|
12
|
-
<%= stylesheet_link_tag 'application',
|
13
|
-
<%=
|
12
|
+
<%= stylesheet_link_tag 'application', 'data-turbo-track': 'reload' %>
|
13
|
+
<%= javascript_include_tag 'application', 'data-turbo-track': 'reload', defer: true %>
|
14
14
|
|
15
15
|
<%= yield :head %>
|
16
16
|
</head>
|
17
17
|
<body>
|
18
18
|
|
19
19
|
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-4">
|
20
|
-
|
20
|
+
<div class="container-fluid">
|
21
|
+
<%= render 'layouts/nav' %>
|
22
|
+
</div>
|
21
23
|
</nav>
|
22
24
|
|
23
25
|
<div class="container">
|
24
26
|
|
25
27
|
<h1><%= @title %></h1>
|
26
28
|
|
27
|
-
<div class="row actions">
|
29
|
+
<div class="row actions mb-3">
|
28
30
|
<div class="col-md-5">
|
29
31
|
<%= yield :tools %>
|
30
32
|
</div>
|
31
33
|
<div class="col-md-7">
|
32
|
-
<div class="btn-toolbar float-
|
34
|
+
<div class="btn-toolbar float-end">
|
33
35
|
<%= yield :actions %>
|
34
36
|
</div>
|
35
37
|
</div>
|
@@ -11,23 +11,24 @@
|
|
11
11
|
= csrf_meta_tag
|
12
12
|
= csp_meta_tag
|
13
13
|
|
14
|
-
= stylesheet_link_tag 'application',
|
15
|
-
=
|
14
|
+
= stylesheet_link_tag 'application', 'data-turbo-track': 'reload'
|
15
|
+
= javascript_include_tag 'application', 'data-turbo-track': 'reload', defer: true
|
16
16
|
|
17
17
|
= yield :head
|
18
18
|
|
19
19
|
%body
|
20
20
|
%nav.navbar.navbar-expand-lg.navbar-light.bg-light.mb-4
|
21
|
-
|
21
|
+
.container-fluid
|
22
|
+
= render 'layouts/nav'
|
22
23
|
|
23
24
|
.container
|
24
25
|
%h1= @title
|
25
26
|
|
26
|
-
.row.actions
|
27
|
+
.row.actions.mb-3
|
27
28
|
.col-md-5
|
28
29
|
= yield :tools
|
29
30
|
.col-md-7
|
30
|
-
.btn-toolbar.float-
|
31
|
+
.btn-toolbar.float-end
|
31
32
|
= yield :actions
|
32
33
|
|
33
34
|
#flash= render partial: 'layouts/flash', collection: [:notice, :alert], as: :level
|
@@ -3,8 +3,6 @@
|
|
3
3
|
<%= hidden_field_tag :page, 1 %>
|
4
4
|
<div class="input-group">
|
5
5
|
<%= search_field_tag :q, params[:q], class: 'form-control' %>
|
6
|
-
|
7
|
-
<%= submit_tag ti(:"button.search"), class: 'btn btn-outline-secondary' %>
|
8
|
-
</span>
|
6
|
+
<%= submit_tag ti(:"button.search"), class: 'btn btn-outline-secondary' %>
|
9
7
|
</div>
|
10
8
|
<% end %>
|
@@ -3,5 +3,4 @@
|
|
3
3
|
= hidden_field_tag :page, 1
|
4
4
|
.input-group
|
5
5
|
= search_field_tag :q, params[:q], class: 'form-control'
|
6
|
-
|
7
|
-
= submit_tag ti(:"button.search"), class: 'btn btn-outline-secondary'
|
6
|
+
= submit_tag ti(:"button.search"), class: 'btn btn-outline-secondary'
|
@@ -50,7 +50,7 @@ describe CrudTestModelsController do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'has models_label singular' do
|
53
|
-
expect(controller.models_label(false)).to eq('Crud Test Model')
|
53
|
+
expect(controller.models_label(plural: false)).to eq('Crud Test Model')
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -245,7 +245,7 @@ describe CrudTestModelsController do
|
|
245
245
|
|
246
246
|
context 'plain', combine: 'chcp' do
|
247
247
|
it_is_expected_to_respond
|
248
|
-
it_is_expected_to_persist_entry(false)
|
248
|
+
it_is_expected_to_persist_entry(persist: false)
|
249
249
|
it_is_expected_to_have_flash(:alert)
|
250
250
|
|
251
251
|
it 'sets entry name' do
|
@@ -292,7 +292,7 @@ describe CrudTestModelsController do
|
|
292
292
|
|
293
293
|
context 'plain', combine: 'chip' do
|
294
294
|
it_is_expected_to_respond
|
295
|
-
it_is_expected_to_persist_entry(false)
|
295
|
+
it_is_expected_to_persist_entry(persist: false)
|
296
296
|
it_is_expected_to_not_have_flash(:notice)
|
297
297
|
it_is_expected_to_not_have_flash(:alert)
|
298
298
|
|
@@ -316,7 +316,7 @@ describe CrudTestModelsController do
|
|
316
316
|
|
317
317
|
context 'plain', combine: 'cjcb' do
|
318
318
|
it_is_expected_to_respond(422)
|
319
|
-
it_is_expected_to_persist_entry(false)
|
319
|
+
it_is_expected_to_persist_entry(persist: false)
|
320
320
|
it_is_expected_to_not_have_flash(:notice)
|
321
321
|
it_is_expected_to_not_have_flash(:alert)
|
322
322
|
it_is_expected_to_render_json
|
@@ -42,7 +42,7 @@ describe 'DryCrud::Form::Builder' do
|
|
42
42
|
other_ids: :has_many_field,
|
43
43
|
more_ids: :has_many_field }.each do |attr, method|
|
44
44
|
it "dispatches #{attr} attr to #{method}" do
|
45
|
-
expect(form).to receive(method).with(attr
|
45
|
+
expect(form).to receive(method).with(attr)
|
46
46
|
form.input_field(attr)
|
47
47
|
end
|
48
48
|
|
@@ -63,12 +63,12 @@ describe 'DryCrud::Form::Builder' do
|
|
63
63
|
describe '#labeled_input_field' do
|
64
64
|
context 'when required' do
|
65
65
|
subject { form.labeled_input_field(:name) }
|
66
|
-
it { is_expected.to include('input-group-
|
66
|
+
it { is_expected.to include('input-group-text') }
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'when not required' do
|
70
70
|
subject { form.labeled_input_field(:remarks) }
|
71
|
-
it { is_expected.not_to include('input-group-
|
71
|
+
it { is_expected.not_to include('input-group-text') }
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'with help text' do
|
@@ -97,7 +97,7 @@ describe FormHelper do
|
|
97
97
|
|
98
98
|
it do
|
99
99
|
is_expected.to match(/input .*?type="number"
|
100
|
-
.*?value
|
100
|
+
.*?value="9"
|
101
101
|
.*?name="crud_test_model\[children\]"/x)
|
102
102
|
end
|
103
103
|
|
@@ -132,9 +132,10 @@ describe FormHelper do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it do
|
135
|
-
is_expected.to match(/div\ class="
|
136
|
-
|
137
|
-
|
135
|
+
is_expected.to match(/div\ class="row\ mb-3">.*?
|
136
|
+
<input .*?class="is-invalid\ form-control"
|
137
|
+
.*?type="text"
|
138
|
+
.*?name="crud_test_model\[name\]"/x)
|
138
139
|
end
|
139
140
|
|
140
141
|
it do
|
@@ -191,7 +192,7 @@ describe FormHelper do
|
|
191
192
|
end
|
192
193
|
|
193
194
|
it do
|
194
|
-
is_expected.to match(/input .*?type="datetime
|
195
|
+
is_expected.to match(/input .*?type="datetime-local"
|
195
196
|
.*?name="crud_test_model\[last_seen\]"/x)
|
196
197
|
end
|
197
198
|
|