cm-admin 1.1.6 → 1.1.8

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop-https---raw-githubusercontent-com-commutatus-cm-linters-main-rubocop-yml +20 -0
  3. data/Gemfile.lock +60 -60
  4. data/app/assets/javascripts/cm_admin/application.js +8 -3
  5. data/app/assets/javascripts/cm_admin/bulk_actions.js +36 -0
  6. data/app/assets/javascripts/cm_admin/custom.js +0 -0
  7. data/app/assets/javascripts/cm_admin/scaffolds.js +1 -1
  8. data/app/assets/stylesheets/cm_admin/base/navbar.scss +3 -2
  9. data/app/assets/stylesheets/cm_admin/cm_admin.css.scss +1 -0
  10. data/app/assets/stylesheets/cm_admin/components/_buttons.scss +17 -11
  11. data/app/assets/stylesheets/cm_admin/dependency/jquery-jgrowl.min.css +1 -0
  12. data/app/assets/stylesheets/cm_admin/helpers/_variable.scss +31 -30
  13. data/app/controllers/cm_admin/resource_controller.rb +29 -10
  14. data/app/helpers/cm_admin/application_helper.rb +4 -0
  15. data/app/javascript/packs/cm_admin/application.js +1 -0
  16. data/app/models/concerns/cm_admin/bulk_action_processor.rb +29 -0
  17. data/app/views/cm_admin/main/_associated_table.html.slim +19 -9
  18. data/app/views/cm_admin/main/_table.html.slim +27 -14
  19. data/app/views/cm_admin/main/index.html.slim +1 -1
  20. data/app/views/layouts/_cm_flash_message.html.slim +3 -3
  21. data/app/views/layouts/_custom_action_modals.html.slim +4 -1
  22. data/lib/cm_admin/model.rb +3 -1
  23. data/lib/cm_admin/models/action.rb +10 -4
  24. data/lib/cm_admin/models/bulk_action.rb +18 -0
  25. data/lib/cm_admin/models/dsl_method.rb +9 -0
  26. data/lib/cm_admin/models/filter.rb +55 -29
  27. data/lib/cm_admin/models/form_field.rb +18 -3
  28. data/lib/cm_admin/models/utils/helpers.rb +14 -0
  29. data/lib/cm_admin/version.rb +1 -1
  30. data/lib/cm_admin/view_helpers/filter_helper.rb +1 -1
  31. data/lib/cm_admin/view_helpers/form_field_helper.rb +16 -17
  32. data/lib/cm_admin/view_helpers/page_info_helper.rb +10 -0
  33. metadata +9 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01cfdef16d888507aaaa1969921502f28a3f5f7af5c80f29ef4cde88975805f9
4
- data.tar.gz: 6d257af43f68b2d5ab7b57162724a91b1494946d02e2fe1536531d5d0363bb6b
3
+ metadata.gz: ba81abd1bda39ffb9374cd1c93320c6459ffb106ac105fc9b6dabca27c941b2b
4
+ data.tar.gz: c43d2423a3aed2e123eb058874d0bcf1b8df3c8b09597715a25720514177a93d
5
5
  SHA512:
6
- metadata.gz: 3cb0fb31de297ecf1bb914e891188a72f6c2fd95d4b0ef05adaa99c36a9c15d3b8f2ad167e35c6ba65e5bd515951ee0474f2027df64aa95a31a4d7dd03fd29d9
7
- data.tar.gz: 97119da3716c2be594af5cf3207eb830e13b32d79c15e3286a3abda3616c863a1a5439b94553ac9bfe1c56452d76cd9c9993893d6d1359541c9f366cf02ca8b2
6
+ metadata.gz: 3b24b0d099f5557d2f6c0cf08ece3efc79129d0bbbcff25b115244cd04eb2ad8e4059bb563e1e63af201c46529a2e15902f8331a8988bec0d62bd3db84655852
7
+ data.tar.gz: 91b506a984661154df8536ace4bbea58cf67eb22fe13c99f02be6e5e3cd99e1f5565a3f363de974d3c9adf8e7a616912519cdd6155e9a861df42d490e56e9a11
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ DisabledByDefault: false
3
+
4
+ Style/FrozenStringLiteralComment:
5
+ Enabled: false
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Layout/IndentationStyle:
11
+ Enabled: false
12
+
13
+ Layout/LineLength:
14
+ Enabled: false
15
+
16
+ Metrics/MethodLength:
17
+ Enabled: false
18
+
19
+ Metrics/AbcSize:
20
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (1.1.6)
4
+ cm-admin (1.1.8)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -16,67 +16,67 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- actioncable (7.0.3.1)
20
- actionpack (= 7.0.3.1)
21
- activesupport (= 7.0.3.1)
19
+ actioncable (7.0.5.1)
20
+ actionpack (= 7.0.5.1)
21
+ activesupport (= 7.0.5.1)
22
22
  nio4r (~> 2.0)
