cm-admin 1.5.27 → 1.5.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linters.yml +0 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +32 -26
- data/app/views/cm_admin/main/_show_section.html.slim +6 -3
- data/cm_admin.gemspec +1 -1
- data/lib/cm_admin/models/form_field.rb +2 -2
- data/lib/cm_admin/models/row.rb +9 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +18 -1
- data/lib/cm_admin/view_helpers/form_field_helper.rb +117 -49
- data/package-lock.json +3 -3
- data/yarn.lock +3 -3
- metadata +4 -6
- data/.github/workflows/push_gem.yml +0 -79
- data/.reek.yml +0 -9
- /data/.github/workflows/{bump_gem.yml → release-gem.yml} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7935960984bf5a170dbb16e272ce951ab886ae16fcbb131d25fcbaafc31a8e82
|
4
|
+
data.tar.gz: de1756f433cdb23fccf3daaee59e46b8436ca37cee29b5c34808a19d28211989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 315d9e2c449721ac68ae48fe238ad80035208b774c84e31c71f70bf9c4fb3f481ae0ff37d1e9fa76aaa9040106d59a202e7baea257cc2b603ecb7bd4cdc08efc
|
7
|
+
data.tar.gz: 00577270ba1efaee074b670e339e80ee80692414b3ea7ecc2388951443d881bbbc3f5f56866baa4f0b7c907d8a1188f10dd6081fbafce27d268f37bbbb67c276
|
@@ -19,10 +19,6 @@ jobs:
|
|
19
19
|
rubocop_extensions: rubocop-rails:2.14.2
|
20
20
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
21
21
|
reporter: github-pr-check # Possible values are github-pr-check, github-pr-review
|
22
|
-
- name: reek
|
23
|
-
uses: reviewdog/action-reek@v1
|
24
|
-
with:
|
25
|
-
reek_version: 6.1.1
|
26
22
|
- uses: actions/checkout@v3
|
27
23
|
- name: stylelint
|
28
24
|
uses: reviewdog/action-stylelint@v1
|
data/Gemfile
CHANGED
@@ -8,9 +8,9 @@ gem 'rspec', '~> 3.0'
|
|
8
8
|
gem 'slim'
|
9
9
|
|
10
10
|
group :development do
|
11
|
-
gem 'rubocop',
|
12
|
-
gem 'rubocop-
|
13
|
-
gem 'rubocop-
|
11
|
+
gem 'rubocop', require: false
|
12
|
+
gem 'rubocop-performance', require: false
|
13
|
+
gem 'rubocop-rails', require: false
|
14
14
|
end
|
15
15
|
# Specify your gem's dependencies in cm_admin.gemspec
|
16
16
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cm-admin (1.5.
|
4
|
+
cm-admin (1.5.28)
|
5
5
|
caxlsx_rails
|
6
6
|
cocoon (~> 1.2.15)
|
7
7
|
csv-importer (~> 0.8.2)
|
@@ -98,7 +98,7 @@ GEM
|
|
98
98
|
cocoon (1.2.15)
|
99
99
|
coercible (1.0.0)
|
100
100
|
descendants_tracker (~> 0.0.1)
|
101
|
-
concurrent-ruby (1.
|
101
|
+
concurrent-ruby (1.3.3)
|
102
102
|
crass (1.0.6)
|
103
103
|
csv-importer (0.8.2)
|
104
104
|
virtus
|
@@ -110,14 +110,15 @@ GEM
|
|
110
110
|
globalid (1.2.1)
|
111
111
|
activesupport (>= 6.1)
|
112
112
|
htmlentities (4.3.4)
|
113
|
-
i18n (1.14.
|
113
|
+
i18n (1.14.5)
|
114
114
|
concurrent-ruby (~> 1.0)
|
115
115
|
ice_nine (0.11.2)
|
116
116
|
importmap-rails (2.0.1)
|
117
117
|
actionpack (>= 6.0.0)
|
118
118
|
activesupport (>= 6.0.0)
|
119
119
|
railties (>= 6.0.0)
|
120
|
-
json (2.
|
120
|
+
json (2.7.2)
|
121
|
+
language_server-protocol (3.17.0.3)
|
121
122
|
local_time (2.1.0)
|
122
123
|
loofah (2.22.0)
|
123
124
|
crass (~> 1.0.2)
|
@@ -131,7 +132,7 @@ GEM
|
|
131
132
|
method_source (1.1.0)
|
132
133
|
mini_mime (1.1.5)
|
133
134
|
mini_portile2 (2.8.7)
|
134
|
-
minitest (5.
|
135
|
+
minitest (5.24.0)
|
135
136
|
net-imap (0.4.11)
|
136
137
|
date
|
137
138
|
net-protocol
|
@@ -150,13 +151,14 @@ GEM
|
|
150
151
|
nokogiri (1.16.5-x86_64-linux)
|
151
152
|
racc (~> 1.4)
|
152
153
|
pagy (4.11.0)
|
153
|
-
parallel (1.
|
154
|
-
parser (3.
|
154
|
+
parallel (1.25.1)
|
155
|
+
parser (3.3.3.0)
|
155
156
|
ast (~> 2.4.1)
|
157
|
+
racc
|
156
158
|
pundit (2.2.0)
|
157
159
|
activesupport (>= 3.0.0)
|
158
160
|
racc (1.8.0)
|
159
|
-
rack (2.2.
|
161
|
+
rack (2.2.9)
|
160
162
|
rack-proxy (0.7.7)
|
161
163
|
rack
|
162
164
|
rack-test (2.1.0)
|
@@ -191,8 +193,9 @@ GEM
|
|
191
193
|
zeitwerk (~> 2.5)
|
192
194
|
rainbow (3.1.1)
|
193
195
|
rake (12.3.3)
|
194
|
-
regexp_parser (2.
|
195
|
-
rexml (3.
|
196
|
+
regexp_parser (2.9.2)
|
197
|
+
rexml (3.3.0)
|
198
|
+
strscan
|
196
199
|
rspec (3.10.0)
|
197
200
|
rspec-core (~> 3.10.0)
|
198
201
|
rspec-expectations (~> 3.10.0)
|
@@ -206,31 +209,34 @@ GEM
|
|
206
209
|
diff-lcs (>= 1.2.0, < 2.0)
|
207
210
|
rspec-support (~> 3.10.0)
|
208
211
|
rspec-support (3.10.2)
|
209
|
-
rubocop (1.
|
212
|
+
rubocop (1.64.1)
|
210
213
|
json (~> 2.3)
|
214
|
+
language_server-protocol (>= 3.17.0)
|
211
215
|
parallel (~> 1.10)
|
212
|
-
parser (>= 3.
|
216
|
+
parser (>= 3.3.0.2)
|
213
217
|
rainbow (>= 2.2.2, < 4.0)
|
214
218
|
regexp_parser (>= 1.8, < 3.0)
|
215
219
|
rexml (>= 3.2.5, < 4.0)
|
216
|
-
rubocop-ast (>= 1.
|
220
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
217
221
|
ruby-progressbar (~> 1.7)
|
218
|
-
unicode-display_width (>=
|
219
|
-
rubocop-ast (1.
|
220
|
-
parser (>= 3.
|
221
|
-
rubocop-performance (1.
|
222
|
-
rubocop (>= 1.
|
223
|
-
rubocop-ast (>=
|
224
|
-
rubocop-rails (2.
|
222
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
223
|
+
rubocop-ast (1.31.3)
|
224
|
+
parser (>= 3.3.1.0)
|
225
|
+
rubocop-performance (1.21.1)
|
226
|
+
rubocop (>= 1.48.1, < 2.0)
|
227
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
228
|
+
rubocop-rails (2.25.0)
|
225
229
|
activesupport (>= 4.2.0)
|
226
230
|
rack (>= 1.1)
|
227
|
-
rubocop (>= 1.
|
228
|
-
|
231
|
+
rubocop (>= 1.33.0, < 2.0)
|
232
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
233
|
+
ruby-progressbar (1.13.0)
|
229
234
|
rubyzip (2.3.2)
|
230
235
|
semantic_range (3.0.0)
|
231
236
|
slim (4.1.0)
|
232
237
|
temple (>= 0.7.6, < 0.9)
|
233
238
|
tilt (>= 2.0.6, < 2.1)
|
239
|
+
strscan (3.1.0)
|
234
240
|
temple (0.8.2)
|
235
241
|
thor (1.3.1)
|
236
242
|
thread_safe (0.3.6)
|
@@ -238,7 +244,7 @@ GEM
|
|
238
244
|
timeout (0.4.1)
|
239
245
|
tzinfo (2.0.6)
|
240
246
|
concurrent-ruby (~> 1.0)
|
241
|
-
unicode-display_width (2.
|
247
|
+
unicode-display_width (2.5.0)
|
242
248
|
virtus (2.0.0)
|
243
249
|
axiom-types (~> 0.1)
|
244
250
|
coercible (~> 1.0)
|
@@ -267,9 +273,9 @@ DEPENDENCIES
|
|
267
273
|
pundit
|
268
274
|
rake (~> 12.0)
|
269
275
|
rspec (~> 3.0)
|
270
|
-
rubocop
|
271
|
-
rubocop-performance
|
272
|
-
rubocop-rails
|
276
|
+
rubocop
|
277
|
+
rubocop-performance
|
278
|
+
rubocop-rails
|
273
279
|
slim
|
274
280
|
|
275
281
|
BUNDLED WITH
|
@@ -4,7 +4,10 @@
|
|
4
4
|
p.section-heading = section.section_name
|
5
5
|
.card
|
6
6
|
.card-body
|
7
|
-
- section.section_fields.
|
8
|
-
|
7
|
+
- if !section.section_fields.empty?
|
8
|
+
- section.section_fields.each do |field|
|
9
|
+
= show_field(@ar_object, field)
|
10
|
+
- if section.rows.present?
|
11
|
+
= show_rows(@ar_object, section.rows)
|
9
12
|
- section.nested_table_fields.each do |nested_field|
|
10
|
-
= render partial: 'cm_admin/main/nested_table_section', locals: { nested_field: nested_field, ar_object: @ar_object }
|
13
|
+
= render partial: 'cm_admin/main/nested_table_section', locals: { nested_field: nested_field, ar_object: @ar_object }
|
data/cm_admin.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = 'CmAdmin providing a streamlined and efficient solution for building customized admin panels within the context of Rails applications. Its robust features empower developers to effortlessly generate and manage administrative interfaces with precision and ease.'
|
11
11
|
spec.homepage = 'https://github.com/commutatus/cm-admin'
|
12
12
|
spec.license = 'MIT'
|
13
|
-
spec.required_ruby_version = '>=
|
13
|
+
spec.required_ruby_version = '>= 2.7.0'
|
14
14
|
|
15
15
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
16
|
|
@@ -6,7 +6,7 @@ module CmAdmin
|
|
6
6
|
include Utils::Helpers
|
7
7
|
|
8
8
|
attr_accessor :field_name, :label, :header, :input_type, :collection, :disabled, :helper_method,
|
9
|
-
:placeholder, :display_if, :
|
9
|
+
:placeholder, :display_if, :html_attrs, :target, :col_size, :ajax_url
|
10
10
|
|
11
11
|
VALID_INPUT_TYPES = %i[
|
12
12
|
integer decimal string single_select multi_select date date_time text
|
@@ -28,7 +28,7 @@ module CmAdmin
|
|
28
28
|
self.disabled = lambda { |arg| return false } if display_if.nil?
|
29
29
|
self.label = self.field_name.to_s.titleize
|
30
30
|
self.input_type = :string
|
31
|
-
self.
|
31
|
+
self.html_attrs = {}
|
32
32
|
self.target = {}
|
33
33
|
self.col_size = nil
|
34
34
|
end
|
data/lib/cm_admin/models/row.rb
CHANGED
@@ -27,6 +27,14 @@ module CmAdmin
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def field(field_name, options={})
|
31
|
+
if @current_nested_field
|
32
|
+
@current_nested_field.fields << CmAdmin::Models::Field.new(field_name, options)
|
33
|
+
else
|
34
|
+
@row_fields << CmAdmin::Models::Field.new(field_name, options)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
30
38
|
def cm_section(section_name, col_size: nil, display_if: nil, &block)
|
31
39
|
@sections << CmAdmin::Models::Section.new(section_name, @current_action, @model, display_if, col_size, &block)
|
32
40
|
end
|
@@ -37,4 +45,4 @@ module CmAdmin
|
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
40
|
-
end
|
48
|
+
end
|
data/lib/cm_admin/version.rb
CHANGED
@@ -9,6 +9,23 @@ module CmAdmin
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
def show_rows(ar_object, rows, col_size: 3)
|
13
|
+
rows.map do |row|
|
14
|
+
content_tag(:div, class: 'row') do
|
15
|
+
row.row_fields.map do |field|
|
16
|
+
next unless field.display_if.call(ar_object)
|
17
|
+
|
18
|
+
content_tag(:div, class: "col-#{col_size}") do
|
19
|
+
content_tag(:div, class: "card-info") do
|
20
|
+
concat show_field_label(ar_object, field)
|
21
|
+
concat value_with_prefix_and_suffix(ar_object, field)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end.compact.join.html_safe
|
25
|
+
end
|
26
|
+
end.join.html_safe
|
27
|
+
end
|
28
|
+
|
12
29
|
def show_field_label(ar_object, field)
|
13
30
|
content_tag(:div, class: "card-info__label") do
|
14
31
|
field_label = if field.label.present?
|
@@ -71,7 +88,7 @@ module CmAdmin
|
|
71
88
|
when :tag
|
72
89
|
tag_class = field.tag_class.dig("#{ar_object.send(field.field_name.to_s)}".to_sym).to_s
|
73
90
|
content_tag :span, class: "status-tag #{tag_class}" do
|
74
|
-
ar_object.send(field.field_name).to_s.upcase
|
91
|
+
ar_object.send(field.field_name).to_s.titleize.upcase
|
75
92
|
end
|
76
93
|
when :attachment
|
77
94
|
show_attachment_value(ar_object, field)
|
@@ -19,57 +19,73 @@ module CmAdmin
|
|
19
19
|
|
20
20
|
def cm_integer_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
21
21
|
form_obj.text_field cm_field.field_name,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
merge_wrapper_options(
|
23
|
+
{
|
24
|
+
class: "field-control #{required_class}",
|
25
|
+
disabled: cm_field.disabled.call(form_obj.object),
|
26
|
+
value: value,
|
27
|
+
placeholder: cm_field.placeholder,
|
28
|
+
data: { behaviour: 'integer-only' }
|
29
|
+
}, cm_field.html_attrs )
|
27
30
|
end
|
28
31
|
|
29
32
|
def cm_decimal_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
30
33
|
form_obj.text_field cm_field.field_name,
|
34
|
+
merge_wrapper_options({
|
31
35
|
class: "field-control #{required_class}",
|
32
36
|
disabled: cm_field.disabled.call(form_obj.object),
|
33
37
|
value: value,
|
34
38
|
placeholder: cm_field.placeholder,
|
35
39
|
data: { behaviour: 'decimal-only' }
|
40
|
+
}, cm_field.html_attrs )
|
36
41
|
end
|
37
42
|
|
38
43
|
def cm_string_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
39
44
|
form_obj.text_field cm_field.field_name,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
merge_wrapper_options(
|
46
|
+
{
|
47
|
+
class: "field-control #{required_class}",
|
48
|
+
disabled: cm_field.disabled.call(form_obj.object),
|
49
|
+
value: value,
|
50
|
+
placeholder: cm_field.placeholder
|
51
|
+
}, cm_field.html_attrs )
|
44
52
|
end
|
45
53
|
|
46
54
|
def cm_custom_string_field(form_obj, cm_field, value, required_class, _target_action)
|
47
|
-
text_field_tag cm_field.
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
text_field_tag cm_field.html_attrs[:name] || cm_field.field_name,
|
56
|
+
merge_wrapper_options(
|
57
|
+
{
|
58
|
+
value: value,
|
59
|
+
class: "field-control #{required_class}",
|
60
|
+
disabled: cm_field.disabled.call(form_obj.object),
|
61
|
+
placeholder: cm_field.placeholder
|
62
|
+
}, cm_field.html_attrs )
|
51
63
|
end
|
52
64
|
|
53
65
|
def cm_single_select_field(form_obj, cm_field, value, required_class, target_action, ajax_url)
|
54
66
|
class_name = ajax_url.present? ? 'select-2-ajax' : 'select-2'
|
55
67
|
form_obj.select cm_field.field_name, options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
|
56
|
-
{
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
68
|
+
{include_blank: cm_field.placeholder},
|
69
|
+
merge_wrapper_options(
|
70
|
+
{
|
71
|
+
class: "field-control #{required_class} #{class_name}",
|
72
|
+
disabled: cm_field.disabled.call(form_obj.object),
|
73
|
+
data: {
|
74
|
+
field_name: cm_field.field_name,
|
75
|
+
field_type: 'linked-field',
|
76
|
+
target_action: target_action&.name,
|
77
|
+
target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : '',
|
78
|
+
ajax_url: ajax_url
|
79
|
+
}
|
80
|
+
}, cm_field.html_attrs )
|
66
81
|
end
|
67
82
|
|
68
83
|
def cm_custom_single_select_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
|
69
|
-
select_tag cm_field.
|
84
|
+
select_tag cm_field.html_attrs[:name] || cm_field.field_name,
|
70
85
|
options_for_select(select_collection_value(form_obj.object, cm_field)),
|
86
|
+
{include_blank: cm_field.placeholder}
|
87
|
+
merge_wrapper_options(
|
71
88
|
{
|
72
|
-
include_blank: cm_field.placeholder,
|
73
89
|
class: "field-control #{required_class} select-2",
|
74
90
|
disabled: cm_field.disabled.call(form_obj.object),
|
75
91
|
data: {
|
@@ -78,66 +94,94 @@ module CmAdmin
|
|
78
94
|
target_action: target_action&.name,
|
79
95
|
target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
|
80
96
|
}
|
81
|
-
}
|
97
|
+
}, cm_field.html_attrs )
|
82
98
|
end
|
83
99
|
|
84
100
|
def cm_multi_select_field(form_obj, cm_field, value, required_class, target_action, _ajax_url)
|
85
101
|
form_obj.select cm_field.field_name,
|
86
102
|
options_for_select(select_collection_value(form_obj.object, cm_field), form_obj.object.send(cm_field.field_name)),
|
87
|
-
{
|
88
|
-
|
89
|
-
|
103
|
+
{include_blank: cm_field.placeholder}
|
104
|
+
merge_wrapper_options(
|
105
|
+
{
|
106
|
+
class: "field-control #{required_class} select-2",
|
107
|
+
disabled: cm_field.disabled.call(form_obj.object), multiple: true
|
108
|
+
}, cm_field.html_attrs )
|
90
109
|
end
|
91
110
|
|
92
111
|
def cm_date_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
93
112
|
form_obj.text_field cm_field.field_name,
|
113
|
+
merge_wrapper_options(
|
114
|
+
{
|
94
115
|
class: "field-control #{required_class}",
|
95
116
|
disabled: cm_field.disabled.call(form_obj.object),
|
96
117
|
value: value&.strftime('%d-%m-%Y'),
|
97
118
|
placeholder: cm_field.placeholder,
|
98
119
|
data: { behaviour: 'date-only' }
|
120
|
+
}, cm_field.html_attrs )
|
99
121
|
end
|
100
122
|
|
101
123
|
def cm_custom_date_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
102
|
-
text_field_tag cm_field.
|
124
|
+
text_field_tag cm_field.html_attrs[:name] || cm_field.field_name, value&.strftime('%d-%m-%Y'),
|
125
|
+
merge_wrapper_options(
|
126
|
+
{
|
103
127
|
class: "field-control #{required_class}",
|
104
128
|
disabled: cm_field.disabled.call(form_obj.object),
|
105
129
|
value: value&.strftime('%d-%m-%Y'),
|
106
130
|
placeholder: cm_field.placeholder,
|
107
131
|
data: { behaviour: 'date-only' }
|
132
|
+
}, cm_field.html_attrs )
|
108
133
|
end
|
109
134
|
|
110
135
|
def cm_date_time_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
111
136
|
form_obj.text_field cm_field.field_name,
|
137
|
+
merge_wrapper_options(
|
138
|
+
{
|
112
139
|
class: "field-control #{required_class}",
|
113
140
|
disabled: cm_field.disabled.call(form_obj.object),
|
114
141
|
value: value,
|
115
142
|
placeholder: cm_field.placeholder,
|
116
143
|
data: { behaviour: 'date-time' }
|
144
|
+
}, cm_field.html_attrs )
|
117
145
|
end
|
118
146
|
|
119
147
|
def cm_text_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
120
148
|
form_obj.text_area cm_field.field_name,
|
121
|
-
|
122
|
-
|
149
|
+
merge_wrapper_options(
|
150
|
+
{
|
151
|
+
class: "field-control #{required_class}",
|
152
|
+
placeholder: cm_field.placeholder
|
153
|
+
}, cm_field.html_attrs)
|
123
154
|
end
|
124
155
|
|
125
156
|
def cm_rich_text_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
126
157
|
form_obj.rich_text_area cm_field.field_name,
|
127
|
-
|
128
|
-
|
158
|
+
merge_wrapper_options(
|
159
|
+
{
|
160
|
+
class: "field-control #{required_class}",
|
161
|
+
placeholder: cm_field.placeholder
|
162
|
+
}, cm_field.html_attrs)
|
129
163
|
end
|
130
164
|
|
131
165
|
def cm_single_file_upload_field(form_obj, cm_field, _value, required_class, _target_action, _ajax_url)
|
132
166
|
content_tag(:div) do
|
133
|
-
concat form_obj.file_field cm_field.field_name,
|
167
|
+
concat form_obj.file_field cm_field.field_name,
|
168
|
+
merge_wrapper_options(
|
169
|
+
{
|
170
|
+
class: "field-control #{required_class}",
|
171
|
+
disabled: cm_field.disabled.call(form_obj.object)
|
172
|
+
}, cm_field.html_attrs )
|
134
173
|
concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
135
174
|
end
|
136
175
|
end
|
137
176
|
|
138
177
|
def cm_multi_file_upload_field(form_obj, cm_field, _value, required_class, _target_action, _ajax_url)
|
139
178
|
content_tag(:div) do
|
140
|
-
concat form_obj.file_field cm_field.field_name,
|
179
|
+
concat form_obj.file_field cm_field.field_name,
|
180
|
+
merge_wrapper_options(
|
181
|
+
{
|
182
|
+
multiple: true, class: "field-control #{required_class}",
|
183
|
+
disabled: cm_field.disabled.call(form_obj.object)
|
184
|
+
}, cm_field.html_attrs )
|
141
185
|
concat attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
142
186
|
end
|
143
187
|
end
|
@@ -145,7 +189,7 @@ module CmAdmin
|
|
145
189
|
def attachment_list(form_obj, cm_field, _value, required_class, _target_action)
|
146
190
|
attached = form_obj.object.send(cm_field.field_name)
|
147
191
|
return if defined?(::Paperclip) && attached.instance_of?(::Paperclip::Attachment)
|
148
|
-
|
192
|
+
|
149
193
|
content_tag(:div) do
|
150
194
|
if attached.class == ActiveStorage::Attached::Many
|
151
195
|
attached.each do |attachment|
|
@@ -176,8 +220,11 @@ module CmAdmin
|
|
176
220
|
|
177
221
|
def cm_hidden_field(form_obj, cm_field, value, required_class, _target_action, _ajax_url)
|
178
222
|
form_obj.hidden_field cm_field.field_name,
|
179
|
-
|
180
|
-
|
223
|
+
merge_wrapper_options(
|
224
|
+
{
|
225
|
+
value: value,
|
226
|
+
name: cm_field.html_attrs[:name] || "#{form_obj.object_name}[#{cm_field.field_name}]"
|
227
|
+
}, cm_field.html_attrs )
|
181
228
|
end
|
182
229
|
|
183
230
|
# Refactor: Collection argument can be removed.
|
@@ -197,15 +244,16 @@ module CmAdmin
|
|
197
244
|
format_check_box_array(value, form_obj, cm_field, required_class, target_action)
|
198
245
|
else
|
199
246
|
form_obj.check_box cm_field.field_name,
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
247
|
+
merge_wrapper_options(
|
248
|
+
{
|
249
|
+
class: "cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
|
250
|
+
disabled: cm_field.disabled.call(form_obj.object),
|
251
|
+
data: {
|
252
|
+
field_name: cm_field.field_name,
|
253
|
+
target_action: target_action&.name,
|
254
|
+
target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path") : ''
|
255
|
+
}
|
256
|
+
}, cm_field.html_attrs )
|
209
257
|
end
|
210
258
|
end
|
211
259
|
|
@@ -227,6 +275,7 @@ module CmAdmin
|
|
227
275
|
def format_check_box_tag(val, form_obj, cm_field, required_class, target_action)
|
228
276
|
content_tag :div, class: 'cm-radio-tag' do
|
229
277
|
concat form_obj.check_box cm_field.field_name,
|
278
|
+
merge_wrapper_options(
|
230
279
|
{
|
231
280
|
class: "cm-checkbox #{required_class} #{target_action.present? ? 'linked-field-request' : ''}",
|
232
281
|
disabled: cm_field.disabled.call(form_obj.object),
|
@@ -235,7 +284,8 @@ module CmAdmin
|
|
235
284
|
target_action: target_action&.name,
|
236
285
|
target_url: target_action&.name ? cm_admin.send("#{@model.name.underscore}_#{target_action&.name}_path", ':param_1') : ''
|
237
286
|
}
|
238
|
-
},
|
287
|
+
}, cm_field.html_attrs ),
|
288
|
+
val
|
239
289
|
end
|
240
290
|
end
|
241
291
|
|
@@ -259,6 +309,24 @@ module CmAdmin
|
|
259
309
|
concat form_obj.radio_button :level, val, class: 'field-control cm-radio'
|
260
310
|
end
|
261
311
|
end
|
312
|
+
|
313
|
+
def merge_wrapper_options(options, html_attrs)
|
314
|
+
if html_attrs
|
315
|
+
options.merge(html_attrs) do |key, oldval, newval|
|
316
|
+
case key.to_s
|
317
|
+
when "class"
|
318
|
+
oldval + " " + newval
|
319
|
+
when "data", "aria"
|
320
|
+
oldval.merge(newval)
|
321
|
+
else
|
322
|
+
newval
|
323
|
+
end
|
324
|
+
end
|
325
|
+
else
|
326
|
+
options
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
262
330
|
end
|
263
331
|
end
|
264
332
|
end
|
data/package-lock.json
CHANGED
@@ -13650,9 +13650,9 @@
|
|
13650
13650
|
}
|
13651
13651
|
},
|
13652
13652
|
"node_modules/ws": {
|
13653
|
-
"version": "8.
|
13654
|
-
"resolved": "https://registry.npmjs.org/ws/-/ws-8.
|
13655
|
-
"integrity": "sha512-
|
13653
|
+
"version": "8.17.1",
|
13654
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
13655
|
+
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
13656
13656
|
"dev": true,
|
13657
13657
|
"engines": {
|
13658
13658
|
"node": ">=10.0.0"
|
data/yarn.lock
CHANGED
@@ -7717,9 +7717,9 @@ write-file-atomic@^4.0.2:
|
|
7717
7717
|
signal-exit "^3.0.7"
|
7718
7718
|
|
7719
7719
|
ws@^8.4.2:
|
7720
|
-
version "8.
|
7721
|
-
resolved "https://registry.
|
7722
|
-
integrity sha512-
|
7720
|
+
version "8.17.1"
|
7721
|
+
resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"
|
7722
|
+
integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==
|
7723
7723
|
|
7724
7724
|
xtend@^4.0.0, xtend@~4.0.1:
|
7725
7725
|
version "4.0.2"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sajinmp
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-06-
|
13
|
+
date: 2024-06-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: caxlsx_rails
|
@@ -167,11 +167,9 @@ files:
|
|
167
167
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
168
168
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
169
169
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
170
|
-
- ".github/workflows/bump_gem.yml"
|
171
170
|
- ".github/workflows/linters.yml"
|
172
|
-
- ".github/workflows/
|
171
|
+
- ".github/workflows/release-gem.yml"
|
173
172
|
- ".gitignore"
|
174
|
-
- ".reek.yml"
|
175
173
|
- ".rspec"
|
176
174
|
- ".rubocop-https---raw-githubusercontent-com-commutatus-cm-linters-main-rubocop-yml"
|
177
175
|
- ".rubocop.yml"
|
@@ -493,7 +491,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
493
491
|
requirements:
|
494
492
|
- - ">="
|
495
493
|
- !ruby/object:Gem::Version
|
496
|
-
version:
|
494
|
+
version: 2.7.0
|
497
495
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
498
496
|
requirements:
|
499
497
|
- - ">="
|
@@ -1,79 +0,0 @@
|
|
1
|
-
name: Push & Release Gem Gem
|
2
|
-
|
3
|
-
on:
|
4
|
-
workflow_dispatch:
|
5
|
-
inputs:
|
6
|
-
bump_type:
|
7
|
-
type: choice
|
8
|
-
description: "Bump Type ( Choosing None will bump build number and keep the same version )"
|
9
|
-
default: "patch"
|
10
|
-
options:
|
11
|
-
- patch
|
12
|
-
- minor
|
13
|
-
- major
|
14
|
-
|
15
|
-
|
16
|
-
permissions:
|
17
|
-
contents: read
|
18
|
-
|
19
|
-
jobs:
|
20
|
-
build:
|
21
|
-
name: Build gem
|
22
|
-
runs-on: ubuntu-latest
|
23
|
-
|
24
|
-
permissions:
|
25
|
-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
26
|
-
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
|
27
|
-
|
28
|
-
steps:
|
29
|
-
# Set up
|
30
|
-
- uses: actions/checkout@v4
|
31
|
-
|
32
|
-
- name: set git config
|
33
|
-
env:
|
34
|
-
GH_TOKEN: ${{ github.token }}
|
35
|
-
run: |
|
36
|
-
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
|
37
|
-
git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)"
|
38
|
-
git config -l
|
39
|
-
- name: Set up Ruby
|
40
|
-
uses: ruby/setup-ruby@v1
|
41
|
-
with:
|
42
|
-
bundler-cache: true
|
43
|
-
ruby-version: ruby
|
44
|
-
|
45
|
-
- name: Install the gem-release
|
46
|
-
run: gem install gem-release
|
47
|
-
|
48
|
-
- name: Bump the gem
|
49
|
-
run: gem bump ${{ github.events.inputs.bump_type }}
|
50
|
-
|
51
|
-
- name: Push the new version
|
52
|
-
run: git push
|
53
|
-
|
54
|
-
release:
|
55
|
-
|
56
|
-
name: Release gem
|
57
|
-
runs-on: ubuntu-latest
|
58
|
-
needs: build
|
59
|
-
permissions:
|
60
|
-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
61
|
-
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
|
62
|
-
|
63
|
-
steps:
|
64
|
-
- uses: actions/checkout@v4
|
65
|
-
|
66
|
-
- name: Git Pull
|
67
|
-
run: git pull
|
68
|
-
|
69
|
-
- name: Set up Ruby
|
70
|
-
uses: ruby/setup-ruby@v1
|
71
|
-
with:
|
72
|
-
ruby-version: ruby
|
73
|
-
|
74
|
-
- name: Remove lock on bundle
|
75
|
-
run: bundle config set frozen false
|
76
|
-
|
77
|
-
- uses: rubygems/release-gem@v1
|
78
|
-
with:
|
79
|
-
await-release: false
|
data/.reek.yml
DELETED
File without changes
|