cm-admin 1.5.9 → 1.5.10
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/.github/workflows/linters.yml +0 -4
- data/.github/workflows/release-gem.yml +92 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +41 -27
- data/app/assets/stylesheets/cm_admin/base/common.scss +2 -2
- data/app/assets/stylesheets/cm_admin/base/filters.scss +14 -3
- data/app/assets/stylesheets/cm_admin/base/table.scss +2 -2
- data/app/views/cm_admin/main/_show_section.html.slim +6 -3
- 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 +7 -7
- data/.reek.yml +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13710f4822ce508ecf0fa69b136368cfc21c2d381414fa002e7e26217ccafc03
|
|
4
|
+
data.tar.gz: 658aec550f94375067dac5e27c4805eb9d9fcae7b201c90e55bd04ee35818c07
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 653d760b396e835a65129ecd591664cc01ae343921aa36a831f0150503530b803deb5305c85b204fc5634b3d449815c55362b2d3bf281bcf03594db500dd5dd1
|
|
7
|
+
data.tar.gz: bb5a3a55e20b0a020039bac2e45498f225224ac5ee249a9646fd9da1b1e00aeb322d3716a16414f19049a06d6423baffa22a6fc48b2c80a238b5c23e062eb8a1
|
|
@@ -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
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
name: Bump 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: Remove lock on bundle
|
|
52
|
+
run: bundle config set frozen false
|
|
53
|
+
|
|
54
|
+
- name: Bundle Install
|
|
55
|
+
run: bundle install
|
|
56
|
+
|
|
57
|
+
- name: Git Add files
|
|
58
|
+
run: git add Gemfile.lock
|
|
59
|
+
|
|
60
|
+
- name: Git Commit
|
|
61
|
+
run: git commit -m "Add bundle files"
|
|
62
|
+
|
|
63
|
+
- name: Push the new version
|
|
64
|
+
run: git push origin ${{ github.ref_name }}
|
|
65
|
+
|
|
66
|
+
release:
|
|
67
|
+
|
|
68
|
+
name: Release gem
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
needs: build
|
|
71
|
+
permissions:
|
|
72
|
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
73
|
+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
|
|
74
|
+
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/checkout@v4
|
|
77
|
+
|
|
78
|
+
- name: Git Pull
|
|
79
|
+
run: git pull
|
|
80
|
+
|
|
81
|
+
- name: Set up Ruby
|
|
82
|
+
uses: ruby/setup-ruby@v1
|
|
83
|
+
with:
|
|
84
|
+
ruby-version: ruby
|
|
85
|
+
bundler-cache: true
|
|
86
|
+
|
|
87
|
+
- name: Remove lock on bundle
|
|
88
|
+
run: bundle config set frozen false
|
|
89
|
+
|
|
90
|
+
- uses: rubygems/release-gem@v1
|
|
91
|
+
with:
|
|
92
|
+
await-release: false
|
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.10)
|
|
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)
|
|
@@ -130,7 +131,8 @@ GEM
|
|
|
130
131
|
marcel (1.0.4)
|
|
131
132
|
method_source (1.1.0)
|
|
132
133
|
mini_mime (1.1.5)
|
|
133
|
-
|
|
134
|
+
mini_portile2 (2.8.7)
|
|
135
|
+
minitest (5.24.0)
|
|
134
136
|
net-imap (0.4.11)
|
|
135
137
|
date
|
|
136
138
|
net-protocol
|
|
@@ -141,16 +143,22 @@ GEM
|
|
|
141
143
|
net-smtp (0.5.0)
|
|
142
144
|
net-protocol
|
|
143
145
|
nio4r (2.7.3)
|
|
146
|
+
nokogiri (1.16.5)
|
|
147
|
+
mini_portile2 (~> 2.8.2)
|
|
148
|
+
racc (~> 1.4)
|
|
144
149
|
nokogiri (1.16.5-arm64-darwin)
|
|
145
150
|
racc (~> 1.4)
|
|
151
|
+
nokogiri (1.16.5-x86_64-linux)
|
|
152
|
+
racc (~> 1.4)
|
|
146
153
|
pagy (4.11.0)
|
|
147
|
-
parallel (1.
|
|
148
|
-
parser (3.
|
|
154
|
+
parallel (1.25.1)
|
|
155
|
+
parser (3.3.3.0)
|
|
149
156
|
ast (~> 2.4.1)
|
|
157
|
+
racc
|
|
150
158
|
pundit (2.2.0)
|
|
151
159
|
activesupport (>= 3.0.0)
|
|
152
160
|
racc (1.8.0)
|
|
153
|
-
rack (2.2.
|
|
161
|
+
rack (2.2.9)
|
|
154
162
|
rack-proxy (0.7.7)
|
|
155
163
|
rack
|
|
156
164
|
rack-test (2.1.0)
|
|
@@ -185,8 +193,9 @@ GEM
|
|
|
185
193
|
zeitwerk (~> 2.5)
|
|
186
194
|
rainbow (3.1.1)
|
|
187
195
|
rake (12.3.3)
|
|
188
|
-
regexp_parser (2.
|
|
189
|
-
rexml (3.
|
|
196
|
+
regexp_parser (2.9.2)
|
|
197
|
+
rexml (3.3.0)
|
|
198
|
+
strscan
|
|
190
199
|
rspec (3.10.0)
|
|
191
200
|
rspec-core (~> 3.10.0)
|
|
192
201
|
rspec-expectations (~> 3.10.0)
|
|
@@ -200,31 +209,34 @@ GEM
|
|
|
200
209
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
201
210
|
rspec-support (~> 3.10.0)
|
|
202
211
|
rspec-support (3.10.2)
|
|
203
|
-
rubocop (1.
|
|
212
|
+
rubocop (1.64.1)
|
|
204
213
|
json (~> 2.3)
|
|
214
|
+
language_server-protocol (>= 3.17.0)
|
|
205
215
|
parallel (~> 1.10)
|
|
206
|
-
parser (>= 3.
|
|
216
|
+
parser (>= 3.3.0.2)
|
|
207
217
|
rainbow (>= 2.2.2, < 4.0)
|
|
208
218
|
regexp_parser (>= 1.8, < 3.0)
|
|
209
219
|
rexml (>= 3.2.5, < 4.0)
|
|
210
|
-
rubocop-ast (>= 1.
|
|
220
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
211
221
|
ruby-progressbar (~> 1.7)
|
|
212
|
-
unicode-display_width (>=
|
|
213
|
-
rubocop-ast (1.
|
|
214
|
-
parser (>= 3.
|
|
215
|
-
rubocop-performance (1.
|
|
216
|
-
rubocop (>= 1.
|
|
217
|
-
rubocop-ast (>=
|
|
218
|
-
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)
|
|
219
229
|
activesupport (>= 4.2.0)
|
|
220
230
|
rack (>= 1.1)
|
|
221
|
-
rubocop (>= 1.
|
|
222
|
-
|
|
231
|
+
rubocop (>= 1.33.0, < 2.0)
|
|
232
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
233
|
+
ruby-progressbar (1.13.0)
|
|
223
234
|
rubyzip (2.3.2)
|
|
224
235
|
semantic_range (3.0.0)
|
|
225
236
|
slim (4.1.0)
|
|
226
237
|
temple (>= 0.7.6, < 0.9)
|
|
227
238
|
tilt (>= 2.0.6, < 2.1)
|
|
239
|
+
strscan (3.1.0)
|
|
228
240
|
temple (0.8.2)
|
|
229
241
|
thor (1.3.1)
|
|
230
242
|
thread_safe (0.3.6)
|
|
@@ -232,7 +244,7 @@ GEM
|
|
|
232
244
|
timeout (0.4.1)
|
|
233
245
|
tzinfo (2.0.6)
|
|
234
246
|
concurrent-ruby (~> 1.0)
|
|
235
|
-
unicode-display_width (2.
|
|
247
|
+
unicode-display_width (2.5.0)
|
|
236
248
|
virtus (2.0.0)
|
|
237
249
|
axiom-types (~> 0.1)
|
|
238
250
|
coercible (~> 1.0)
|
|
@@ -250,6 +262,8 @@ GEM
|
|
|
250
262
|
PLATFORMS
|
|
251
263
|
arm64-darwin-20
|
|
252
264
|
arm64-darwin-22
|
|
265
|
+
arm64-darwin-23
|
|
266
|
+
ruby
|
|
253
267
|
x86_64-linux
|
|
254
268
|
|
|
255
269
|
DEPENDENCIES
|
|
@@ -259,10 +273,10 @@ DEPENDENCIES
|
|
|
259
273
|
pundit
|
|
260
274
|
rake (~> 12.0)
|
|
261
275
|
rspec (~> 3.0)
|
|
262
|
-
rubocop
|
|
263
|
-
rubocop-performance
|
|
264
|
-
rubocop-rails
|
|
276
|
+
rubocop
|
|
277
|
+
rubocop-performance
|
|
278
|
+
rubocop-rails
|
|
265
279
|
slim
|
|
266
280
|
|
|
267
281
|
BUNDLED WITH
|
|
268
|
-
2.
|
|
282
|
+
2.5.13
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
margin-left: 32px;
|
|
30
30
|
cursor: pointer;
|
|
31
31
|
&::before {
|
|
32
|
-
content:
|
|
32
|
+
content: "";
|
|
33
33
|
position: absolute;
|
|
34
34
|
top: -5px;
|
|
35
35
|
left: -16px;
|
|
@@ -78,7 +78,9 @@
|
|
|
78
78
|
&:focus {
|
|
79
79
|
border-color: $brand-color !important;
|
|
80
80
|
outline: 0 !important;
|
|
81
|
-
box-shadow:
|
|
81
|
+
box-shadow:
|
|
82
|
+
inset 0 1px 1px rgba(0, 0, 0, 0.075),
|
|
83
|
+
0 0 8px rgba(102, 175, 233, 0.6) !important;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -95,7 +97,9 @@
|
|
|
95
97
|
&:focus {
|
|
96
98
|
border-color: $brand-color;
|
|
97
99
|
outline: 0;
|
|
98
|
-
box-shadow:
|
|
100
|
+
box-shadow:
|
|
101
|
+
inset 0 1px 1px rgba(0, 0, 0, 0.075),
|
|
102
|
+
0 0 8px rgba(102, 175, 233, 0.6);
|
|
99
103
|
}
|
|
100
104
|
.select2-selection__rendered {
|
|
101
105
|
color: #555555;
|
|
@@ -192,3 +196,10 @@
|
|
|
192
196
|
}
|
|
193
197
|
}
|
|
194
198
|
}
|
|
199
|
+
|
|
200
|
+
//TODO: Fixing the filter search height by overriding. But this needs to be fixed on auth. The auth .form-control class styles causing this issue
|
|
201
|
+
.filter-search {
|
|
202
|
+
input {
|
|
203
|
+
height: 31px;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
border-bottom: 1px solid var(--bs-border-color);
|
|
78
78
|
&:hover {
|
|
79
79
|
.row-action-tool {
|
|
80
|
-
|
|
80
|
+
display: inline;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
z-index: 3 !important;
|
|
111
111
|
background: transparent;
|
|
112
112
|
.row-action-tool {
|
|
113
|
-
|
|
113
|
+
display: none;
|
|
114
114
|
position: relative;
|
|
115
115
|
.popup-card {
|
|
116
116
|
.popup-option {
|
|
@@ -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 }
|
|
@@ -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,16 +1,16 @@
|
|
|
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.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- sajinmp
|
|
8
8
|
- anbublacky
|
|
9
9
|
- AdityaTiwari2102
|
|
10
|
-
autorequire:
|
|
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
|
|
@@ -168,8 +168,8 @@ files:
|
|
|
168
168
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
|
169
169
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
170
170
|
- ".github/workflows/linters.yml"
|
|
171
|
+
- ".github/workflows/release-gem.yml"
|
|
171
172
|
- ".gitignore"
|
|
172
|
-
- ".reek.yml"
|
|
173
173
|
- ".rspec"
|
|
174
174
|
- ".rubocop-https---raw-githubusercontent-com-commutatus-cm-linters-main-rubocop-yml"
|
|
175
175
|
- ".rubocop.yml"
|
|
@@ -483,7 +483,7 @@ licenses:
|
|
|
483
483
|
metadata:
|
|
484
484
|
homepage_uri: https://github.com/commutatus/cm-admin
|
|
485
485
|
source_code_uri: https://github.com/commutatus/cm-admin
|
|
486
|
-
post_install_message:
|
|
486
|
+
post_install_message:
|
|
487
487
|
rdoc_options: []
|
|
488
488
|
require_paths:
|
|
489
489
|
- lib
|
|
@@ -498,8 +498,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
498
498
|
- !ruby/object:Gem::Version
|
|
499
499
|
version: '0'
|
|
500
500
|
requirements: []
|
|
501
|
-
rubygems_version: 3.
|
|
502
|
-
signing_key:
|
|
501
|
+
rubygems_version: 3.5.11
|
|
502
|
+
signing_key:
|
|
503
503
|
specification_version: 4
|
|
504
504
|
summary: CmAdmin is a robust gem designed to assist in creating admin panels for Rails
|
|
505
505
|
applications
|