23
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)
24
+ actionmailbox (7.0.5.1)
25
+ actionpack (= 7.0.5.1)
26
+ activejob (= 7.0.5.1)
27
+ activerecord (= 7.0.5.1)
28
+ activestorage (= 7.0.5.1)
29
+ activesupport (= 7.0.5.1)
30
30
  mail (>= 2.7.1)
31
31
  net-imap
32
32
  net-pop
33
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)
34
+ actionmailer (7.0.5.1)
35
+ actionpack (= 7.0.5.1)
36
+ actionview (= 7.0.5.1)
37
+ activejob (= 7.0.5.1)
38
+ activesupport (= 7.0.5.1)
39
39
  mail (~> 2.5, >= 2.5.4)
40
40
  net-imap
41
41
  net-pop
42
42
  net-smtp
43
43
  rails-dom-testing (~> 2.0)
44
- actionpack (7.0.3.1)
45
- actionview (= 7.0.3.1)
46
- activesupport (= 7.0.3.1)
47
- rack (~> 2.0, >= 2.2.0)
44
+ actionpack (7.0.5.1)
45
+ actionview (= 7.0.5.1)
46
+ activesupport (= 7.0.5.1)
47
+ rack (~> 2.0, >= 2.2.4)
48
48
  rack-test (>= 0.6.3)
49
49
  rails-dom-testing (~> 2.0)
50
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)
51
+ actiontext (7.0.5.1)
52
+ actionpack (= 7.0.5.1)
53
+ activerecord (= 7.0.5.1)
54
+ activestorage (= 7.0.5.1)
55
+ activesupport (= 7.0.5.1)
56
56
  globalid (>= 0.6.0)
57
57
  nokogiri (>= 1.8.5)
58
- actionview (7.0.3.1)
59
- activesupport (= 7.0.3.1)
58
+ actionview (7.0.5.1)
59
+ activesupport (= 7.0.5.1)
60
60
  builder (~> 3.1)
61
61
  erubi (~> 1.4)
62
62
  rails-dom-testing (~> 2.0)
63
63
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
64
- activejob (7.0.3.1)
65
- activesupport (= 7.0.3.1)
64
+ activejob (7.0.5.1)
65
+ activesupport (= 7.0.5.1)
66
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)
67
+ activemodel (7.0.5.1)
68
+ activesupport (= 7.0.5.1)
69
+ activerecord (7.0.5.1)
70
+ activemodel (= 7.0.5.1)
71
+ activesupport (= 7.0.5.1)
72
+ activestorage (7.0.5.1)
73
+ actionpack (= 7.0.5.1)
74
+ activejob (= 7.0.5.1)
75
+ activerecord (= 7.0.5.1)
76
+ activesupport (= 7.0.5.1)
77
77
  marcel (~> 1.0)
78
78
  mini_mime (>= 1.1.0)
79
- activesupport (7.0.3.1)
79
+ activesupport (7.0.5.1)
80
80
  concurrent-ruby (~> 1.0, >= 1.0.2)
81
81
  i18n (>= 1.6, < 2)
82
82
  minitest (>= 5.1)
@@ -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.1.10)
101
+ concurrent-ruby (1.2.2)
102
102
  crass (1.0.6)
103
103
  csv-importer (0.8.2)
104
104
  virtus
@@ -110,7 +110,7 @@ GEM
110
110
  globalid (1.1.0)
111
111
  activesupport (>= 5.0)
112
112
  htmlentities (4.3.4)
113
- i18n (1.11.0)
113
+ i18n (1.14.1)
114
114
  concurrent-ruby (~> 1.0)
