cm-admin 0.9.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +82 -0
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- data/Gemfile.lock +95 -8
- data/app/assets/config/cm_admin_manifest.js +1 -0
- data/app/assets/javascripts/cm_admin/application.js +5 -0
- data/app/{javascript/packs → assets/javascripts}/cm_admin/filters.js +20 -31
- data/app/{javascript/packs → assets/javascripts}/cm_admin/quick_search.js +16 -3
- data/app/assets/javascripts/cm_admin/scaffolds.js +44 -0
- data/app/assets/stylesheets/cm_admin/components/_input.scss +12 -0
- data/app/controllers/cm_admin/resource_controller.rb +19 -13
- data/app/helpers/cm_admin/application_helper.rb +0 -3
- data/app/javascript/packs/cm_admin/application.js +4 -4
- data/app/javascript/packs/cm_admin/scaffolds.js +51 -0
- data/app/views/layouts/cm_admin.html.slim +9 -4
- data/app/views/layouts/static.html.slim +3 -2
- data/bin/importmap +15 -0
- data/bin/webpack +8 -8
- data/bin/webpack-dev-server +9 -9
- data/cm_admin.gemspec +3 -0
- data/config/importmap.rb +12 -0
- data/config/webpack/development.js +1 -1
- data/config/webpack/environment.js +1 -1
- data/config/webpack/production.js +1 -1
- data/config/webpacker.yml +2 -2
- data/lib/cm_admin/configuration.rb +2 -0
- data/lib/cm_admin/engine.rb +36 -15
- data/lib/cm_admin/models/dsl_method.rb +0 -8
- data/lib/cm_admin/models/form_field.rb +8 -2
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/version_manager.rb +21 -0
- data/lib/cm_admin/view_helpers/form_field_helper.rb +180 -35
- data/lib/cm_admin.rb +7 -2
- data/lib/generators/cm_admin/templates/actiontext.scss +0 -1
- data/lib/tasks/webpack_install.rake +15 -13
- data/package-lock.json +18 -27
- data/yarn.lock +9 -9
- metadata +43 -6
- /data/app/{javascript/packs → assets/javascripts}/cm_admin/exports.js +0 -0
- /data/app/{javascript/packs → assets/javascripts}/cm_admin/form_validation.js +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fef403882161b778959795eb4ee4b340a471913582710ed998d3d0c3c6d809eb
|
4
|
+
data.tar.gz: 4f083b865564092997f8a959c22b05675c07bd2973f959a357cf0ee132295fcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 444abf2ad421b1db1bdba4b506a7645e1d5e1653b78c6610c434f45999acc0b7b7ae11017df43f82f37058ec1cdff0aeb5b2a0a3ea0dc08e25c22b713d1cf6c0
|
7
|
+
data.tar.gz: b3475419d75358580b07914f988183071b95ad7a2f891811a8dce9a89aa2b1d90237a0b7b8340619142f90ab62de50e3b50f0ffa626a948a09f306c12601acc5
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
name: 🐛 Bug report
|
3
|
+
about: Report a reproducible bug and help us improve.
|
4
|
+
title: '[Bug]: '
|
5
|
+
labels: 'bug'
|
6
|
+
assignees:
|
7
|
+
- anbublacky
|
8
|
+
- AdityaTiwari2102
|
9
|
+
---
|
10
|
+
|
11
|
+
<!-- Before creating a bug report, try disabling browser extensions to see if the bug is still present. -->
|
12
|
+
|
13
|
+
<!-- If you have added and/or updated any DSL related code try restarting the server. -->
|
14
|
+
|
15
|
+
### Describe the bug
|
16
|
+
|
17
|
+
<!-- A clear and concise description of what the bug is. -->
|
18
|
+
|
19
|
+
### Logs
|
20
|
+
<details>
|
21
|
+
<summary>Error logs</summary>
|
22
|
+
|
23
|
+
```
|
24
|
+
Place your error logs here
|
25
|
+
```
|
26
|
+
</details>
|
27
|
+
|
28
|
+
### To Reproduce
|
29
|
+
|
30
|
+
Steps to reproduce the behavior:
|
31
|
+
|
32
|
+
1. Add this configuration '...'
|
33
|
+
2. Go to '...'
|
34
|
+
3. Click on '....'
|
35
|
+
4. Scroll down to '....'
|
36
|
+
5. See error
|
37
|
+
|
38
|
+
### Expected behavior
|
39
|
+
|
40
|
+
<!-- A clear and concise description of what you expected to happen. -->
|
41
|
+
|
42
|
+
### Screenshots & recordings
|
43
|
+
|
44
|
+
<!-- If applicable, add screenshots to help explain your problem. -->
|
45
|
+
|
46
|
+
### System configuration
|
47
|
+
You can help us to understand your problem if you will share some very
|
48
|
+
useful information about your project environment (don't forget to
|
49
|
+
remove any confidential data if it exists).
|
50
|
+
|
51
|
+
**CM Admin version**:
|
52
|
+
|
53
|
+
**Rails version**:
|
54
|
+
<!-- Requirement is v6.0+ -->
|
55
|
+
|
56
|
+
**Ruby version**:
|
57
|
+
<!-- Requirement is v2.7+ -->
|
58
|
+
|
59
|
+
**OS, version**:
|
60
|
+
|
61
|
+
**Browser, version**:
|
62
|
+
|
63
|
+
### Additional context
|
64
|
+
|
65
|
+
<!-- Add any other context about the problem or helpful links here. -->
|
66
|
+
|
67
|
+
#### Impact
|
68
|
+
<!--
|
69
|
+
How much are you impacted by this issue?
|
70
|
+
Please set a level of Impact and Urgency
|
71
|
+
(Mark [x] inside the brackets)
|
72
|
+
-->
|
73
|
+
|
74
|
+
- [ ] High impact
|
75
|
+
- [ ] Medium impact
|
76
|
+
- [ ] Low impact
|
77
|
+
|
78
|
+
#### Urgency
|
79
|
+
|
80
|
+
- [ ] High urgency
|
81
|
+
- [ ] Medium urgency
|
82
|
+
- [ ] low urgency
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
name: 💡 Feature request
|
3
|
+
about: Request a feature that helps you built the platform better.
|
4
|
+
title: ''
|
5
|
+
labels: 'enhancement'
|
6
|
+
assignees:
|
7
|
+
- anbublacky
|
8
|
+
- AdityaTiwari2102
|
9
|
+
---
|
10
|
+
|
11
|
+
### Feature
|
12
|
+
<!-- A clear and concise description of what the feature is. -->
|
13
|
+
|
14
|
+
### Current workarounds
|
15
|
+
<!-- Is there a way to achieve this behavior at the moment through some hack? -->
|
16
|
+
|
17
|
+
### Screenshots or screen recordings
|
18
|
+
<!-- If applicable, add screenshots or recordings to help explain your problem. -->
|
19
|
+
|
20
|
+
### Additional context
|
21
|
+
<!-- Have you seen this behavior somewhere else where we can test it? -->
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,46 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cm-admin (0.
|
4
|
+
cm-admin (1.0.2)
|
5
5
|
caxlsx_rails
|
6
6
|
cocoon (~> 1.2.15)
|
7
7
|
csv-importer (~> 0.8.2)
|
8
|
+
importmap-rails
|
8
9
|
local_time (~> 2.1.0)
|
9
10
|
pagy (~> 4.11.0)
|
10
11
|
pundit (~> 2.2.0)
|
12
|
+
rails (>= 6.0)
|
11
13
|
slim (~> 4.1.0)
|
12
14
|
webpacker (~> 5.4.3)
|
13
15
|
|
14
16
|
GEM
|
15
17
|
remote: https://rubygems.org/
|
16
18
|
specs:
|
19
|
+
actioncable (7.0.3.1)
|
20
|
+
actionpack (= 7.0.3.1)
|
21
|
+
activesupport (= 7.0.3.1)
|
22
|
+
nio4r (~> 2.0)
|
23
|
+
websocket-driver (>= 0.6.1)
|
24
|
+
actionmailbox (7.0.3.1)
|
25
|
+
actionpack (= 7.0.3.1)
|
26
|
+
activejob (= 7.0.3.1)
|
27
|
+
activerecord (= 7.0.3.1)
|
28
|
+
activestorage (= 7.0.3.1)
|
29
|
+
activesupport (= 7.0.3.1)
|
30
|
+
mail (>= 2.7.1)
|
31
|
+
net-imap
|
32
|
+
net-pop
|
33
|
+
net-smtp
|
34
|
+
actionmailer (7.0.3.1)
|
35
|
+
actionpack (= 7.0.3.1)
|
36
|
+
actionview (= 7.0.3.1)
|
37
|
+
activejob (= 7.0.3.1)
|
38
|
+
activesupport (= 7.0.3.1)
|
39
|
+
mail (~> 2.5, >= 2.5.4)
|
40
|
+
net-imap
|
41
|
+
net-pop
|
42
|
+
net-smtp
|
43
|
+
rails-dom-testing (~> 2.0)
|
17
44
|
actionpack (7.0.3.1)
|
18
45
|
actionview (= 7.0.3.1)
|
19
46
|
activesupport (= 7.0.3.1)
|
@@ -21,12 +48,34 @@ GEM
|
|
21
48
|
rack-test (>= 0.6.3)
|
22
49
|
rails-dom-testing (~> 2.0)
|
23
50
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
51
|
+
actiontext (7.0.3.1)
|
52
|
+
actionpack (= 7.0.3.1)
|
53
|
+
activerecord (= 7.0.3.1)
|
54
|
+
activestorage (= 7.0.3.1)
|
55
|
+
activesupport (= 7.0.3.1)
|
56
|
+
globalid (>= 0.6.0)
|
57
|
+
nokogiri (>= 1.8.5)
|
24
58
|
actionview (7.0.3.1)
|
25
59
|
activesupport (= 7.0.3.1)
|
26
60
|
builder (~> 3.1)
|
27
61
|
erubi (~> 1.4)
|
28
62
|
rails-dom-testing (~> 2.0)
|
29
63
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
64
|
+
activejob (7.0.3.1)
|
65
|
+
activesupport (= 7.0.3.1)
|
66
|
+
globalid (>= 0.3.6)
|
67
|
+
activemodel (7.0.3.1)
|
68
|
+
activesupport (= 7.0.3.1)
|
69
|
+
activerecord (7.0.3.1)
|
70
|
+
activemodel (= 7.0.3.1)
|
71
|
+
activesupport (= 7.0.3.1)
|
72
|
+
activestorage (7.0.3.1)
|
73
|
+
actionpack (= 7.0.3.1)
|
74
|
+
activejob (= 7.0.3.1)
|
75
|
+
activerecord (= 7.0.3.1)
|
76
|
+
activesupport (= 7.0.3.1)
|
77
|
+
marcel (~> 1.0)
|
78
|
+
mini_mime (>= 1.1.0)
|
30
79
|
activesupport (7.0.3.1)
|
31
80
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
32
81
|
i18n (>= 1.6, < 2)
|
@@ -53,25 +102,45 @@ GEM
|
|
53
102
|
crass (1.0.6)
|
54
103
|
csv-importer (0.8.2)
|
55
104
|
virtus
|
105
|
+
date (3.3.3)
|
56
106
|
descendants_tracker (0.0.4)
|
57
107
|
thread_safe (~> 0.3, >= 0.3.1)
|
58
108
|
diff-lcs (1.4.4)
|
59
109
|
erubi (1.11.0)
|
110
|
+
globalid (1.0.0)
|
111
|
+
activesupport (>= 5.0)
|
60
112
|
htmlentities (4.3.4)
|
61
113
|
i18n (1.11.0)
|
62
114
|
concurrent-ruby (~> 1.0)
|
63
115
|
ice_nine (0.11.2)
|
116
|
+
importmap-rails (1.1.5)
|
117
|
+
actionpack (>= 6.0.0)
|
118
|
+
railties (>= 6.0.0)
|
64
119
|
json (2.6.2)
|
65
120
|
local_time (2.1.0)
|
66
|
-
loofah (2.19.
|
121
|
+
loofah (2.19.1)
|
67
122
|
crass (~> 1.0.2)
|
68
123
|
nokogiri (>= 1.5.9)
|
124
|
+
mail (2.8.0)
|
125
|
+
mini_mime (>= 0.1.1)
|
126
|
+
net-imap
|
127
|
+
net-pop
|
128
|
+
net-smtp
|
69
129
|
marcel (1.0.2)
|
70
130
|
method_source (1.0.0)
|
71
|
-
|
131
|
+
mini_mime (1.1.2)
|
72
132
|
minitest (5.16.2)
|
73
|
-
|
74
|
-
|
133
|
+
net-imap (0.3.3)
|
134
|
+
date
|
135
|
+
net-protocol
|
136
|
+
net-pop (0.1.2)
|
137
|
+
net-protocol
|
138
|
+
net-protocol (0.2.1)
|
139
|
+
timeout
|
140
|
+
net-smtp (0.3.3)
|
141
|
+
net-protocol
|
142
|
+
nio4r (2.5.8)
|
143
|
+
nokogiri (1.13.10-arm64-darwin)
|
75
144
|
racc (~> 1.4)
|
76
145
|
pagy (4.11.0)
|
77
146
|
parallel (1.22.1)
|
@@ -79,17 +148,31 @@ GEM
|
|
79
148
|
ast (~> 2.4.1)
|
80
149
|
pundit (2.2.0)
|
81
150
|
activesupport (>= 3.0.0)
|
82
|
-
racc (1.6.
|
151
|
+
racc (1.6.1)
|
83
152
|
rack (2.2.4)
|
84
153
|
rack-proxy (0.7.4)
|
85
154
|
rack
|
86
155
|
rack-test (2.0.2)
|
87
156
|
rack (>= 1.3)
|
157
|
+
rails (7.0.3.1)
|
158
|
+
actioncable (= 7.0.3.1)
|
159
|
+
actionmailbox (= 7.0.3.1)
|
160
|
+
actionmailer (= 7.0.3.1)
|
161
|
+
actionpack (= 7.0.3.1)
|
162
|
+
actiontext (= 7.0.3.1)
|
163
|
+
actionview (= 7.0.3.1)
|
164
|
+
activejob (= 7.0.3.1)
|
165
|
+
activemodel (= 7.0.3.1)
|
166
|
+
activerecord (= 7.0.3.1)
|
167
|
+
activestorage (= 7.0.3.1)
|
168
|
+
activesupport (= 7.0.3.1)
|
169
|
+
bundler (>= 1.15.0)
|
170
|
+
railties (= 7.0.3.1)
|
88
171
|
rails-dom-testing (2.0.3)
|
89
172
|
activesupport (>= 4.2.0)
|
90
173
|
nokogiri (>= 1.6)
|
91
|
-
rails-html-sanitizer (1.4.
|
92
|
-
loofah (~> 2.
|
174
|
+
rails-html-sanitizer (1.4.4)
|
175
|
+
loofah (~> 2.19, >= 2.19.1)
|
93
176
|
railties (7.0.3.1)
|
94
177
|
actionpack (= 7.0.3.1)
|
95
178
|
activesupport (= 7.0.3.1)
|
@@ -143,6 +226,7 @@ GEM
|
|
143
226
|
thor (1.2.1)
|
144
227
|
thread_safe (0.3.6)
|
145
228
|
tilt (2.0.10)
|
229
|
+
timeout (0.3.1)
|
146
230
|
tzinfo (2.0.4)
|
147
231
|
concurrent-ruby (~> 1.0)
|
148
232
|
unicode-display_width (2.3.0)
|
@@ -155,6 +239,9 @@ GEM
|
|
155
239
|
rack-proxy (>= 0.6.1)
|
156
240
|
railties (>= 5.2)
|
157
241
|
semantic_range (>= 2.3.0)
|
242
|
+
websocket-driver (0.7.5)
|
243
|
+
websocket-extensions (>= 0.1.0)
|
244
|
+
websocket-extensions (0.1.5)
|
158
245
|
zeitwerk (2.6.6)
|
159
246
|
|
160
247
|
PLATFORMS
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_tree ../javascripts/cm_admin
|
@@ -1,5 +1,21 @@
|
|
1
1
|
var currentRequest = null;
|
2
2
|
|
3
|
+
var CmFilter = {
|
4
|
+
// Generate or remove elements of the dropdown based on the search value.
|
5
|
+
dropdown_search: function(element) {
|
6
|
+
var filter = element.val().toUpperCase();
|
7
|
+
var dropdownElements = element.parents(':nth(1)').find('.list-area').children();
|
8
|
+
for (var i = 0; i < dropdownElements.length; i++) {
|
9
|
+
var txtValue = $(dropdownElements[i]).children().text();
|
10
|
+
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
11
|
+
$(dropdownElements[i]).css('display', 'flex');
|
12
|
+
} else {
|
13
|
+
$(dropdownElements[i]).css('display', 'none');
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
3
19
|
// Main method which will structure the existing filter values with the newly
|
4
20
|
// applied filter. Send and receive the value from the backend.
|
5
21
|
var getFilteredData = function(filterType, filterValue, filterColumn=null) {
|
@@ -40,7 +56,7 @@ var getFilteredData = function(filterType, filterValue, filterColumn=null) {
|
|
40
56
|
}
|
41
57
|
filterParams = jQuery.param(queryString)
|
42
58
|
var availableParams = searchParams + '&' + filterParams
|
43
|
-
queryString = getParamsAsObject(availableParams)
|
59
|
+
var queryString = getParamsAsObject(availableParams)
|
44
60
|
}
|
45
61
|
|
46
62
|
return currentRequest = $.ajax(url, {
|
@@ -259,7 +275,7 @@ $(document).on('click', '.apply-area', function(e) {
|
|
259
275
|
filterValueText.push($(checkedElements[i]).parent().text())
|
260
276
|
}
|
261
277
|
|
262
|
-
truncatedFilterValue = filterValueText[0]
|
278
|
+
var truncatedFilterValue = filterValueText[0]
|
263
279
|
if (filterValue.length > 1) {
|
264
280
|
truncatedFilterValue += ' + ' + (filterValue.length - 1) + ' more'
|
265
281
|
}
|
@@ -286,7 +302,7 @@ $(document).on('click', '.filter-chip-remove', function(e) {
|
|
286
302
|
|
287
303
|
var searchParams = window.location.search
|
288
304
|
if (searchParams.length > 0) {
|
289
|
-
queryString = getParamsAsObject(searchParams)
|
305
|
+
var queryString = getParamsAsObject(searchParams)
|
290
306
|
if (queryString['filters'][filterType] != undefined) {
|
291
307
|
delete(queryString['filters'][filterType][filterColumn])
|
292
308
|
var queryParam = jQuery.param(queryString)
|
@@ -317,31 +333,4 @@ $(document).on('click', '[data-behaviour="selected-chip"]', function(e) {
|
|
317
333
|
$(selectElement).parent().siblings(':first').addClass('search-area').removeClass('search-with-chips')
|
318
334
|
$(selectElement).parent().siblings(':last').removeClass('active')
|
319
335
|
}
|
320
|
-
})
|
321
|
-
|
322
|
-
CmFilter = {
|
323
|
-
// Generate or remove elements of the dropdown based on the search value.
|
324
|
-
dropdown_search: function(element) {
|
325
|
-
var filter = element.val().toUpperCase();
|
326
|
-
var dropdownElements = element.parents(':nth(1)').find('.list-area').children();
|
327
|
-
for (var i = 0; i < dropdownElements.length; i++) {
|
328
|
-
txtValue = $(dropdownElements[i]).children().text();
|
329
|
-
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
330
|
-
$(dropdownElements[i]).css('display', 'flex');
|
331
|
-
} else {
|
332
|
-
$(dropdownElements[i]).css('display', 'none');
|
333
|
-
}
|
334
|
-
}
|
335
|
-
},
|
336
|
-
quick_input_search: function(element) {
|
337
|
-
var filter = element.val().toUpperCase();
|
338
|
-
var searchElements = element.parents(':nth(3)').find('.list-area').children();
|
339
|
-
searchElements.removeClass('visible').addClass('hidden')
|
340
|
-
for (var i = 0; i < searchElements.length; i++) {
|
341
|
-
txtValue = $(searchElements[i]).children().text();
|
342
|
-
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
343
|
-
$(searchElements[i]).removeClass('hidden').addClass('visible');
|
344
|
-
}
|
345
|
-
}
|
346
|
-
}
|
347
|
-
}
|
336
|
+
})
|
@@ -1,3 +1,17 @@
|
|
1
|
+
var CmFilter = {
|
2
|
+
quick_input_search: function(element) {
|
3
|
+
var filter = element.val().toUpperCase();
|
4
|
+
var searchElements = element.parents(':nth(3)').find('.list-area').children();
|
5
|
+
searchElements.removeClass('visible').addClass('hidden')
|
6
|
+
for (var i = 0; i < searchElements.length; i++) {
|
7
|
+
var txtValue = $(searchElements[i]).children().text();
|
8
|
+
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
9
|
+
$(searchElements[i]).removeClass('hidden').addClass('visible');
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
1
15
|
$(document).on("keydown", function(e) {
|
2
16
|
if (e.keyCode == 75 && e.metaKey) {
|
3
17
|
$('#quickSearchModal').modal('show')
|
@@ -12,7 +26,7 @@ $(document).on('keydown', function(e){
|
|
12
26
|
if(e.which === 40){
|
13
27
|
if(liSelected){
|
14
28
|
liSelected.removeClass('active-item');
|
15
|
-
next = liSelected.next();
|
29
|
+
var next = liSelected.next();
|
16
30
|
if(next.length > 0){
|
17
31
|
liSelected = next.addClass('active-item');
|
18
32
|
selected = next.text();
|
@@ -44,8 +58,7 @@ $(document).on('keydown', function(e){
|
|
44
58
|
}
|
45
59
|
}
|
46
60
|
if(liSelected && e.which === 13) {
|
47
|
-
|
48
|
-
href = liSelected.attr('href')
|
61
|
+
var href = liSelected.attr('href')
|
49
62
|
window.location = href
|
50
63
|
}
|
51
64
|
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import jQuery from 'jquery';
|
2
|
+
window.jQuery = jQuery // <- "select2" will check this
|
3
|
+
window.$ = jQuery
|
4
|
+
|
5
|
+
// This is a hack to fix 'process is not defined'
|
6
|
+
// Ref article: https://adambien.blog/roller/abien/entry/uncaught_referenceerror_process_is_not
|
7
|
+
// Based on this filter dropdown works.
|
8
|
+
window.process = {
|
9
|
+
env: {
|
10
|
+
NODE_ENV: 'development'
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
import 'moment'
|
15
|
+
import 'bootstrap'
|
16
|
+
import '@popperjs/core'
|
17
|
+
import 'flatpickr'
|
18
|
+
import 'jgrowl'
|
19
|
+
jqueryJgrowl()
|
20
|
+
import Select2 from "select2"
|
21
|
+
Select2()
|
22
|
+
|
23
|
+
// import '@nathanvda/cocoon'
|
24
|
+
import 'daterangepicker'
|
25
|
+
import '@fortawesome/fontawesome-free'
|
26
|
+
import jqueryJgrowl from 'jgrowl';
|
27
|
+
|
28
|
+
|
29
|
+
flatpickr("[data-behaviour='date-only']", {
|
30
|
+
dateFormat: "d-m-Y"
|
31
|
+
})
|
32
|
+
flatpickr("[data-behaviour='date-time']", {
|
33
|
+
enableTime: true
|
34
|
+
})
|
35
|
+
flatpickr("[data-behaviour='filter'][data-filter-type='date']", {
|
36
|
+
mode: 'range'
|
37
|
+
})
|
38
|
+
$('.select-2').select2();
|
39
|
+
$(document).on('turbolinks:load', function () {
|
40
|
+
$('.select-2').select2();
|
41
|
+
flatpickr("[data-behaviour='date-only']", {
|
42
|
+
dateFormat: "d-m-Y"
|
43
|
+
})
|
44
|
+
})
|
@@ -182,6 +182,18 @@ input.cm-checkbox[type="checkbox"] {
|
|
182
182
|
}
|
183
183
|
|
184
184
|
//Radio button styles
|
185
|
+
.cm-radio-section {
|
186
|
+
width: 100%;
|
187
|
+
float: left;
|
188
|
+
.cm-radio-label {
|
189
|
+
float: left;
|
190
|
+
padding-left: 10px;
|
191
|
+
}
|
192
|
+
.cm-radio-tag {
|
193
|
+
float: left;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
185
197
|
input.cm-radio[type="radio"] {
|
186
198
|
position: relative;
|
187
199
|
display: inline-block;
|
@@ -106,12 +106,14 @@ module CmAdmin
|
|
106
106
|
data = @action.parent == "index" ? @ar_object.data : @ar_object
|
107
107
|
format.html { render @action.partial }
|
108
108
|
else
|
109
|
-
|
110
|
-
if
|
111
|
-
|
109
|
+
response_object = @action.code_block.call(@response_object)
|
110
|
+
if response_object.class == Hash
|
111
|
+
format.json { render json: response_object }
|
112
|
+
elsif response_object.errors.empty?
|
113
|
+
redirect_url = @model.current_action.redirection_url || @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@response_object.id}"
|
112
114
|
format.html { redirect_to redirect_url, notice: "#{@action.name.titleize} is successful" }
|
113
115
|
else
|
114
|
-
error_messages =
|
116
|
+
error_messages = response_object.errors.full_messages.map{|error_message| "<li>#{error_message}</li>"}.join
|
115
117
|
format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><ul>#{error_messages}</ul>" }
|
116
118
|
end
|
117
119
|
end
|
@@ -176,13 +178,16 @@ module CmAdmin
|
|
176
178
|
|
177
179
|
def filter_by(params, records, filter_params={}, sort_params={})
|
178
180
|
filtered_result = OpenStruct.new
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
181
|
+
cm_model = @associated_model || @model
|
182
|
+
db_columns = cm_model.ar_model&.columns&.map{|x| x.name.to_sym}
|
183
|
+
if db_columns.include?(@current_action.sort_column)
|
184
|
+
sort_column = @current_action.sort_column
|
185
|
+
else
|
186
|
+
sort_column = 'created_at'
|
187
|
+
end
|
183
188
|
records = "CmAdmin::#{@model.name}Policy::Scope".constantize.new(Current.user, @model.name.constantize).resolve if records.nil?
|
184
|
-
records = records.order("#{
|
185
|
-
final_data = CmAdmin::Models::Filter.filtered_data(filter_params, records,
|
189
|
+
records = records.order("#{sort_column} #{@current_action.sort_direction}")
|
190
|
+
final_data = CmAdmin::Models::Filter.filtered_data(filter_params, records, cm_model.filters)
|
186
191
|
pagy, records = pagy(final_data)
|
187
192
|
filtered_result.data = records
|
188
193
|
filtered_result.pagy = pagy
|
@@ -193,9 +198,11 @@ module CmAdmin
|
|
193
198
|
end
|
194
199
|
|
195
200
|
def resource_params(params)
|
196
|
-
columns = @model.ar_model.
|
201
|
+
columns = @model.ar_model.columns_hash.map {|key, ar_adapter|
|
202
|
+
ar_adapter.sql_type_metadata.sql_type.ends_with?('[]') ? Hash[ar_adapter.name, []] : ar_adapter.name.to_sym
|
203
|
+
}
|
197
204
|
columns += @model.ar_model.stored_attributes.values.flatten
|
198
|
-
permittable_fields = @model.additional_permitted_fields + columns.reject { |i| CmAdmin::REJECTABLE_FIELDS.include?(i) }
|
205
|
+
permittable_fields = @model.additional_permitted_fields + columns.reject { |i| CmAdmin::REJECTABLE_FIELDS.include?(i) }
|
199
206
|
permittable_fields += @model.ar_model.name.constantize.reflect_on_all_associations.map {|x|
|
200
207
|
next if x.options[:polymorphic]
|
201
208
|
if x.class.name.include?('HasOne')
|
@@ -214,7 +221,6 @@ module CmAdmin
|
|
214
221
|
}
|
215
222
|
permittable_fields += nested_fields
|
216
223
|
@model.ar_model.columns.map { |col| permittable_fields << col.name.split('_cents') if col.name.include?('_cents') }
|
217
|
-
|
218
224
|
params.require(@model.name.underscore.to_sym).permit(*permittable_fields)
|
219
225
|
end
|
220
226
|
|
@@ -9,10 +9,10 @@ require('flatpickr')
|
|
9
9
|
require("jgrowl")
|
10
10
|
require("trix")
|
11
11
|
require('./scaffolds.js')
|
12
|
-
require('
|
13
|
-
require('
|
14
|
-
require('
|
15
|
-
require('
|
12
|
+
require('/app/assets/javascripts/cm_admin/form_validation.js')
|
13
|
+
require('/app/assets/javascripts/cm_admin/quick_search.js')
|
14
|
+
require('/app/assets/javascripts/cm_admin/filters.js')
|
15
|
+
require('/app/assets/javascripts/cm_admin/exports.js')
|
16
16
|
|
17
17
|
import jQuery from 'jquery'
|
18
18
|
import LocalTime from "local-time"
|
@@ -75,6 +75,57 @@ $(document).on('click', '.drawer-close', function(e) {
|
|
75
75
|
}, 300);
|
76
76
|
});
|
77
77
|
|
78
|
+
$(document).on('change', '[data-field-type="linked-field"]', function(e) {
|
79
|
+
e.stopPropagation();
|
80
|
+
params = {}
|
81
|
+
params[$(this).data('field-name')] = $(this).val()
|
82
|
+
request_url = $(this).data('target-url') + '?' + $.param(params);
|
83
|
+
console.log(request_url)
|
84
|
+
$.ajax(request_url, {
|
85
|
+
type: 'GET',
|
86
|
+
success: function(data) {
|
87
|
+
apply_response_to_field(data)
|
88
|
+
},
|
89
|
+
error: function(jqxhr, textStatus, errorThrown) {
|
90
|
+
alert('Something went wrong. Please try again later.\n' + errorThrown);
|
91
|
+
}
|
92
|
+
});
|
93
|
+
});
|
94
|
+
|
95
|
+
function apply_response_to_field(response) {
|
96
|
+
$.each(response['fields'], function(key, value) {
|
97
|
+
switch(value['target_type']) {
|
98
|
+
case 'select':
|
99
|
+
update_options_in_select(value['target_value'])
|
100
|
+
break;
|
101
|
+
case 'input':
|
102
|
+
update_options_input_value(value['target_value'])
|
103
|
+
break;
|
104
|
+
case 'toggle_visibility':
|
105
|
+
toggle_field_visibility(value['target_value'])
|
106
|
+
}
|
107
|
+
})
|
108
|
+
}
|
109
|
+
|
110
|
+
function update_options_input_value(field_obj) {
|
111
|
+
input_tag = $('#' + field_obj['table'] + '_' + field_obj['field_name'])
|
112
|
+
input_tag.val(field_obj['field_value'])
|
113
|
+
}
|
114
|
+
|
115
|
+
function update_options_in_select(field_obj) {
|
116
|
+
select_tag = $('#' + field_obj['table'] + '_' + field_obj['field_name'])
|
117
|
+
select_tag.empty();
|
118
|
+
$.each(field_obj['field_value'], function(key, value) {
|
119
|
+
select_tag.append($("<option></option>")
|
120
|
+
.attr("value", value[1]).text(value[0]));
|
121
|
+
});
|
122
|
+
}
|
123
|
+
|
124
|
+
function toggle_field_visibility(field_obj) {
|
125
|
+
element = $('#' + field_obj['table'] + '_' + field_obj['field_name'])
|
126
|
+
element.closest('.input-wrapper').toggleClass('hidden')
|
127
|
+
}
|
128
|
+
|
78
129
|
$(document).on('cocoon:after-insert', '.nested-field-wrapper', function(e) {
|
79
130
|
e.stopPropagation();
|
80
131
|
replaceAccordionTitle($(this))
|
@@ -7,12 +7,17 @@ html
|
|
7
7
|
= csrf_meta_tags
|
8
8
|
= csp_meta_tag
|
9
9
|
= stylesheet_link_tag 'cm_admin/cm_admin', media: 'all', 'data-turbolinks-track': 'reload'
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
- if CmAdmin::VersionManager.use_webpacker?
|
11
|
+
= stylesheet_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
|
12
|
+
= javascript_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
|
13
|
+
script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"
|
14
|
+
- elsif CmAdmin::VersionManager.use_importmap?
|
15
|
+
= javascript_importmap_tags
|
16
|
+
= javascript_import_module_tag "cm_admin/application"
|
13
17
|
= javascript_include_tag 'cm_admin/custom', 'data-turbolinks-track': 'reload'
|
14
18
|
= stylesheet_link_tag 'cm_admin/custom', media: 'all', 'data-turbolinks-track': 'reload'
|
15
|
-
|
19
|
+
link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" /
|
20
|
+
|
16
21
|
script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"
|
17
22
|
body
|
18
23
|
.cm-admin
|