dynamic_scaffold 2.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c5c6ffc040bc5b732799e02be73ade7950d28950e8b1769f574c61ecb126f7e
4
- data.tar.gz: c34716b1c1896bd321616d6d5ad8018a7299ef892317ad9d8ea4ed02cedbc5e7
3
+ metadata.gz: 549a2a9dce875ddc14d6e57bd810b0a28dca62eae1ad765eed919de83c62af72
4
+ data.tar.gz: 5a1e8edd82846a933533f97f2f1bee7a4d9a5b07ac5789e43e5e8416c5aeb46a
5
5
  SHA512:
6
- metadata.gz: d09f5c854cdecebcbfdfa42230871e8438684399d088f275603dc326741488e31543f74ac3ddc5a391e71775c2f3ed4d10f1a6b01395a5e54f5c7e08987d19fa
7
- data.tar.gz: c8ad8ed86a3d2e56894c067fb95c05ba52a89a8858ac7f1289ad1fca5ec6d2737be056c511d0c39cf36feb1bfb112d9c8c472be7afa784622155b51bd0a2c68f
6
+ metadata.gz: d7fa4fe5610e2c252040d7da35c920c6aab5a86b7bec00c97e7aaa53a8c21467ea962ccbd51cb25be7b26bfb2a6ac0f808be41ece7d047b898a95971dab19cd5
7
+ data.tar.gz: 6529bea1eb3ec34ffd4a9a26896a04d995320af4bb6dda7855ad9a3a528c30b022078dc404371f9f12c587d7abbcf05c5d75b3e7b035d12cc07f9057b5abbf81
data/README.md CHANGED
@@ -10,9 +10,11 @@ The Scaffold system which dynamically generates CRUD and sort functions.
10
10
  * Support image crop.