115
115
  ice_nine (0.11.2)
116
116
  importmap-rails (1.2.1)
@@ -129,7 +129,7 @@ GEM
129
129
  marcel (1.0.2)
130
130
  method_source (1.0.0)
131
131
  mini_mime (1.1.2)
132
- minitest (5.16.2)
132
+ minitest (5.18.1)
133
133
  net-imap (0.3.6)
134
134
  date
135
135
  net-protocol
@@ -149,25 +149,25 @@ GEM
149
149
  pundit (2.2.0)
150
150
  activesupport (>= 3.0.0)
151
151
  racc (1.7.1)
152
- rack (2.2.6.4)
152
+ rack (2.2.7)
153
153
  rack-proxy (0.7.6)
154
154
  rack
155
155
  rack-test (2.1.0)
156
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)
157
+ rails (7.0.5.1)
158
+ actioncable (= 7.0.5.1)
159
+ actionmailbox (= 7.0.5.1)
160
+ actionmailer (= 7.0.5.1)
161
+ actionpack (= 7.0.5.1)
162
+ actiontext (= 7.0.5.1)
163
+ actionview (= 7.0.5.1)
164
+ activejob (= 7.0.5.1)
165
+ activemodel (= 7.0.5.1)
166
+ activerecord (= 7.0.5.1)
167
+ activestorage (= 7.0.5.1)
168
+ activesupport (= 7.0.5.1)
169
169
  bundler (>= 1.15.0)
170
- railties (= 7.0.3.1)
170
+ railties (= 7.0.5.1)
171
171
  rails-dom-testing (2.1.1)
172
172
  activesupport (>= 5.0.0)
173
173
  minitest
@@ -175,9 +175,9 @@ GEM
175
175
  rails-html-sanitizer (1.6.0)
176
176
  loofah (~> 2.21)
177
177
  nokogiri (~> 1.14)
178
- railties (7.0.3.1)
179
- actionpack (= 7.0.3.1)
180
- activesupport (= 7.0.3.1)
178
+ railties (7.0.5.1)
179
+ actionpack (= 7.0.5.1)
180
+ activesupport (= 7.0.5.1)
181
181
  method_source
182
182
  rake (>= 12.2)
183
183
  thor (~> 1.0)
@@ -229,7 +229,7 @@ GEM
229
229
  thread_safe (0.3.6)
230
230
  tilt (2.0.10)
231
231
  timeout (0.4.0)
232
- tzinfo (2.0.4)
232
+ tzinfo (2.0.6)
233
233
  concurrent-ruby (~> 1.0)
234
234
  unicode-display_width (2.3.0)
235
235
  virtus (2.0.0)
@@ -1,7 +1,12 @@
1
1
  import './scaffolds.js';
2
- import './cocoon.js'
3
2
  import './shared_scaffolds.js';
3
+
4
+ import './bulk_actions.js'
5
+ import './cocoon.js'
6
+ import './exports.js'
7
+ import './filters.js'
4
8
  import './form_validation.js'
5
9
  import './quick_search.js'
6
- import './filters.js'
7
- import './exports.js'
10
+ import './custom.js'
11
+
12
+
@@ -0,0 +1,36 @@
1
+ $(document).on('click', '[data-behaviour="bulk-action-checkbox"]', function(e) {
2
+ if ($('[data-behaviour="bulk-action-checkbox"]').is(':checked')) {
3
+ $('[data-section="bulk-action"]').removeClass('hidden')
4
+ setBulkActionParams()
5
+ } else {
6
+ $('[data-section="bulk-action"]').addClass('hidden')
7
+ }
8
+ });
9
+
10
+ $(document).on('click', '[data-behaviour="bulk-action-select-all"]', function(e) {
11
+ if ($(this).is(':checked')) {
12
+ $('[data-behaviour="bulk-action-checkbox"]').prop('checked', true)
13
+ $('[data-section="bulk-action"]').removeClass('hidden')
14
+ setBulkActionParams()
15
+ } else {
16
+ $('[data-behaviour="bulk-action-checkbox"]').prop('checked', false)
17
+ $('[data-section="bulk-action"]').addClass('hidden')
18
+ }
19
+ });
20
+
21
+ function setBulkActionParams() {
22
+ var selected_ids = []
23
+ $('[data-behaviour="bulk-action-checkbox"]:checked').each(function(){ selected_ids.push($(this).data('ar-object-id')) })
24
+ var bulk_action_form = '[data-section="bulk-action"] form'
25
+ if ($(bulk_action_form)) {
26
+ if ($(bulk_action_form + ' [name="selected_ids"]').length == 0) {
27
+ $('<input>').attr({
28
+ type: 'hidden',
29
+ name: 'selected_ids'
30
+ }).appendTo(bulk_action_form);
31
+ }
32
+ }
33
+ $('[data-section="bulk-action"] [name="selected_ids"]').each(function( i ) {
34
+ $(this).val(selected_ids)
35
+ })
36
+ }
File without changes
@@ -16,7 +16,6 @@ import 'bootstrap'
16
16
  import '@popperjs/core'
