cm-admin 0.5.0 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/cm_admin/base/table.scss +71 -10
- data/app/assets/stylesheets/cm_admin/components/_drawer.scss +86 -0
- data/app/assets/stylesheets/cm_admin/components/index.scss +1 -0
- data/app/assets/stylesheets/cm_admin/scaffold.scss +10 -0
- data/app/javascript/packs/cm_admin/scaffolds.js +23 -0
- data/app/views/cm_admin/main/_associated_table.html.slim +20 -18
- data/app/views/cm_admin/main/_drawer.html.slim +13 -0
- data/app/views/cm_admin/main/_nested_fields.html.slim +6 -5
- data/app/views/cm_admin/main/_nested_table_form.html.slim +3 -2
- data/app/views/cm_admin/main/_table.html.slim +4 -1
- data/app/views/cm_admin/main/_top_navbar.html.slim +6 -1
- data/app/views/cm_admin/main/index.html.slim +1 -0
- data/app/views/layouts/_custom_action_modals.html.slim +3 -3
- data/app/views/layouts/cm_admin.html.slim +2 -0
- data/cm_admin.gemspec +2 -2
- data/config/routes.rb +1 -1
- data/lib/cm_admin/engine.rb +2 -0
- data/lib/cm_admin/model.rb +9 -3
- data/lib/cm_admin/models/action.rb +1 -1
- data/lib/cm_admin/models/cm_show_section.rb +0 -2
- data/lib/cm_admin/models/controller_method.rb +8 -7
- data/lib/cm_admin/models/form_field.rb +1 -0
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/form_helper.rb +4 -4
- data/lib/cm_admin/view_helpers/navigation_helper.rb +19 -17
- data/tmp/cache/webpacker/last-compilation-digest-development +1 -1
- data/yarn.lock +6 -6
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 740dc3d69ceebeee0f6137dc2858b9d10bea0f5ef5c71013c988115e445b779b
|
4
|
+
data.tar.gz: d6f44e0ad96646096ab7fd33595c9e57e9605d5f6e746638b1a3141876854adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95e5b8b2e3ac48e776577fe2cdbfb864f82c29777210e57c5342a726593b51d8f543d4b5ef1bafe7e4bb693746881b646ca3504857d07b7749c5ee791b8d4721
|
7
|
+
data.tar.gz: 3b6a1a37c18bbae57b57e662f4ff6401a8fba43470cc7da6b5e1b8af3f174120d15fa928e8d745afddb7f3be20841b4f9b6bc391a935ca2dd29de66bf7f1fe47
|
@@ -5,6 +5,13 @@
|
|
5
5
|
background-color: $white;
|
6
6
|
overflow: auto;
|
7
7
|
|
8
|
+
.sticky-container {
|
9
|
+
z-index: 4;
|
10
|
+
.cm-filters-v2 {
|
11
|
+
padding: 16px 24px 36px 24px;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
8
15
|
&__filters {
|
9
16
|
// If you want to overwrite filters styles ---> add styles here
|
10
17
|
}
|
@@ -65,23 +72,24 @@
|
|
65
72
|
}
|
66
73
|
}
|
67
74
|
|
75
|
+
|
68
76
|
.new-admin-table {
|
69
77
|
overflow: auto;
|
70
78
|
margin-top: 40px;
|
71
79
|
margin-bottom: 50px;
|
80
|
+
height: 280px;
|
72
81
|
.cm-table {
|
73
82
|
table-layout: fixed;
|
74
83
|
position: relative;
|
75
84
|
min-width: fit-content;
|
76
85
|
border-collapse: collapse;
|
77
|
-
white-space: nowrap;
|
78
86
|
border: 1px solid $grey-lighter-clr;
|
79
87
|
border-radius: $radius-8;
|
80
88
|
&__header {
|
81
89
|
.header-row {
|
82
90
|
display: block;
|
83
|
-
position: relative;
|
84
91
|
width: 100%;
|
92
|
+
position: relative;
|
85
93
|
box-shadow: inset 0px -1px 0px rgba(148, 151, 155, 0.15);
|
86
94
|
th {
|
87
95
|
@include font($size: $t6-text, $color: $ink-lighter-clr, $weight: bold);
|
@@ -90,10 +98,22 @@
|
|
90
98
|
max-width: 200px;
|
91
99
|
padding: 12px 16px 12px 16px;
|
92
100
|
}
|
101
|
+
th:nth-child(2){
|
102
|
+
position: sticky;
|
103
|
+
left: 38px;
|
104
|
+
z-index: 2;
|
105
|
+
background-color: #fff;
|
106
|
+
border-bottom: 1.21px solid rgb(240, 239, 239);
|
107
|
+
}
|
93
108
|
.check-box-space {
|
109
|
+
position: sticky;
|
110
|
+
left: 0;
|
94
111
|
min-width: fit-content;
|
95
112
|
max-width: fit-content;
|
96
113
|
padding: 12px 8px 12px 16px;
|
114
|
+
z-index: 2;
|
115
|
+
background-color: #fff;
|
116
|
+
border-bottom: 1.21px solid rgb(240, 239, 239);
|
97
117
|
span {
|
98
118
|
vertical-align: text-top;
|
99
119
|
}
|
@@ -101,24 +121,47 @@
|
|
101
121
|
}
|
102
122
|
}
|
103
123
|
&__body {
|
124
|
+
// display: block;
|
125
|
+
// overflow: auto;
|
126
|
+
// overflow-x: hidden;
|
127
|
+
// position: relative;
|
128
|
+
// width: 100%;
|
129
|
+
// height: 335px;
|
104
130
|
display: block;
|
105
131
|
position: relative;
|
106
|
-
width: 100%;
|
107
|
-
|
108
|
-
|
132
|
+
width: 100%;
|
133
|
+
.body-row {
|
134
|
+
border-bottom: 1.21px solid rgb(240, 239, 239);
|
135
|
+
td:nth-child(2){
|
136
|
+
position: sticky;
|
137
|
+
left: 38px;
|
138
|
+
z-index: 2;
|
139
|
+
background-color: #fff;
|
140
|
+
}
|
141
|
+
|
109
142
|
&:nth-last-child(1) {
|
110
143
|
box-shadow: none;
|
111
144
|
}
|
112
145
|
&:hover {
|
113
146
|
background-color: $grey-lighter-clr;
|
147
|
+
td:nth-child(1) {
|
148
|
+
background-color: $grey-lighter-clr;
|
149
|
+
}
|
150
|
+
td:nth-child(2) {
|
151
|
+
background-color: $grey-lighter-clr;
|
152
|
+
}
|
114
153
|
.row-action-cell {
|
115
154
|
opacity: 1;
|
116
155
|
}
|
117
156
|
}
|
118
157
|
.check-box-space {
|
158
|
+
position: sticky;
|
159
|
+
left: 0;
|
119
160
|
min-width: fit-content;
|
120
161
|
max-width: fit-content;
|
121
162
|
padding: 16px 8px 16px 16px;
|
163
|
+
z-index: 2;
|
164
|
+
background-color: #fff;
|
122
165
|
span {
|
123
166
|
vertical-align: text-top;
|
124
167
|
}
|
@@ -146,6 +189,17 @@
|
|
146
189
|
align-items: center;
|
147
190
|
justify-content: center;
|
148
191
|
height: 100%;
|
192
|
+
.popup-card {
|
193
|
+
width:fit-content;
|
194
|
+
.popup-option {
|
195
|
+
a {
|
196
|
+
font-weight: 500;
|
197
|
+
font-size: 14px;
|
198
|
+
line-height: 22px;
|
199
|
+
color: #1D2129;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
149
203
|
.tool-btn {
|
150
204
|
background-color: transparent;
|
151
205
|
border: none;
|
@@ -155,15 +209,20 @@
|
|
155
209
|
}
|
156
210
|
}
|
157
211
|
}
|
212
|
+
.cm-table > thead {
|
213
|
+
position:sticky;
|
214
|
+
top:0;
|
215
|
+
background-color: #fff;
|
216
|
+
z-index: 3;
|
217
|
+
}
|
158
218
|
}
|
159
219
|
|
160
220
|
.admin-table-index {
|
161
|
-
|
162
221
|
position: fixed;
|
163
222
|
width: calc(100% - 285px);
|
164
223
|
left: 245px;
|
165
224
|
background-color: #fff;
|
166
|
-
z-index:
|
225
|
+
z-index: 4;
|
167
226
|
.table-sticky-top {
|
168
227
|
position: sticky;
|
169
228
|
top: 254px;
|
@@ -173,6 +232,8 @@
|
|
173
232
|
justify-content: space-between;
|
174
233
|
align-items: center;
|
175
234
|
padding-bottom: 16px;
|
235
|
+
margin-top: -20px;
|
236
|
+
background-color: #fff;
|
176
237
|
&__total-count {
|
177
238
|
font-size: $t4-text;
|
178
239
|
line-height: 22px;
|
@@ -222,7 +283,7 @@
|
|
222
283
|
box-shadow: inset 0px 1px 0px rgba(148, 151, 155, 0.15);
|
223
284
|
}
|
224
285
|
}
|
225
|
-
}
|
286
|
+
}
|
226
287
|
|
227
288
|
.columns-list {
|
228
289
|
.column-item {
|
@@ -266,7 +327,7 @@
|
|
266
327
|
}
|
267
328
|
}
|
268
329
|
}
|
269
|
-
}
|
330
|
+
}
|
270
331
|
}
|
271
332
|
|
272
333
|
.cm-pagination {
|
@@ -317,4 +378,4 @@
|
|
317
378
|
}
|
318
379
|
}
|
319
380
|
}
|
320
|
-
}
|
381
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
@import "../helpers/index.scss";
|
2
|
+
|
3
|
+
.cm-drawer {
|
4
|
+
position: fixed;
|
5
|
+
top: 0;
|
6
|
+
right: 0;
|
7
|
+
bottom: 0;
|
8
|
+
left: 0;
|
9
|
+
width: 100%;
|
10
|
+
height: 100%;
|
11
|
+
z-index: 5;
|
12
|
+
background-color: rgba(0, 0, 0, .7);
|
13
|
+
&__container {
|
14
|
+
position: relative;
|
15
|
+
width: 360px;
|
16
|
+
height: 100%;
|
17
|
+
background: $white;
|
18
|
+
box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.16);
|
19
|
+
.header {
|
20
|
+
display: flex;
|
21
|
+
align-items: center;
|
22
|
+
justify-content: space-between;
|
23
|
+
padding: 24px;
|
24
|
+
background: #F8F9FA;
|
25
|
+
&__lhs {
|
26
|
+
.title {
|
27
|
+
font-family: $primary-font;
|
28
|
+
font-size: $t1-text;
|
29
|
+
font-weight: 600;
|
30
|
+
line-height: 28px;
|
31
|
+
color: $primary-text-clr;
|
32
|
+
margin-bottom: 8px;
|
33
|
+
}
|
34
|
+
.description {
|
35
|
+
font-family: $primary-font;
|
36
|
+
font-size: $t4-text;
|
37
|
+
line-height: 22px;
|
38
|
+
color: $primary-text-clr;
|
39
|
+
margin-bottom: 0;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
&__rhs {
|
43
|
+
color: $ink-lighter-clr;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
.body {
|
47
|
+
padding: 24px;
|
48
|
+
.info-text {
|
49
|
+
font-family: $primary-font;
|
50
|
+
font-size: $t4-text;
|
51
|
+
line-height: 22px;
|
52
|
+
color: $primary-text-clr;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
.drawer-slide-in {
|
59
|
+
animation: slideInLeft .3s ease-in forwards;
|
60
|
+
}
|
61
|
+
|
62
|
+
.drawer-slide-out {
|
63
|
+
animation: slideOutLeft .3s ease-in forwards;
|
64
|
+
}
|
65
|
+
|
66
|
+
@keyframes slideInLeft {
|
67
|
+
0% {
|
68
|
+
left: -400px;
|
69
|
+
opacity: 0;
|
70
|
+
}
|
71
|
+
100% {
|
72
|
+
left: 0;
|
73
|
+
opacity: 1;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
@keyframes slideOutLeft {
|
78
|
+
0% {
|
79
|
+
left: 0;
|
80
|
+
opacity: 1;
|
81
|
+
}
|
82
|
+
100% {
|
83
|
+
left: -400px;
|
84
|
+
opacity: 0;
|
85
|
+
}
|
86
|
+
}
|
@@ -40,4 +40,27 @@ $(document).on('click', '.row-action-cell', function(e) {
|
|
40
40
|
} else {
|
41
41
|
return $(this).find('.table-export-popup').addClass('hidden');
|
42
42
|
}
|
43
|
+
});
|
44
|
+
|
45
|
+
|
46
|
+
$(document).on('click', '.drawer-btn', function(e) {
|
47
|
+
e.stopPropagation();
|
48
|
+
if ($('.cm-drawer').hasClass('hidden')) {
|
49
|
+
$('.cm-drawer').removeClass('hidden');
|
50
|
+
if ($('#drawer-container').hasClass('drawer-slide-out')) {
|
51
|
+
$('#drawer-container').removeClass('drawer-slide-out');
|
52
|
+
}
|
53
|
+
$('#drawer-container').addClass('drawer-slide-in');
|
54
|
+
} else {
|
55
|
+
return $('.cm-drawer').addClass('hidden');
|
56
|
+
}
|
57
|
+
});
|
58
|
+
|
59
|
+
$(document).on('click', '.drawer-close', function(e) {
|
60
|
+
e.stopPropagation();
|
61
|
+
$('#drawer-container').removeClass('drawer-slide-in');
|
62
|
+
$('#drawer-container').addClass('drawer-slide-out');
|
63
|
+
setTimeout(() => {
|
64
|
+
$('.cm-drawer').addClass('hidden');
|
65
|
+
}, 300);
|
43
66
|
});
|
@@ -37,24 +37,26 @@
|
|
37
37
|
.popup-option
|
38
38
|
a href="#{page_url('edit', ar_object)}"
|
39
39
|
| Edit
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
/ span.page-num-btn 2
|
49
|
-
/ span.page-num-btn 3
|
50
|
-
/ span.page-num-btn 4
|
51
|
-
/ span.page-num-btn 5
|
52
|
-
/ span.page-move-btn
|
53
|
-
/ i.fa.fa-chevron-right.bolder
|
54
|
-
/ span.page-move-btn
|
55
|
-
/ i.fa.fa-angle-double-right.bolder.f14
|
56
|
-
|
40
|
+
- @associated_model && @associated_model.available_actions.select{|act| act if act.route_type == 'member'}.each do |custom_action|
|
41
|
+
- if custom_action.display_if.call(ar_object)
|
42
|
+
.popup-option
|
43
|
+
- if custom_action.display_type == :button
|
44
|
+
= link_to custom_action.name.titleize, custom_action.path.gsub(':id', ar_object.id.to_s), method: custom_action.verb
|
45
|
+
- elsif custom_action.display_type == :modal
|
46
|
+
= link_to custom_action.name.titleize, '', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal-#{ar_object.id.to_s}" }
|
47
|
+
|
57
48
|
.cm-pagination
|
58
49
|
.cm-pagination__lhs Showing #{@associated_ar_object.pagy.from} to #{@associated_ar_object.pagy.to} out of #{@associated_ar_object.pagy.count}
|
59
50
|
.cm-pagination__rhs
|
60
|
-
== render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @associated_ar_object.pagy }
|
51
|
+
== render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @associated_ar_object.pagy }
|
52
|
+
|
53
|
+
- @associated_ar_object.data.each do |ar_object|
|
54
|
+
- @associated_model && @associated_model.available_actions.select{|act| act if act.route_type == 'member'}.each do |custom_action|
|
55
|
+
.modal.fade id="#{custom_action.name.classify}Modal-#{ar_object.id.to_s}" aria-hidden="true" aria-labelledby="#{custom_action.name.classify}ModalLabel" tabindex="1"
|
56
|
+
.modal-dialog
|
57
|
+
.modal-content
|
58
|
+
.modal-header
|
59
|
+
h5.modal-title id="#{custom_action.name.classify}ModalLabel" = custom_action.name.classify
|
60
|
+
button.btn-close aria-label="Close" data-bs-dismiss="modal" type="button"
|
61
|
+
.modal-body
|
62
|
+
= render partial: custom_action.partial, locals: { ar_object: ar_object }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
.cm-drawer.hidden
|
2
|
+
.cm-drawer__container#drawer-container
|
3
|
+
.header
|
4
|
+
.header__lhs
|
5
|
+
h2.title Review
|
6
|
+
p.description Theresa Webb
|
7
|
+
.header__rhs
|
8
|
+
i.fa.fa-times.drawer-close.pointer
|
9
|
+
.body
|
10
|
+
p.info-text
|
11
|
+
| It was really an amazing experience being an Unschooler. Its really different from other e-learning websites in every aspects like certification, providing internship opportunities and many more. I am going to recommend Unschool for sure!
|
12
|
+
|
13
|
+
|
@@ -1,7 +1,8 @@
|
|
1
1
|
.nested-fields
|
2
2
|
- @model.available_fields[action_name.to_sym][assoc_name].each do |field|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
.row
|
4
|
+
.col-sm-10
|
5
|
+
= input_field_for_column(f, field)
|
6
|
+
.col-sm-2
|
7
|
+
- if @reflections.select {|x| x if x.name == assoc_name}.first.macro == :has_many
|
8
|
+
= link_to_remove_association "x", f
|
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
.nested-field-wrapper
|
2
|
+
label.field-label = table_name.to_s.titleize
|
2
3
|
= f.fields_for table_name do |record|
|
3
4
|
= render partial: '/cm_admin/main/nested_fields', locals: { f: record, assoc_name: table_name }
|
4
5
|
- if @reflections.select {|x| x if x.name == table_name}.first.macro == :has_many
|
5
6
|
.links
|
6
|
-
= link_to_add_association "
|
7
|
+
= link_to_add_association "+ Add #{table_name.to_s.titleize}", f, table_name, partial: '/cm_admin/main/nested_fields', render_options: {locals: { assoc_name: table_name }}
|
@@ -16,6 +16,7 @@
|
|
16
16
|
input.cm-checkbox type="checkbox"
|
17
17
|
- @model.available_fields[:index].each do |column|
|
18
18
|
th = column.header
|
19
|
+
// th Drawer
|
19
20
|
tbody.cm-table__body
|
20
21
|
- @ar_object.data.each do |ar_object|
|
21
22
|
tr.body-row
|
@@ -26,9 +27,11 @@
|
|
26
27
|
td.text-ellipsis
|
27
28
|
span class="#{column.cm_css_class}"
|
28
29
|
- if index == 0
|
29
|
-
= link_to ar_object.send(column.field_name), "/cm_admin/#{
|
30
|
+
= link_to ar_object.send(column.field_name), "/cm_admin/#{ar_object.model_name.collection}/#{ar_object.id}"
|
30
31
|
- else
|
31
32
|
= show_field_value(ar_object, column)
|
33
|
+
// td
|
34
|
+
// button.drawer-btn Open Drawer
|
32
35
|
td.row-action-cell
|
33
36
|
.row-action-tool
|
34
37
|
button.secondary-btn.tool-btn type="button"
|
@@ -33,4 +33,9 @@
|
|
33
33
|
- if custom_action.display_type == :button && custom_action.display_if.call(@ar_object)
|
34
34
|
= link_to custom_action.name.titleize, custom_action.path.gsub(':id', params[:id]), class: 'primary-btn ml-2', method: custom_action.verb
|
35
35
|
- elsif custom_action.display_type == :modal && custom_action.display_if.call(@ar_object)
|
36
|
-
= link_to custom_action.name.titleize, '', class: 'primary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
|
36
|
+
= link_to custom_action.name.titleize, '', class: 'primary-btn ml-2', data: { bs_toggle: "modal", bs_target: "##{custom_action.name.classify}Modal" }
|
37
|
+
|
38
|
+
- edit_action = @model.available_actions.select{|act| act if act.action_type.eql?(:default) && act.name.eql?('edit')}
|
39
|
+
- if edit_action.any?
|
40
|
+
a.primary-btn.ml-2 href="#{page_url('edit', @ar_object)}"
|
41
|
+
= "Edit #{@model.name}"
|
@@ -1,9 +1,9 @@
|
|
1
|
-
- @model.available_actions.select{|act| act if act.
|
2
|
-
.modal.fade id="#{custom_action.name.classify}Modal" aria-hidden="true" aria-labelledby="
|
1
|
+
- @model.available_actions.select{|act| act if act.display_type == :modal}.each do |custom_action|
|
2
|
+
.modal.fade id="#{custom_action.name.classify}Modal" aria-hidden="true" aria-labelledby="#{custom_action.name.classify}ModalLabel" tabindex="1"
|
3
3
|
.modal-dialog
|
4
4
|
.modal-content
|
5
5
|
.modal-header
|
6
|
-
h5
|
6
|
+
h5.modal-title id="#{custom_action.name.classify}ModalLabel" = custom_action.name.classify
|
7
7
|
button.btn-close aria-label="Close" data-bs-dismiss="modal" type="button"
|
8
8
|
.modal-body
|
9
9
|
= render partial: custom_action.partial
|
@@ -10,6 +10,8 @@ html
|
|
10
10
|
= stylesheet_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
|
11
11
|
link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" /
|
12
12
|
= javascript_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
|
13
|
+
= javascript_include_tag 'cm_admin/custom', 'data-turbolinks-track': 'reload'
|
14
|
+
= stylesheet_link_tag 'cm_admin/custom', media: 'all', 'data-turbolinks-track': 'reload'
|
13
15
|
script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"
|
14
16
|
script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"
|
15
17
|
body
|
data/cm_admin.gemspec
CHANGED
@@ -3,8 +3,8 @@ require_relative 'lib/cm_admin/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "cm-admin"
|
5
5
|
spec.version = CmAdmin::VERSION
|
6
|
-
spec.authors = ["sajinmp", "anbublacky", "
|
7
|
-
spec.email = ["sajinprasadkm@gmail.com", "anbublacky@gmail.com"]
|
6
|
+
spec.authors = ["sajinmp", "anbublacky", "AdityaTiwari2102"]
|
7
|
+
spec.email = ["sajinprasadkm@gmail.com", "anbublacky@gmail.com", "taditya.tiwari007@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = %q{This is an admin panel gem}
|
10
10
|
spec.description = %q{This is an admin panel gem}
|
data/config/routes.rb
CHANGED
@@ -12,7 +12,7 @@ CmAdmin::Engine.routes.draw do
|
|
12
12
|
CmAdmin.cm_admin_models.each do |model|
|
13
13
|
model.available_actions.sort_by {|act| act.class}.each do |act|
|
14
14
|
scope model.name.tableize do
|
15
|
-
send(act.verb, act.path.present? ? act.path : act.name, to: "#{model.name.underscore}##{act.name}")
|
15
|
+
send(act.verb, act.path.present? ? act.path : act.name, to: "#{model.name.underscore}##{act.name}", as: "#{model.name.underscore}_#{act.name}")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/cm_admin/engine.rb
CHANGED
data/lib/cm_admin/model.rb
CHANGED
@@ -22,7 +22,7 @@ module CmAdmin
|
|
22
22
|
include Models::DslMethod
|
23
23
|
include Models::ControllerMethod
|
24
24
|
attr_accessor :available_actions, :actions_set, :available_fields, :permitted_fields, :current_action, :params, :filters, :available_tabs
|
25
|
-
attr_reader :name, :ar_model
|
25
|
+
attr_reader :name, :ar_model, :is_visible_on_sidebar
|
26
26
|
|
27
27
|
# Class variable for storing all actions
|
28
28
|
# CmAdmin::Model.all_actions
|
@@ -31,6 +31,7 @@ module CmAdmin
|
|
31
31
|
def initialize(entity, &block)
|
32
32
|
@name = entity.name
|
33
33
|
@ar_model = entity
|
34
|
+
@is_visible_on_sidebar = true
|
34
35
|
@available_actions ||= []
|
35
36
|
@current_action = nil
|
36
37
|
@available_tabs ||= []
|
@@ -85,6 +86,10 @@ module CmAdmin
|
|
85
86
|
@actions_set = true
|
86
87
|
end
|
87
88
|
|
89
|
+
def visible_on_sidebar(visible_option)
|
90
|
+
@is_visible_on_sidebar = visible_option
|
91
|
+
end
|
92
|
+
|
88
93
|
|
89
94
|
private
|
90
95
|
|
@@ -99,6 +104,7 @@ module CmAdmin
|
|
99
104
|
@model = CmAdmin::Model.find_by(name: controller_name.classify)
|
100
105
|
@model.params = params
|
101
106
|
@action = CmAdmin::Models::Action.find_by(@model, name: action_name)
|
107
|
+
@model.current_action = @action
|
102
108
|
@ar_object = @model.try(@action.parent || action_name, params)
|
103
109
|
@ar_object, @associated_model, @associated_ar_object = @model.custom_controller_action(action_name, params.permit!) if !@ar_object.present? && params[:id].present?
|
104
110
|
aar_model = request.url.split('/')[-2].classify.constantize if params[:aar_id]
|
@@ -134,11 +140,11 @@ module CmAdmin
|
|
134
140
|
data = @action.parent == "index" ? @ar_object.data : @ar_object
|
135
141
|
format.html { render action.partial }
|
136
142
|
else
|
137
|
-
redirect_url = request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@ar_object.id}"
|
138
143
|
if @action.code_block.call(@ar_object)
|
144
|
+
redirect_url = @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@ar_object.id}"
|
139
145
|
format.html { redirect_to redirect_url }
|
140
146
|
else
|
141
|
-
format.html { redirect_to
|
147
|
+
format.html { redirect_to request.referrer }
|
142
148
|
end
|
143
149
|
end
|
144
150
|
elsif action.layout.present?
|
@@ -6,7 +6,7 @@ module CmAdmin
|
|
6
6
|
include Actions::Blocks
|
7
7
|
attr_accessor :name, :verb, :layout_type, :layout, :partial, :path, :page_title, :page_description,
|
8
8
|
:child_records, :is_nested_field, :nested_table_name, :parent, :display_if, :route_type, :code_block,
|
9
|
-
:display_type, :action_type
|
9
|
+
:display_type, :action_type, :redirection_url
|
10
10
|
|
11
11
|
def initialize(attributes = {}, &block)
|
12
12
|
if attributes[:layout_type].present? && attributes[:layout].nil? && attributes[:partial].nil?
|
@@ -7,12 +7,10 @@ module CmAdmin
|
|
7
7
|
def initialize(section_name, &block)
|
8
8
|
@available_section_fields = []
|
9
9
|
@section_name = section_name
|
10
|
-
puts "-- reached here --"
|
11
10
|
instance_eval(&block)
|
12
11
|
end
|
13
12
|
|
14
13
|
def field(field_name, options={})
|
15
|
-
puts "For printing field #{field_name}"
|
16
14
|
@available_section_fields << CmAdmin::Models::Field.new(field_name, options)
|
17
15
|
end
|
18
16
|
end
|
@@ -7,23 +7,23 @@ module CmAdmin
|
|
7
7
|
@current_action = CmAdmin::Models::Action.find_by(self, name: 'show')
|
8
8
|
@ar_object = @ar_model.find(params[:id])
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def index(params)
|
12
12
|
@current_action = CmAdmin::Models::Action.find_by(self, name: 'index')
|
13
13
|
# Based on the params the filter and pagination object to be set
|
14
14
|
@ar_object = filter_by(params, nil, filter_params(params))
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def new(params)
|
18
18
|
@current_action = CmAdmin::Models::Action.find_by(self, name: 'new')
|
19
19
|
@ar_object = @ar_model.new
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def edit(params)
|
23
23
|
@current_action = CmAdmin::Models::Action.find_by(self, name: 'edit')
|
24
24
|
@ar_object = @ar_model.find(params[:id])
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def update(params)
|
28
28
|
@ar_object = @ar_model.find(params[:id])
|
29
29
|
@ar_object.assign_attributes(resource_params(params))
|
@@ -50,7 +50,7 @@ module CmAdmin
|
|
50
50
|
# filtered_result.facets.sort = sort_params
|
51
51
|
return filtered_result
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def resource_params(params)
|
55
55
|
permittable_fields = @permitted_fields || @ar_model.columns.map(&:name).reject { |i| CmAdmin::REJECTABLE_FIELDS.include?(i) }.map(&:to_sym)
|
56
56
|
permittable_fields += @ar_model.reflect_on_all_attachments.map {|x|
|
@@ -62,15 +62,16 @@ module CmAdmin
|
|
62
62
|
}.compact
|
63
63
|
nested_tables = self.available_fields[:new].except(:fields).keys
|
64
64
|
nested_tables += self.available_fields[:edit].except(:fields).keys
|
65
|
-
nested_fields = nested_tables.map {|table|
|
65
|
+
nested_fields = nested_tables.uniq.map {|table|
|
66
66
|
Hash[
|
67
67
|
table.to_s + '_attributes',
|
68
68
|
table.to_s.classify.constantize.columns.map(&:name).reject { |i| CmAdmin::REJECTABLE_FIELDS.include?(i) }.map(&:to_sym) + [:id, :_destroy]
|
69
69
|
]
|
70
70
|
}
|
71
71
|
permittable_fields += nested_fields
|
72
|
+
@ar_model.columns.map { |col| permittable_fields << col.name.split('_cents') if col.name.include?('_cents') }
|
72
73
|
params.require(self.name.underscore.to_sym).permit(*permittable_fields)
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
76
|
-
end
|
77
|
+
end
|
data/lib/cm_admin/version.rb
CHANGED
@@ -22,7 +22,7 @@ module CmAdmin
|
|
22
22
|
|
23
23
|
def form_with_all_fields(resource, method)
|
24
24
|
columns = resource.class.columns.dup
|
25
|
-
table_name = resource.
|
25
|
+
table_name = resource.model_name.collection
|
26
26
|
columns.reject! { |i| REJECTABLE.include?(i.name) }
|
27
27
|
url = CmAdmin::Engine.mount_path + "/#{table_name}/#{resource.id}"
|
28
28
|
set_form_for_fields(resource, columns, url, method)
|
@@ -30,7 +30,7 @@ module CmAdmin
|
|
30
30
|
|
31
31
|
def form_with_mentioned_fields(resource, available_fields, method)
|
32
32
|
# columns = resource.class.columns.select { |i| available_fields.map(&:field_name).include?(i.name.to_sym) }
|
33
|
-
table_name = resource.
|
33
|
+
table_name = resource.model_name.collection
|
34
34
|
# columns.reject! { |i| REJECTABLE.include?(i.name) }
|
35
35
|
url = CmAdmin::Engine.mount_path + "/#{table_name}/#{resource.id}"
|
36
36
|
set_form_for_fields(resource, available_fields, url, method)
|
@@ -44,10 +44,10 @@ module CmAdmin
|
|
44
44
|
if field.input_type.eql?(:hidden)
|
45
45
|
concat input_field_for_column(f, field)
|
46
46
|
else
|
47
|
-
concat f.label field.
|
47
|
+
concat f.label field.label, class: 'field-label'
|
48
48
|
concat tag.br
|
49
49
|
concat(content_tag(:div, class: "datetime-wrapper") do
|
50
|
-
concat input_field_for_column(f, field)
|
50
|
+
concat input_field_for_column(f, field)
|
51
51
|
end)
|
52
52
|
concat tag.p resource.errors[field.field_name].first if resource.errors[field.field_name].present?
|
53
53
|
end
|
@@ -5,26 +5,28 @@ module CmAdmin
|
|
5
5
|
include Pagy::Frontend
|
6
6
|
def navigation_links(navigation_type)
|
7
7
|
CmAdmin.cm_admin_models.map { |model|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
content_tag(:
|
12
|
-
content_tag(:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
elsif navigation_type == "quick_links"
|
19
|
-
content_tag(:a, href: path, class: 'visible') do
|
20
|
-
content_tag(:div, class: 'result-item') do
|
21
|
-
content_tag(:span) do
|
22
|
-
concat tag.i class: 'fa fa-th-large'
|
23
|
-
end +
|
24
|
-
content_tag(:span) do
|
8
|
+
if model.is_visible_on_sidebar
|
9
|
+
path = CmAdmin::Engine.mount_path + '/' + model.name.underscore.pluralize
|
10
|
+
if navigation_type == "sidebar"
|
11
|
+
content_tag(:a, href: path) do
|
12
|
+
content_tag(:div, class: 'menu-item') do
|
13
|
+
content_tag(:span, class: 'menu-icon') do
|
14
|
+
concat tag.i class: 'fa fa-th-large'
|
15
|
+
end +
|
25
16
|
model.name
|
26
17
|
end
|
27
18
|
end
|
19
|
+
elsif navigation_type == "quick_links"
|
20
|
+
content_tag(:a, href: path, class: 'visible') do
|
21
|
+
content_tag(:div, class: 'result-item') do
|
22
|
+
content_tag(:span) do
|
23
|
+
concat tag.i class: 'fa fa-th-large'
|
24
|
+
end +
|
25
|
+
content_tag(:span) do
|
26
|
+
model.name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
}.join.html_safe
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
07d558738c316293586496817b2bccbf6430b5bd
|
data/yarn.lock
CHANGED
@@ -2941,9 +2941,9 @@ flush-write-stream@^1.0.0:
|
|
2941
2941
|
readable-stream "^2.3.6"
|
2942
2942
|
|
2943
2943
|
follow-redirects@^1.0.0:
|
2944
|
-
version "1.14.
|
2945
|
-
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.
|
2946
|
-
integrity sha512-
|
2944
|
+
version "1.14.8"
|
2945
|
+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
|
2946
|
+
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
|
2947
2947
|
|
2948
2948
|
for-in@^1.0.2:
|
2949
2949
|
version "1.0.2"
|
@@ -6589,9 +6589,9 @@ urix@^0.1.0:
|
|
6589
6589
|
integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=
|
6590
6590
|
|
6591
6591
|
url-parse@^1.4.3, url-parse@^1.5.1:
|
6592
|
-
version "1.5.
|
6593
|
-
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.
|
6594
|
-
integrity sha512-
|
6592
|
+
version "1.5.7"
|
6593
|
+
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.7.tgz#00780f60dbdae90181f51ed85fb24109422c932a"
|
6594
|
+
integrity sha512-HxWkieX+STA38EDk7CE9MEryFeHCKzgagxlGvsdS7WBImq9Mk+PGwiT56w82WI3aicwJA8REp42Cxo98c8FZMA==
|
6595
6595
|
dependencies:
|
6596
6596
|
querystringify "^2.1.1"
|
6597
6597
|
requires-port "^1.0.0"
|
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: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sajinmp
|
8
8
|
- anbublacky
|
9
|
-
-
|
9
|
+
- AdityaTiwari2102
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pagy
|
@@ -86,6 +86,7 @@ description: This is an admin panel gem
|
|
86
86
|
email:
|
87
87
|
- sajinprasadkm@gmail.com
|
88
88
|
- anbublacky@gmail.com
|
89
|
+
- taditya.tiwari007@gmail.com
|
89
90
|
executables: []
|
90
91
|
extensions: []
|
91
92
|
extra_rdoc_files: []
|
@@ -115,6 +116,7 @@ files:
|
|
115
116
|
- app/assets/stylesheets/cm_admin/cm_admin.css.scss
|
116
117
|
- app/assets/stylesheets/cm_admin/components/_alerts.scss
|
117
118
|
- app/assets/stylesheets/cm_admin/components/_buttons.scss
|
119
|
+
- app/assets/stylesheets/cm_admin/components/_drawer.scss
|
118
120
|
- app/assets/stylesheets/cm_admin/components/_dropdown-popup.scss
|
119
121
|
- app/assets/stylesheets/cm_admin/components/_input.scss
|
120
122
|
- app/assets/stylesheets/cm_admin/components/_modal.scss
|
@@ -138,6 +140,7 @@ files:
|
|
138
140
|
- app/javascript/stylesheets/cm_admin/application.scss
|
139
141
|
- app/views/cm_admin/main/_associated_table.html.slim
|
140
142
|
- app/views/cm_admin/main/_cm_pagy_nav.html.slim
|
143
|
+
- app/views/cm_admin/main/_drawer.html.slim
|
141
144
|
- app/views/cm_admin/main/_filters.html.slim
|
142
145
|
- app/views/cm_admin/main/_nested_fields.html.slim
|
143
146
|
- app/views/cm_admin/main/_nested_table_form.html.slim
|