11
11
  * Support [globalize](https://github.com/globalize/globalize) form fields.
12
12
  * Support [cocoon](https://github.com/nathanvda/cocoon).
13
- * This has the views with the Twitter Bootstrap. Support bootstrap3/4.
13
+ * This has the views with the Twitter Bootstrap. Support Bootstrap 4/5. Bootstrap 3 is no longer supported.
14
14
  * Customizable and flexible.
15
15
 
16
+ Version 3.0.0 supports Bootstrap 4/5 and has been tested with Rails 7.2.4 on Ruby 3.2.3. Bootstrap 3 is no longer a supported target.
17
+
16
18
  <img src="images/list_with_pager.png">
17
19
 
18
20
 
@@ -118,13 +120,13 @@ class Admin::ShopsController < Admin::BaseController
118
120
 
119
121
  ### Prepare CSS and Javascript
120
122
 
121
- You need to load the files for CSS and Javascript. Currently, we support the Bootstrap 3 and Bootstrap 4.
123
+ You need to load the files for CSS and Javascript. Currently, we support Bootstrap 4 and Bootstrap 5.
122
124
 
123
125
  ```sass
124
126
  # app/assets/stylesheets/application.scss
125
- @import 'dynamic_scaffold/bootstrap3'
126
- # or
127
127
  @import 'dynamic_scaffold/bootstrap4'
128
+ # or
129
+ @import 'dynamic_scaffold/bootstrap5'
128
130
  ```
129
131
 
130
132
  ```js
@@ -243,7 +245,7 @@ class ShopController < ApplicationController
243
245
  # You can use form helper methods for type,
244
246
  # text_field, check_box, radio_button, password_field, hidden_field, file_field, text_area, color_field,
245
247
  # collection_check_boxes, collection_radio_buttons, collection_select, grouped_collection_select,
246
- # time_select, date_select, datetime_select, date_field, number_field, telephone_field
248
+ # time_select, date_select, datetime_select, date_field, datetime_local_field, number_field, telephone_field
247
249
 
248
250
 
249
251
  # Default label is I18n model attribute name.
@@ -684,7 +686,7 @@ class ShopController < ApplicationController
684
686
 
685
687
  ### Development hints.
686
688
 
687
- Please support both Bootstrap 3/4. You can change CSS to Bootstrap3 by registering `bootstrap=3` in cookie in the sample page.
689
+ Please support both Bootstrap 4/5. Compare the `/en/controls/master/shops` (Bootstrap 4) and `/en/bootstrap5/shops` (Bootstrap 5) sample pages.
688
690
 
689
691
  ## License
690
692
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -5,8 +5,8 @@ document.addEventListener('dynamic_scaffold:load', function(){
5
5
  function swapAnimation(promises, source, target){
6
6
  promises.push(new Promise(function(resolve){
7
7
  source.dynamicScaffoldSortingResolver = resolve
8
- sourceRect = source.getBoundingClientRect()
9
- targetRect = target.getBoundingClientRect()
8
+ const sourceRect = source.getBoundingClientRect()
9
+ const targetRect = target.getBoundingClientRect()
10
10
 
11
11
 
12
12
  // Find the distance between two points and calculate the animation duration.
@@ -52,4 +52,66 @@ $dynamic_scaffold_danger: #dc3545 !default;
52
52
 
53
53
  .btn-outline-primary.disabled, .btn-outline-primary:disabled{
54
54
  background-color: transparent;
55
- }
55
+ }
56
+
57
+
58
+ .form-select {
59
+ --bs-body-color: #212529;
60
+ --bs-body-bg: #fff;
61
+ --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
62
+ --bs-border-width: 1px;
63
+ --bs-border-color: #dee2e6;
64
+ --bs-border-radius: 0.375rem;
65
+ display: block;
66
+ width: 100%;
67
+ padding: 0.375rem 2.25rem 0.375rem 0.75rem;
68
+ font-size: 1rem;
69
+ font-weight: 400;
70
+ line-height: 1.5;
71
+ color: var(--bs-body-color);
72
+ -webkit-appearance: none;
73
+ -moz-appearance: none;
74
+ appearance: none;
75
+ background-color: var(--bs-body-bg);
76
+ background-image: var(--bs-form-select-bg-img),var(--bs-form-select-bg-icon,none);
77
+ background-repeat: no-repeat;
78
+ background-position: right 0.75rem center;
79
+ background-size: 16px 12px;
80
+ border: var(--bs-border-width) solid var(--bs-border-color);
81
+ border-radius: var(--bs-border-radius);
82
+ transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
83
+ }
84
+
85
+ // Bootstrap 4 does not define form-select, so provide its interactive states too.
86
+ .form-select:focus {
87
+ border-color: #80bdff;
88
+ outline: 0;
89
+ box-shadow: 0 0 0 0.2rem rgba($dynamic_scaffold_primary, 0.25);
90
+ }
91
+
92
+ .form-select:disabled {
93
+ background-color: #e9ecef;
94
+ opacity: 1;
95
+ }
96
+
97
+ .form-select[multiple], .form-select[size]:not([size="1"]) {
98
+ height: auto;
99
+ padding-right: 0.75rem;
100
+ background-image: none;
101
+ }
102
+
103
+ .form-select.is-invalid, .was-validated .form-select:invalid {
104
+ border-color: $dynamic_scaffold_danger;
105
+
106
+ &:focus {
107
+ box-shadow: 0 0 0 0.2rem rgba($dynamic_scaffold_danger, 0.25);
108
+ }
109
+ }
110
+
111
+ .form-select.is-valid, .was-validated .form-select:valid {
112
+ border-color: #28a745;
113
+
114
+ &:focus {
115
+ box-shadow: 0 0 0 0.2rem rgba(#28a745, 0.25);
116
+ }
117
+ }
@@ -0,0 +1,51 @@
1
+ @import 'common';
2
+ @import 'resplist';
3
+
4
+
5
+ .btn-outline-primary, .btn-outline-secondary, .btn-outline-warning, .btn-outline-danger{
6
+ background-color: #fff;
7
+ }
8
+
9
+ .btn-outline-primary path{
10
+ fill: #007bff;
11
+ }
12
+
13
+ .btn-outline-primary:hover path {
14
+ fill: #fff;
15
+ }
16
+
17
+ .btn-outline-secondary path{
18
+ fill: #868e96;
19
+ }
20
+
21
+ .btn-outline-secondary:hover path{
22
+ fill: #fff;
23
+ }
24
+
25
+ .btn-outline-warning path{
26
+ fill: #ffc107;
27
+ }
28
+
29
+ .btn-outline-danger path{
30
+ fill: #dc3545;
31
+ }
32
+
33
+ .btn-outline-warning:hover, .btn-outline-danger:hover{
34
+ path{
35
+ fill: #fff;
36
+ }
37
+
38
+ color: #fff;
39
+ }
40
+
41
+ .page-item .page-link path{
42
+ fill: #007bff;
43
+ }
44
+
45
+ .page-item.disabled .page-link path{
46
+ fill: #868e96;
47
+ }
48
+
49
+ .btn-outline-primary.disabled, .btn-outline-primary:disabled{
50
+ background-color: transparent;
51
+ }
@@ -129,7 +129,7 @@
129
129
  margin-left: 10px;
130
130
  }
131
131
 
132
- // Fixed a problem that font-awesome icon and text link do not match in height.
132
+ /* Fixed a problem that font-awesome icon and text link do not match in height. */
133
133
  .page-link{
134
134
  line-height: 1.6;
135
135
  }
@@ -172,4 +172,16 @@
172
172
 
173
173
  .ds-form .form-group{
174
174
  margin-bottom: 1.5rem;
175
- }
175
+ }
176
+
177
+ .ds-time-sep{
178
+ display: inline-block;
179
+ margin-left: -5px;
180
+ margin-right: 5px;
181
+ }
182
+
183
+ .form-inline .form-select {
184
+ display: inline-block;
185
+ width: auto;
186
+ vertical-align: middle;
187
+ }
@@ -14,4 +14,20 @@ module DynamicScaffoldHelper
14
14
  def dynamic_scaffold_icon(name)
15
15
  instance_exec name, &::Rails.application.config.dynamic_scaffold.icons
16
16
  end
17
+
18
+ def render_check_box(form, field, value, label, input_options = {}, label_options = {}) # rubocop:disable Metrics/ParameterLists, Metrics/LineLength
19
+ id = "#{field.name}_#{value}"
20
+ concat(
21
+ form.check_box(
22
+ field.name, {
23
+ id: id,
24
+ multiple: field.multiple,
25
+ include_hidden: false,
26
+ **input_options
27
+ },
28
+ value
29
+ )
30
+ )
31
+ concat tag.label label, for: id, **label_options
32
+ end
17
33
  end
@@ -5,18 +5,25 @@
5
5
  <%end%>
6
6
  <input type="hidden" class="authenticity_param_name" value="<%= request_forgery_protection_token %>">
7
7
  <%= form_with method: :patch, url: dynamic_scaffold_path(:sort, request_queries(dynamic_scaffold.list.page_param_name)), local: true do%>
8
- <%- if dynamic_scaffold.list.add_button -%>
9
- <div class="ds-row">
10
- <%= link_to dynamic_scaffold_path(:new, request_queries), class: class_names('btn btn-outline-primary btn-primary btn-sm spec-ds-add', 'disabled': dynamic_scaffold.max_count?(@count)) do%>
11
- <%= dynamic_scaffold_icon(:add) %> <%= t('dynamic_scaffold.button.add') %>
12
- <%- unless dynamic_scaffold.max_count.nil? -%>
13
- &nbsp;<span class="badge badge-light">
14
- <%= @count %>&nbsp;/&nbsp;<%= dynamic_scaffold.max_count%>
15
- </span>
16
- <% end %>
17
- <%end%>
8
+ <div class="<%= class_names('ds-row d-flex align-items-center', dynamic_scaffold.list.add_button ? 'justify-content-between' : 'justify-content-end') %>">
9
+ <%- if dynamic_scaffold.list.add_button -%>
10
+ <%= link_to dynamic_scaffold_path(:new, request_queries), class: class_names('btn btn-outline-primary btn-primary btn-sm spec-ds-add', 'disabled': dynamic_scaffold.max_count?(@count)) do%>
11
+ <%= dynamic_scaffold_icon(:add) %> <%= t('dynamic_scaffold.button.add') %>
12
+ <%- unless dynamic_scaffold.max_count.nil? -%>
13
+ &nbsp;<span class="badge badge-light text-bg-light">
14
+ <%= @count %>&nbsp;/&nbsp;<%= dynamic_scaffold.max_count%>
15
+ </span>
16
+ <% end %>
17
+ <%end%>
18
+ <%- end -%>
19
+ <span class="badge badge-light text-bg-light fs-6 border h6 mb-0">
20
+ <% if @records.respond_to?(:total_count) %>
21
+ <%= t('dynamic_scaffold.count', count: @records.total_count) %>
22
+ <%- else -%>
23
+ <%= t('dynamic_scaffold.count', count: @records.count) %>
24
+ <%- end -%>
25
+ </span>
18
26
  </div>
19
- <%- end -%>
20
27
  <%= render 'dynamic_scaffold/bootstrap/pagination' %>
21
28
  <div class="ds-row">
22
29
  <%= render 'dynamic_scaffold/bootstrap/save_order'%>
@@ -48,7 +55,7 @@
48
55
  <%end%>
49
56
  </div>
50
57
  <div class="ds-list-footer clearfix">
51
- <div class="float-right pull-right">
58
+ <div class="float-right pull-right float-end">
52
59
  <%- if dynamic_scaffold.list.edit_buttons(record) -%>
53
60
  <div class="btn-group">
54
61
  <%= link_to dynamic_scaffold_path(:edit, request_queries.merge(id: record[record.class.primary_key])), class: 'btn btn-primary btn-outline-primary btn-sm spec-ds-edit' do %>
@@ -1,5 +1,5 @@
1
1
  <% if dynamic_scaffold.list.sorter %>
2
- <div class="text-right">
2
+ <div class="text-right text-end">
3
3
  <button type="submit" name="submit_sort" class="btn btn-outline-warning btn-warning btn-sm">
4
4
  <%= dynamic_scaffold_icon :save %> <%= t('dynamic_scaffold.button.save_order') %>
5
5
  </button>
@@ -1,5 +1,5 @@
1
1
  <div class="card mb-2 nested-fields">
2
- <div class="card-header text-right p-2">
2
+ <div class="card-header text-right text-end p-2">
3
3
  <%= link_to_remove_association dynamic_scaffold_icon(:delete), f, class: 'btn btn-danger btn-sm' %>
4
4
  </div>
5
5
  <div class="card-body">
@@ -30,8 +30,8 @@
30
30
  <div class="js-ds-image-wrapper">
31
31
  <div class="js-ds-image-preview panel panel-default card mb-1">
32
32
  <% if elem.options[:removable] %>
33
- <div class="text-right panel-heading card-header">
34
- <button type="button" class="btn btn-outline-danger btn-danger btn-sm js-ds-image-remove">
33
+ <div class="text-right text-end panel-heading card-header">
34
+ <button type="button" class="btn btn-danger btn-sm js-ds-image-remove">
35
35
  <%= dynamic_scaffold_icon :times %>
36
36
  </button>
37
37
  </div>
@@ -39,7 +39,7 @@
39
39
  <div class="panel-body card-body">
40
40
  <%- if elem.cropper.present? -%>
41
41
  <%= form.hidden_field "cropper_#{elem.name}", class: "js-ds-image-cropper", data:{options: elem.cropper.to_json} %>
42
- <div class="text-right" style="height: 24px;">
42
+ <div class="text-right text-end" style="height: 24px;">
43
43
  <span class="js-ds-image-cropper-display badge badge-primary"></span>
44
44
  </div>
45
45
  <%- end -%>
@@ -49,7 +49,7 @@
49
49
  </div>
50
50
  </div>
51
51
  <%= form.hidden_field "remove_#{elem.name}", value: "1", disabled:"disabled", class: 'js-ds-image-remove-flag' if elem.options[:removable]%>
52
- <%= elem.render(self, form, 'form-control-file js-ds-image') do |attr|%>
52
+ <%= elem.render(self, form, 'form-control js-ds-image') do |attr|%>
53
53
  <%= form.file_field(elem.name, attr) %>
54
54
  <%end%>
55
55
  <%= form.hidden_field "#{elem.name}_cache" %>
@@ -59,7 +59,7 @@
59
59
  <%- locale_errors = elem.locale_errors(locale, form) -%>
60
60
  <%= form.globalize_fields_for(locale) do |gform|%>
61
61
  <div class="<%= class_names('ds-globalize-group', 'has-error': locale_errors.present?) %>">
62
- <%= tag.span(elem.lang_attributes('ds-globalize-lang')) do%>
62
+ <%= tag.span(**elem.lang_attributes('ds-globalize-lang')) do%>
63
63
  <%= name %>
64
64
  <%end%>
65
65
  <%= elem.render(self, gform, class_names('form-control', {'is-invalid': locale_errors.present?})) %>
@@ -79,11 +79,10 @@
79
79
  partial: 'dynamic_scaffold/bootstrap/form/cocoon',
80
80
  render_options: { locals: { items: elem.form.items, depth: depth } }
81
81
  ) %>
82
- <% elsif elem.type?(:date_select, :datetime_select) %>
82
+ <% elsif elem.type?(:date_select, :datetime_select, :time_select) %>
83
83
  <div class="form-inline">
84
- <%== elem.render(self, form, class_names('form-control mr-2', {'is-invalid': errors.present?}))
85
- .gsub(/ &mdash; /, '<span class="m-2" style="display: inline-block;">&nbsp;</span>')
86
- .gsub(/ : /, '<span class="mr-2" style="display: inline-block;">:</span>')
84
+ <%== elem.render(self, form, class_names('form-select mr-2 me-2 mb-1', {'is-invalid': errors.present?}))
85
+ .gsub(/^(.*) &mdash; (.*) : (.*)/m, '<div class="mr-3 me-3" style="display: inline-block;">\1</div><div style="display: inline-block;">\2<span class="ds-time-sep">:</span>\3</div>')
87
86
  %>
88
87
  </div>
89
88
  <% elsif elem.type?(:json_object) %>
@@ -92,8 +91,10 @@
92
91
  <%= render 'dynamic_scaffold/bootstrap/form/row', form: child_form, elem: child_elem, depth: depth %>
93
92
  <% end %>
94
93
  <% end %>
94
+ <% elsif elem.type?(:collection_select, :grouped_collection_select) %>
95
+ <%= elem.render(self, form, class_names('form-select', {'is-invalid': errors.present?})) %>
95
96
  <% else %>
96
- <%= elem.render(self, form, class_names('form-control', {'is-invalid': errors.present?})) %>
97
+ <%= elem.render(self, form, class_names('form-control', {'is-invalid': errors.present?}), { autocomplete: 'new-password' }) %>
97
98
  <% end %>
98
99
  <%- elem.insert(:after).each do |block| -%>
99
100
  <%= self.instance_exec(@record, &block) %>
@@ -9,12 +9,23 @@ en:
9
9
  index: 'List'
10
10
  edit: 'Edit'
11
11
  new: 'Create'
12
+ button:
13
+ add: 'Add'
14
+ edit: 'Edit'
15
+ save_order: 'Sort'
16
+ save: 'Save'
17
+ back: 'Back'
12
18
  message:
13
19
  no_records: '%{model} was not found.'
14
20
  destroy_confirm: 'Are you sure you want to delete this?'
15
21
  confirm_cancel: 'Cancel'
16
22
  confirm_ok: 'OK'
23
+ sort_error: 'The sort has been failed, because the following record failed to save.'
17
24
  alert:
18
25
  destroy:
19
26
  invalid_foreign_key: 'That item can not be deleted because it has associated record(s).'
20
- failed: 'That item can not be deleted'
27
+ failed: 'That item can not be deleted'
28
+ count: '%{count} items'
29
+ views:
30
+ pagination:
31
+ truncate: '…'
@@ -20,10 +20,12 @@ ja:
20
20
  destroy_confirm: '削除します。よろしいですか?'
21
21
  confirm_cancel: 'キャンセル'
22
22
  confirm_ok: 'OK'
23
+ sort_error: '下記のレコードの保存に失敗したため、ソートを完了できませんでした。'
23
24
  alert:
24
25
  destroy:
25
26
  invalid_foreign_key: '関連づいたレコードがあるので削除できません。'
26
27
  failed: '削除に失敗しました。'
28
+ count: '%{count} 件'
27
29
  views:
28
30
  pagination:
29
31
  truncate: '…'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicScaffold
4
- module Controller
4
+ module Controller # rubocop:disable Metrics/ModuleLength
5
5
  extend ActiveSupport::Concern
6
6
  include ControllerUtilities
7
7
 
@@ -78,6 +78,7 @@ module DynamicScaffold
78
78
  if @record.save
79
79
  redirect_to dynamic_scaffold_path(:index, request_queries)
80
80
  else
81
+ before_render_form_with_errors(@record)
81
82
  render "#{params[:controller]}/new"
82
83
  end
83
84
  end
@@ -111,6 +112,7 @@ module DynamicScaffold
111
112
  if @record.save
112
113
  redirect_to dynamic_scaffold_path(:index, request_queries)
113
114
  else
115
+ before_render_form_with_errors(@record)
114
116
  render "#{params[:controller]}/edit"
115
117
  end
116
118
  end
@@ -137,18 +139,26 @@ module DynamicScaffold
137
139
  redirect_to dynamic_scaffold_path(:index, request_queries)
138
140
  end
139
141
 
140
- def sort
142
+ def sort # rubocop:disable Metrics/AbcSize
141
143
  pkeys_list = sort_params
142
144
  reset_sequence(pkeys_list.size)
143
- dynamic_scaffold.model.transaction do
144
- pkeys_list.each do |pkeys|
145
- rec = find_record(pkeys.to_hash)
146
- next_sec = next_sequence!
147
- rec[dynamic_scaffold.list.sorter_attribute] = next_sec
148
- yield(rec) if block_given?
149
- rec.save!
145
+
146
+ begin
147
+ dynamic_scaffold.model.transaction do
148
+ pkeys_list.each do |pkeys|
149
+ rec = find_record(pkeys.to_hash)
150
+ next_sec = next_sequence!
151
+ rec[dynamic_scaffold.list.sorter_attribute] = next_sec
152
+ yield(rec) if block_given?
153
+ rec.save!
154
+ end
150
155
  end
156
+ rescue ActiveRecord::RecordInvalid => e
157
+ messages = [I18n.t('dynamic_scaffold.message.sort_error'), '', sort_validation_error_title(e.record)]
158
+ messages.concat(e.record.errors.full_messages)
159
+ flash[:dynamic_scaffold_danger] = messages.join('<br>')
151
160
  end
161
+
152
162
  redirect_to dynamic_scaffold_path(:index, request_queries)
153
163
  end
154
164
  end
@@ -147,5 +147,11 @@ module DynamicScaffold
147
147
  .page(params[dynamic_scaffold.list.pagination.param_name])
148
148
  .per(dynamic_scaffold.list.pagination.per_page)
149
149
  end
150
+
151
+ def sort_validation_error_title(record)
152
+ "ID: #{record.id}"
153
+ end
154
+
155
+ def before_render_form_with_errors(record); end
150
156
  end
151
157
  end
@@ -178,10 +178,11 @@ module DynamicScaffold
178
178
 
179
179
  protected
180
180
 
181
- def build_html_attributes(classnames)
181
+ def build_html_attributes(classnames, html_attributes = {})
182
182
  classnames_list = @classnames_list
183
183
  classnames_list = [*classnames_list, classnames] if classnames
184
- options = @html_attributes.dup
184
+ # Attributes supplied by the view are defaults; explicit field settings take priority.
185
+ options = html_attributes.stringify_keys.merge(@html_attributes.stringify_keys)
185
186
  options[:class] = classnames_list.join(' ') unless classnames_list.empty?
186
187
  options
187
188
  end
@@ -9,7 +9,9 @@ module DynamicScaffold
9
9
  @block = block
10
10
  end
11
11
 
12
- def render(view, form, classnames = nil)
12
+ # The `block` renders the return value of the block, so html_attributes is not relevant,
13
+ # but it is called with `autocomplete="new-password"` because of the `if` statement in _row.html.erb.
14
+ def render(view, form, classnames = nil, _html_attributes = {})
13
15
  view.instance_exec(form, self, classnames, &@block)
14
16
  end
15
17
  end
@@ -28,8 +28,8 @@ module DynamicScaffold
28
28
  end
29
29
  end
30
30
 
31
- def render(_view, _form, classnames = nil)
32
- html_attributes = build_html_attributes(classnames)
31
+ def render(_view, _form, classnames = nil, html_attributes = {})
32
+ html_attributes = build_html_attributes(classnames, html_attributes)
33
33
  yield(html_attributes)
34
34
  end
35
35
 
@@ -11,8 +11,8 @@ module DynamicScaffold
11
11
  super(config, type, name, html_attributes)
12
12
  end
13
13
 
14
- def render(view, form, classnames = nil)
15
- html_attributes = build_html_attributes(classnames)
14
+ def render(view, form, classnames = nil, html_attributes = {})
15
+ html_attributes = build_html_attributes(classnames, html_attributes)
16
16
  # Retain the value of the password field on error.
17
17
  html_attributes[:value] = form.object.public_send(@name) if @type == :password_field
18
18
  form.public_send(@type, @name, *build_args(view, @args), html_attributes)
@@ -20,8 +20,8 @@ module DynamicScaffold
20
20
  super(config, type, name, html_attributes)
21
21
  end
22
22
 
23
- def render(view, form, classnames = nil)
24
- html_attributes = build_html_attributes(classnames)
23
+ def render(view, form, classnames = nil, html_attributes = {})
24
+ html_attributes = build_html_attributes(classnames, html_attributes)
25
25
  form.public_send(@type, @name, *build_args(view, @args), @options, html_attributes)
26
26
  end
27
27
  end
@@ -4,13 +4,13 @@ module DynamicScaffold
4
4
  module Form
5
5
  module Item
6
6
  class TwoOptionsWithBlock < TwoOptions
7
- def render(view, form, classnames = nil)
7
+ def render(view, form, classnames = nil, html_attributes = {})
8
8
  form.public_send(
9
9
  @type,
10
10
  @name,
11
11
  *build_args(view, @args),
12
12
  @options,
13
- build_html_attributes(classnames)
13
+ build_html_attributes(classnames, html_attributes)
14
14
  ) do |builder|
15
15
  yield builder
16
16
  end
@@ -16,6 +16,7 @@ module DynamicScaffold
16
16
  color_field: Form::Item::SingleOption,
17
17
  number_field: Form::Item::SingleOption,
18
18
  telephone_field: Form::Item::SingleOption,
19
+ datetime_local_field: Form::Item::SingleOption,
19
20
 
20
21
  time_select: Form::Item::TwoOptions,
21
22
  date_select: Form::Item::TwoOptions,
@@ -18,7 +18,11 @@ module DynamicScaffold
18
18
  module ClassMethods
19
19
  def json_object_attributte(attribute_name, model)
20
20
  @json_object_attribute_names << attribute_name
21
- serialize attribute_name, model
21
+ if ActiveRecord.gem_version >= Gem::Version.new('7.1')
22
+ serialize attribute_name, coder: model
23
+ else
24
+ serialize attribute_name, model
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicScaffold
4
- VERSION = '2.0.0'
4
+ VERSION = '3.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masamoto Miyata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-20 00:00:00.000000000 Z
11
+ date: 2026-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: classnames-rails-view
@@ -45,9 +45,9 @@ dependencies:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5.0'
48
- - - "<="
48
+ - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: 6.1.4.4
50
+ version: '8.0'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -55,9 +55,9 @@ dependencies:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '5.0'
58
- - - "<="
58
+ - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: 6.1.4.4
60
+ version: '8.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: capybara
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -188,44 +188,44 @@ dependencies:
188
188
  name: rspec
189
189
  requirement: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - '='
191
+ - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: '3.10'
193
+ version: '3.13'
194
194
  type: :development
195
195
  prerelease: false
196
196
  version_requirements: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - '='
198
+ - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: '3.10'
200
+ version: '3.13'
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: rspec-rails
203
203
  requirement: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ">="
205
+ - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '0'
207
+ version: '7.1'
208
208
  type: :development
209
209
  prerelease: false
210
210
  version_requirements: !ruby/object:Gem::Requirement
211
211
  requirements:
212
- - - ">="
212
+ - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: '0'
214
+ version: '7.1'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: rubocop
217
217
  requirement: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - '='
220
220
  - !ruby/object:Gem::Version
221
- version: 0.75.0
221
+ version: 0.89.1
222
222
  type: :development
223
223
  prerelease: false
224
224
  version_requirements: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - '='
227
227
  - !ruby/object:Gem::Version
228
- version: 0.75.0
228
+ version: 0.89.1
229
229
  - !ruby/object:Gem::Dependency
230
230
  name: rubocop-rails
231
231
  requirement: !ruby/object:Gem::Requirement
@@ -246,14 +246,14 @@ dependencies:
246
246
  requirements:
247
247
  - - "~>"
248
248
  - !ruby/object:Gem::Version
249
- version: '1.3'
249
+ version: 1.6.0
250
250
  type: :development
251
251
  prerelease: false
252
252
  version_requirements: !ruby/object:Gem::Requirement
253
253
  requirements:
254
254
  - - "~>"
255
255
  - !ruby/object:Gem::Version
256
- version: '1.3'
256
+ version: 1.6.0
257
257
  description: It is customizable and flexible scaffold who support sort and the pagination.
258
258
  email:
259
259
  - miyata@sincere-co.com
@@ -288,6 +288,7 @@ files:
288
288
  - app/assets/javascripts/dynamic_scaffold/sorter.js
289
289
  - app/assets/stylesheets/dynamic_scaffold/bootstrap3.scss
290
290
  - app/assets/stylesheets/dynamic_scaffold/bootstrap4.scss
291
+ - app/assets/stylesheets/dynamic_scaffold/bootstrap5.scss
291
292
  - app/assets/stylesheets/dynamic_scaffold/common.scss
292
293
  - app/assets/stylesheets/dynamic_scaffold/resplist.scss
293
294
  - app/helpers/dynamic_scaffold_helper.rb
@@ -367,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
368
  - !ruby/object:Gem::Version
368
369
  version: '0'
369
370
  requirements: []
370
- rubygems_version: 3.2.32
371
+ rubygems_version: 3.4.19
371
372
  signing_key:
372
373
  specification_version: 4
373
374
  summary: The Scaffold system which dynamically generates CRUD and sort functions.