17
17
  import 'flatpickr'
18
18
  import 'jgrowl'
19
- jqueryJgrowl()
20
19
  import Select2 from "select2"
21
20
  Select2()
22
21
 
@@ -37,6 +36,7 @@ document.addEventListener("turbo:load", function () {
37
36
  mode: 'range'
38
37
  })
39
38
  $('.select-2').select2();
39
+ jqueryJgrowl()
40
40
  });
41
41
 
42
42
  $(document).on('click', '.menu-item', function(e) {
@@ -11,6 +11,7 @@
11
11
  padding: 24px;
12
12
  background-color: $white;
13
13
  z-index: 2;
14
+ gap: 16px;
14
15
  &__lhs {
15
16
  .bread-crumb-area {
16
17
  .breadcrumb-text {
@@ -46,12 +47,12 @@
46
47
  top: 45px;
47
48
  width: 156px;
48
49
  padding: 8px 0;
49
- animation: fadeIn .2s ease-in-out;
50
+ animation: fadeIn 0.2s ease-in-out;
50
51
  .popup-option {
51
52
  padding: 8px 16px;
52
53
  @include font($size: $t4-text, $color: $primary-text-clr);
53
54
  line-height: 22px;
54
- transition: all .2s linear;
55
+ transition: all 0.2s linear;
55
56
  cursor: pointer;
56
57
  &:hover {
57
58
  background-color: $grey-lighter-clr;
@@ -26,6 +26,7 @@
26
26
  *= require 'cm_admin/dependency/bootstrap.min'
27
27
  *= require 'cm_admin/dependency/flatpickr.min'
28
28
  *= require 'cm_admin/dependency/fontawesome.all'
29
+ *= require 'cm_admin/dependency/jquery-jgrowl.min'
29
30
  *= require 'cm_admin/scaffold'
30
31
  *= require_self
31
32
  */
@@ -1,4 +1,4 @@
1
- @import '../helpers/index.scss';
1
+ @import "../helpers/index.scss";
2
2
 
3
3
  .cta-btn {
4
4
  padding: 5px 10px;
@@ -6,7 +6,8 @@
6
6
  background-color: $brand-color;
7
7
  border: none;
8
8
  border-radius: $radius-4;
9
- transition: all .2s linear;
9
+ transition: all 0.2s linear;
10
+ white-space: nowrap;
10
11
  &:hover {
11
12
  color: $white;
12
13
  background: $cta-hover-gradient;
@@ -32,10 +33,11 @@
32
33
  background-color: $white;
33
34
  border: 1px solid $brand-color;
34
35
  border-radius: $radius-4;
35
- transition: all .2s linear;
36
+ transition: all 0.2s linear;
37
+ white-space: nowrap;
36
38
  &:hover {
37
39
  color: $brand-color;
38
- background-color: #E6E4FA;
40
+ background-color: $brand-hover-color;
39
41
  transform: scale(1.05);
40
42
  }
41
43
  &:focus {
@@ -55,11 +57,12 @@
55
57
 
56
58
  .secondary-btn {
57
59
  padding: 5px 10px;
58
- @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
60
+ @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
59
61
  background-color: $white;
60
62
  border: 1px solid $ink-regular-clr;
61
63
  border-radius: $radius-4;
62
- transition: all .2s linear;
64
+ transition: all 0.2s linear;
65
+ white-space: nowrap;
63
66
  &:hover {
64
67
  color: $primary-text-clr;
65
68
  background-color: $grey-light-clr;
@@ -82,17 +85,18 @@
82
85
  margin: 0 4px 0 8px;
83
86
  }
84
87
  span:nth-child(3) {
85
- @include font($size: 10px, $color: $ink-lighter-clr, $weight: bold);
88
+ @include font($size: 10px, $color: $ink-lighter-clr, $weight: bold);
86
89
  }
87
90
  }
88
91
 
89
92
  .gray-border-btn {
90
93
  padding: 5px 10px;
91
- @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
94
+ @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
92
95
  background-color: $white;
93
96
  border: 1px solid $ink-regular-clr;
94
97
  border-radius: $radius-4;
95
- transition: all .2s linear;
98
+ transition: all 0.2s linear;
99
+ white-space: nowrap;
96
100
  &:hover {
97
101
  color: $primary-text-clr;
98
102
  background-color: $grey-light-clr;
@@ -115,11 +119,12 @@
115
119
 
116
120
  .ghost-btn {
117
121
  padding: 5px 10px;
118
- @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
122
+ @include font($size: $t4-text, $color: $primary-text-clr, $weight: bold);
119
123
  background-color: transparent;
120
124
  border: none;
121
125
  border-radius: $radius-4;
122
- transition: all .2s linear;
126
+ transition: all 0.2s linear;
127
+ white-space: nowrap;
123
128
  &:hover {
124
129
  color: $primary-text-clr;
125
130
  background: $grey-light-clr;
@@ -142,6 +147,7 @@
142
147
  .text-btn {
143
148
  border: none;
144
149
  background-color: transparent;
150
+ white-space: nowrap;
145
151
  &:focus {
146
152
  outline: none;
147
153
  }
@@ -0,0 +1 @@
1
+ .jGrowl{z-index:9999;color:#fff;font-size:12px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;position:fixed}.jGrowl.top-left{left:0;top:0}.jGrowl.top-right{right:0;top:0}.jGrowl.bottom-left{left:0;bottom:0}.jGrowl.bottom-right{right:0;bottom:0}.jGrowl.center{top:0;width:50%;left:25%}.jGrowl.center .jGrowl-closer,.jGrowl.center .jGrowl-notification{margin-left:auto;margin-right:auto}.jGrowl-notification{background-color:#000;opacity:.9;zoom:1;width:250px;padding:10px;margin:10px;text-align:left;display:none;border-radius:5px;min-height:40px}.jGrowl-notification .ui-state-highlight,.jGrowl-notification .ui-widget-content .ui-state-highlight,.jGrowl-notification .ui-widget-header .ui-state-highlight{border:1px solid #000;background:#000;color:#fff}.jGrowl-notification .jGrowl-header{font-weight:700;font-size:.85em}.jGrowl-notification .jGrowl-close{background-color:transparent;color:inherit;border:none;z-index:99;float:right;font-weight:700;font-size:1em;cursor:pointer}.jGrowl-closer{background-color:#000;opacity:.9;zoom:1;width:250px;padding:10px;margin:10px;text-align:left;display:none;border-radius:5px;padding-top:4px;padding-bottom:4px;cursor:pointer;font-size:.9em;font-weight:700;text-align:center}.jGrowl-closer .ui-state-highlight,.jGrowl-closer .ui-widget-content .ui-state-highlight,.jGrowl-closer .ui-widget-header .ui-state-highlight{border:1px solid #000;background:#000;color:#fff}@media print{.jGrowl{display:none}}
@@ -1,54 +1,55 @@
1
1
  /* ==== Color Variables ==== */
2
2
 
3
3
  /* Brand Color */
4
- $brand-color: #6554E0;
4
+ $brand-color: #6554e0;
5
+ $brand-hover-color: #e6e4fa;
5
6
 
6
7
  /* Semantic Color */
7
- $informative-clr: #2F80ED;
8
- $error-clr: #F83636;
9
- $warning-clr: #FFC845;
10
- $positive-clr: #30C39E;
11
- $disabled-clr: #9CA7AE;
8
+ $informative-clr: #2f80ed;
9
+ $error-clr: #f83636;
10
+ $warning-clr: #ffc845;
11
+ $positive-clr: #30c39e;
12
+ $disabled-clr: #9ca7ae;
12
13
 
13
14
  /* Blue Colors */
14
- $blue-regular-clr: #2F80ED;
15
- $blue-light-clr: #CDE1FB;
16
- $blue-lightest-clr: #EEF5FE;
15
+ $blue-regular-clr: #2f80ed;
16
+ $blue-light-clr: #cde1fb;
17
+ $blue-lightest-clr: #eef5fe;
17
18
 
18
19
  /* Red Colors */
19
- $red-regular-clr: #F83636;
20
- $red-light-clr: #FDCFCF;
21
- $red-lightest-clr: #FEEFEF;
20
+ $red-regular-clr: #f83636;
21
+ $red-light-clr: #fdcfcf;
22
+ $red-lightest-clr: #feefef;
22
23
 
23
24
  /* Yellow Colors */
24
- $yellow-regular-clr: #FFC845;
25
- $yellow-light-clr: #FFEFC7;
26
- $yellow-lightest-clr: #FFF8E9;
25
+ $yellow-regular-clr: #ffc845;
26
+ $yellow-light-clr: #ffefc7;
27
+ $yellow-lightest-clr: #fff8e9;
27
28
 
28
29
  /* Green Colors */
29
- $green-regular-clr: #30C39E;
30
- $green-light-clr: #C1EDE2;
31
- $green-lightest-clr: #EEFAF7;
30
+ $green-regular-clr: #30c39e;
31
+ $green-light-clr: #c1ede2;
32
+ $green-lightest-clr: #eefaf7;
32
33
 
33
34
  /* Grey Colors */
34
- $grey-regular-clr: #C7CED5;
35
- $grey-light-clr: #D9DEE3;
36
- $grey-lighter-clr: #F3F4F6;
37
- $grey-lightest-clr: #F8F9FA;
35
+ $grey-regular-clr: #c7ced5;
36
+ $grey-light-clr: #d9dee3;
37
+ $grey-lighter-clr: #f3f4f6;
38
+ $grey-lightest-clr: #f8f9fa;
38
39
  $grey-dark-clr: #828282;
39
40
 
40
41
  /* Ink Colors */
41
- $ink-regular-clr: #1D2129;
42
- $ink-light-clr: #3B4352;
43
- $ink-lighter-clr: #6B7586;
44
- $ink-lightest-clr: #9CA7AE;
42
+ $ink-regular-clr: #1d2129;
43
+ $ink-light-clr: #3b4352;
44
+ $ink-lighter-clr: #6b7586;
45
+ $ink-lightest-clr: #9ca7ae;
45
46
 
46
47
  /* Text Colors */
47
- $primary-text-clr: #1D2129;
48
- $subdued-text-clr: #D9DEE3;
48
+ $primary-text-clr: #1d2129;
49
+ $subdued-text-clr: #d9dee3;
49
50
 
50
51
  /* Common Colors */
51
- $white: #FFFFFF;
52
+ $white: #ffffff;
52
53
  $black: #000000;
53
54
 
54
55
  // Gradient Colors
@@ -56,7 +57,7 @@ $gradient-one: linear-gradient(270deg, $grey-lighter-clr 81.75%, rgba(243, 244,
56
57
  $cta-hover-gradient: linear-gradient(0deg, rgba(0, 0, 0, 0.24), rgba(0, 0, 0, 0.24)), $brand-color;
57
58
 
58
59
  /* Typography */
59
- $primary-font: 'Open Sans', sans-serif;
60
+ $primary-font: "Open Sans", sans-serif;
60
61
  $font-size: (
61
62
  24: 24px,
62
63
  18: 18px,
@@ -93,7 +93,22 @@ module CmAdmin
93
93
  end
94
94
  end
95
95
 
96
- def cm_history(params)
96
+ def cm_bulk_action(params)
97
+ @model = Model.find_by({ name: controller_name.classify })
98
+ @bulk_action_processor = CmAdmin::BulkActionProcessor.new(@action, @model, params).perform_bulk_action
99
+ respond_to do |format|
100
+ if @bulk_action_processor.invalid_records.empty?
101
+ format.html { redirect_to request.referrer, notice: "#{@action.name.humanize} is successful" }
102
+ else
103
+ error_messages = @bulk_action_processor.invalid_records.map { |invalid_record|
104
+ "<li>#{invalid_record.error_message}</li>"
105
+ }.join
106
+ format.html { redirect_to request.referrer, alert: "<b>#{@action.name.humanize} is unsuccessful</b><br /><ul>#{error_messages}</ul>" }
107
+ end
108
+ end
109
+ end
110
+
111
+ def cm_history(_params)
97
112
  @current_action = CmAdmin::Models::Action.find_by(@model, name: 'history')
98
113
  resource_identifier
99
114
  respond_to do |format|
@@ -122,15 +137,19 @@ module CmAdmin
122
137
  data = @action.parent == "index" ? @ar_object.data : @ar_object
123
138
  format.html { render @action.partial }
124
139
  else
125
- response_object = @action.code_block.call(@response_object)
126
- if response_object.class == Hash
127
- format.json { render json: response_object }
128
- elsif response_object.errors.empty?
129
- redirect_url = @model.current_action.redirection_url || @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@response_object.id}"
130
- format.html { redirect_to redirect_url, notice: "#{@action.name.titleize} is successful" }
131
- else
132
- error_messages = response_object.errors.full_messages.map{|error_message| "<li>#{error_message}</li>"}.join
133
- format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><ul>#{error_messages}</ul>" }
140
+ begin
141
+ response_object = @action.code_block.call(@response_object)
142
+ if response_object.class == Hash
143
+ format.json { render json: response_object }
144
+ elsif response_object.errors.empty?
145
+ redirect_url = @model.current_action.redirection_url || @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@response_object.id}"
146
+ format.html { redirect_to redirect_url, notice: "#{@action.name.titleize} is successful" }
147
+ else
148
+ error_messages = response_object.errors.full_messages.map{|error_message| "<li>#{error_message}</li>"}.join
149
+ format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><ul>#{error_messages}</ul>" }
150
+ end
151
+ rescue => exception
152
+ format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><p>#{exception.message}</p>" }
134
153
  end
135
154
  end
136
155
  end
@@ -68,5 +68,9 @@ module CmAdmin
68
68
  model.available_actions.map(&:name).include?('show') &&
69
69
  has_valid_policy(model.name, 'show')
70
70
  end
71
+
72
+ def actions_filter(model, action_type)
73
+ model.available_actions.select { |action| action.action_type == action_type && has_valid_policy(model.name, action.name) }
74
+ end
71
75
  end
72
76
  end
@@ -14,6 +14,7 @@ require('/app/assets/javascripts/cm_admin/form_validation.js')
14
14
  require('/app/assets/javascripts/cm_admin/quick_search.js')
15
15
  require('/app/assets/javascripts/cm_admin/filters.js')
16
16
  require('/app/assets/javascripts/cm_admin/exports.js')
17
+ require('/app/assets/javascripts/cm_admin/bulk_actions.js')
17
18
 
18
19
  import jQuery from 'jquery'
19
20
  import LocalTime from "local-time"
@@ -0,0 +1,29 @@
1
+ class CmAdmin::BulkActionProcessor
2
+ extend ActiveSupport::Concern
3
+ attr_accessor :invalid_records
4
+
5
+ def initialize(current_action, model, params)
6
+ @invalid_records = []
7
+ @current_action = current_action
8
+ @model = model
9
+ @params = params
10
+ end
11
+
12
+ def perform_bulk_action
13
+ @params[:selected_ids].split(',').each do |id|
14
+ ar_object = @model.ar_model.find(id)
15
+ column_name = @model.available_fields[:index].first.field_name
16
+ begin
17
+ @current_action.code_block.call(id)
18
+ rescue NoMethodError, NameError => e
19
+ @error_message = "#{e.message.slice(0..(e.message.index(' for')))} at #{ar_object.send(column_name)}"
20
+ rescue ActiveRecord::RecordInvalid => e
21
+ @error_message = "#{e.message} at #{ar_object.send(column_name)}"
22
+ rescue StandardError => e
23
+ @error_message = e.message
24
+ end
25
+ @invalid_records << OpenStruct.new({ row_identifier: ar_object.send(column_name), error_message: @error_message }) if @error_message
26
+ end
27
+ self
28
+ end
29
+ end