cm-admin 1.2.9 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/stylesheets/cm_admin/base/cardView.scss +43 -0
- data/app/assets/stylesheets/cm_admin/base/form.scss +0 -19
- data/app/assets/stylesheets/cm_admin/base/scaffold.scss +1 -1
- data/app/assets/stylesheets/cm_admin/base/table.scss +117 -122
- data/app/assets/stylesheets/cm_admin/cm_admin.css.scss +2 -1
- data/app/javascript/packs/cm_admin/scaffolds.js +1 -1
- data/app/views/cm_admin/main/_associated_table.html.slim +5 -7
- data/app/views/cm_admin/main/_card.html.slim +71 -0
- data/app/views/cm_admin/main/_member_custom_action_modal.html.slim +4 -1
- data/app/views/cm_admin/main/_nested_fields.html.slim +1 -1
- data/app/views/cm_admin/main/_nested_table_form.html.slim +1 -1
- data/app/views/cm_admin/main/_nested_table_section.html.slim +4 -4
- data/app/views/cm_admin/main/_table.html.slim +23 -20
- data/app/views/cm_admin/main/index.html.slim +2 -0
- data/app/views/cm_admin/main/new.html.slim +1 -1
- data/lib/cm_admin/models/action.rb +4 -3
- data/lib/cm_admin/models/column.rb +1 -0
- data/lib/cm_admin/models/dsl_method.rb +2 -2
- data/lib/cm_admin/models/field.rb +1 -0
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/field_display_helper.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e81bb0ae8315860549d0c446bd231a8a4d03f7ec71d43e0bc3dae928d24a052
|
4
|
+
data.tar.gz: 879a1484880f42892d1dd7dc1cab06aa3c54d69f908f9b9ca88c87fb2dddef5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41529999b8a9d3d59cd3f9832f5dbc5e9a7c53229b20307610251a3e3a8f1b4b187fd3fdd961c772bda56e499f4684a71be0c2456d4babb9fb14caaff723beb6
|
7
|
+
data.tar.gz: e2412a8f6502af1d1adc2b7b122c49da5518f6dfedd3a54b580efed363cb2392568d695d13653c9235644cdb7d75a0dc75edf3f43513510cf85ae35cb2f52a04
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
@import "../helpers/index.scss";
|
2
|
+
@import "../dependency/bootstrap/scss/bootstrap";
|
3
|
+
|
4
|
+
.card-list-container {
|
5
|
+
overflow: hidden;
|
6
|
+
padding-right: 24px;
|
7
|
+
.card-grid {
|
8
|
+
@extend .row, .row-cols-4, .g-3;
|
9
|
+
}
|
10
|
+
.item-card {
|
11
|
+
@extend .card, .position-relative;
|
12
|
+
border-radius: 4px;
|
13
|
+
.card-menu {
|
14
|
+
@extend .dropdown, .position-absolute;
|
15
|
+
top: 8px;
|
16
|
+
right: 8px;
|
17
|
+
}
|
18
|
+
.card-img-top {
|
19
|
+
height: 185px;
|
20
|
+
object-fit: cover;
|
21
|
+
border-top-left-radius: 4px;
|
22
|
+
border-top-right-radius: 4px;
|
23
|
+
}
|
24
|
+
.card-subtitle {
|
25
|
+
@extend .d-flex, .justify-content-between, .text-secondary, .fw-medium;
|
26
|
+
font-size: $t4-text;
|
27
|
+
.item-id {
|
28
|
+
margin: 0;
|
29
|
+
span {
|
30
|
+
border-left: 1px solid;
|
31
|
+
padding-left: 4px;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
.card-footer {
|
36
|
+
@extend .d-flex, .justify-content-between, .bg-white;
|
37
|
+
.item-price {
|
38
|
+
font-size: $t4-text;
|
39
|
+
margin: 0;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
@@ -72,22 +72,3 @@
|
|
72
72
|
visibility: hidden;
|
73
73
|
}
|
74
74
|
}
|
75
|
-
|
76
|
-
//Nested form table styles
|
77
|
-
.nested-form-table-wrapper {
|
78
|
-
overflow-y: scroll;
|
79
|
-
.nested-form-table {
|
80
|
-
@extend .table, .table-light, .table-hover, .table-bordered, .m-0;
|
81
|
-
width: max-content;
|
82
|
-
.item-delete-cell {
|
83
|
-
vertical-align: middle;
|
84
|
-
text-align: center;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
.nested-table-footer {
|
90
|
-
padding: 8px;
|
91
|
-
border: 1px solid var(--bs-border-color);
|
92
|
-
border-top: 0;
|
93
|
-
}
|
@@ -37,143 +37,97 @@
|
|
37
37
|
}
|
38
38
|
}
|
39
39
|
|
40
|
-
//Table UI
|
41
|
-
.
|
40
|
+
// Table UI v2
|
41
|
+
.table-wrapper {
|
42
42
|
min-width: 720px;
|
43
43
|
max-width: fit-content;
|
44
|
-
|
44
|
+
max-height: calc(100vh - 240px);
|
45
45
|
overflow: auto;
|
46
|
-
.
|
47
|
-
table-
|
46
|
+
.index-table {
|
47
|
+
@extend .table, .table-hover;
|
48
|
+
border: 1px solid $grey-lighter-clr;
|
48
49
|
position: relative;
|
49
50
|
min-width: 720px;
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
background-color: $white;
|
73
|
-
border-bottom: 1.21px solid rgb(240, 239, 239);
|
74
|
-
}
|
75
|
-
.check-box-space {
|
76
|
-
position: sticky;
|
77
|
-
left: 0;
|
78
|
-
min-width: fit-content;
|
79
|
-
max-width: fit-content;
|
80
|
-
padding: 12px 8px 12px 16px;
|
81
|
-
z-index: 2;
|
82
|
-
background-color: $white;
|
83
|
-
border-bottom: 1.21px solid rgb(240, 239, 239);
|
84
|
-
span {
|
85
|
-
vertical-align: text-top;
|
86
|
-
}
|
87
|
-
}
|
51
|
+
margin: 0;
|
52
|
+
thead {
|
53
|
+
position: sticky;
|
54
|
+
top: 0;
|
55
|
+
z-index: 4;
|
56
|
+
background-color: $white;
|
57
|
+
th {
|
58
|
+
font-size: 12px;
|
59
|
+
min-width: 120px;
|
60
|
+
max-width: 240px;
|
61
|
+
}
|
62
|
+
th:nth-child(1) {
|
63
|
+
position: sticky;
|
64
|
+
left: 0;
|
65
|
+
z-index: 2;
|
66
|
+
background-color: $white;
|
67
|
+
}
|
68
|
+
th:nth-child(2) {
|
69
|
+
position: sticky;
|
70
|
+
left: 32px;
|
71
|
+
z-index: 2;
|
72
|
+
background-color: $white;
|
88
73
|
}
|
89
74
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
background-color: $white;
|
95
|
-
.body-row {
|
96
|
-
display: flex;
|
97
|
-
border-bottom: 1.21px solid rgb(240, 239, 239);
|
98
|
-
td:nth-child(1) {
|
99
|
-
position: sticky;
|
100
|
-
left: 0;
|
101
|
-
z-index: 2;
|
102
|
-
background-color: $white;
|
103
|
-
}
|
104
|
-
&:nth-last-child(1) {
|
105
|
-
box-shadow: none;
|
106
|
-
}
|
75
|
+
|
76
|
+
tbody {
|
77
|
+
tr {
|
78
|
+
border-bottom: 1px solid var(--bs-border-color);
|
107
79
|
&:hover {
|
108
|
-
background-color: $grey-lighter-clr;
|
109
|
-
td:nth-child(1) {
|
110
|
-
background-color: $grey-lighter-clr;
|
111
|
-
}
|
112
80
|
.row-action-cell {
|
113
|
-
|
114
|
-
}
|
115
|
-
}
|
116
|
-
.check-box-space {
|
117
|
-
position: sticky;
|
118
|
-
left: 0;
|
119
|
-
min-width: fit-content;
|
120
|
-
max-width: fit-content;
|
121
|
-
padding: 16px 8px 16px 16px;
|
122
|
-
z-index: 2;
|
123
|
-
background-color: $white;
|
124
|
-
span {
|
125
|
-
vertical-align: text-top;
|
81
|
+
visibility: visible;
|
126
82
|
}
|
127
83
|
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
84
|
+
}
|
85
|
+
td {
|
86
|
+
font-size: $t4-text;
|
87
|
+
min-width: 120px;
|
88
|
+
max-width: 240px;
|
89
|
+
}
|
90
|
+
td:nth-child(1) {
|
91
|
+
position: sticky;
|
92
|
+
left: 0;
|
93
|
+
z-index: 2;
|
94
|
+
background-color: $white;
|
95
|
+
}
|
96
|
+
td:nth-child(2) {
|
97
|
+
position: sticky;
|
98
|
+
left: 32px;
|
99
|
+
z-index: 2;
|
100
|
+
background-color: $white;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
.check-box-space {
|
105
|
+
min-width: 32px;
|
106
|
+
max-width: 32px;
|
107
|
+
font-size: $t4-text;
|
108
|
+
}
|
109
|
+
|
110
|
+
.row-action-cell {
|
111
|
+
position: sticky;
|
112
|
+
right: 0;
|
113
|
+
max-width: inherit;
|
114
|
+
min-width: inherit;
|
115
|
+
padding: 4px;
|
116
|
+
background: $gradient-one;
|
117
|
+
visibility: hidden;
|
118
|
+
z-index: 3;
|
119
|
+
.row-action-tool {
|
120
|
+
.popup-card {
|
121
|
+
.popup-option {
|
122
|
+
a {
|
123
|
+
@include font($size: $t4-text, $color: $ink-regular-clr, $weight: 500);
|
124
|
+
line-height: 22px;
|
165
125
|
}
|
166
126
|
}
|
167
127
|
}
|
168
128
|
}
|
169
129
|
}
|
170
130
|
}
|
171
|
-
.cm-table > thead {
|
172
|
-
position: sticky;
|
173
|
-
top: 0;
|
174
|
-
background-color: $white;
|
175
|
-
z-index: 4;
|
176
|
-
}
|
177
131
|
}
|
178
132
|
|
179
133
|
// table-column-modal
|
@@ -266,7 +220,7 @@
|
|
266
220
|
bottom: 0;
|
267
221
|
left: 0;
|
268
222
|
border: 1px solid $grey-lighter-clr;
|
269
|
-
box-shadow:
|
223
|
+
box-shadow: 0px 1px 0px 0px rgba(148, 151, 155, 0.3) inset;
|
270
224
|
z-index: 2;
|
271
225
|
.count-text {
|
272
226
|
@include font($size: $t4-text, $color: var(--bs-body-color));
|
@@ -281,11 +235,52 @@
|
|
281
235
|
}
|
282
236
|
}
|
283
237
|
|
284
|
-
|
238
|
+
[data-field-type="money"] {
|
239
|
+
text-align: right;
|
240
|
+
}
|
241
|
+
|
242
|
+
//Nested show table styles
|
285
243
|
.nested-table-wrapper {
|
286
244
|
overflow-y: scroll;
|
287
245
|
.nested-table {
|
288
246
|
@extend .table, .table-light, .table-hover, .table-bordered;
|
289
247
|
width: max-content;
|
290
248
|
}
|
249
|
+
th,
|
250
|
+
td {
|
251
|
+
min-width: 120px;
|
252
|
+
max-width: 240px;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
//Nested form table styles
|
257
|
+
.nested-form-table-wrapper {
|
258
|
+
overflow-y: scroll;
|
259
|
+
.nested-form-table {
|
260
|
+
@extend .table, .table-light, .table-hover, .table-bordered, .m-0;
|
261
|
+
width: max-content;
|
262
|
+
.item-delete-cell {
|
263
|
+
vertical-align: middle;
|
264
|
+
text-align: center;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
th:nth-child(1) {
|
268
|
+
min-width: 47px;
|
269
|
+
max-width: 47px;
|
270
|
+
}
|
271
|
+
td:nth-child(1) {
|
272
|
+
min-width: 47px;
|
273
|
+
max-width: 47px;
|
274
|
+
}
|
275
|
+
th,
|
276
|
+
td {
|
277
|
+
min-width: 120px;
|
278
|
+
max-width: 240px;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
.nested-table-footer {
|
283
|
+
padding: 8px;
|
284
|
+
border: 1px solid var(--bs-border-color);
|
285
|
+
border-top: 0;
|
291
286
|
}
|
@@ -22,6 +22,7 @@
|
|
22
22
|
*= require 'cm_admin/base/auth'
|
23
23
|
*= require 'cm_admin/base/filters'
|
24
24
|
*= require 'cm_admin/base/common'
|
25
|
+
*= require 'cm_admin/base/cardView'
|
25
26
|
*= require 'cm_admin/components/index'
|
26
27
|
*= require 'cm_admin/dependency/bootstrap.min'
|
27
28
|
*= require 'cm_admin/dependency/flatpickr.min'
|
@@ -29,4 +30,4 @@
|
|
29
30
|
*= require 'cm_admin/dependency/jquery-jgrowl.min'
|
30
31
|
*= require 'cm_admin/scaffold'
|
31
32
|
*= require_self
|
32
|
-
*/
|
33
|
+
*/
|
@@ -20,5 +20,5 @@ $(document).on('turbolinks:load', function () {
|
|
20
20
|
}
|
21
21
|
var headerElemHeight = $('.page-top-bar').height() + 64
|
22
22
|
var calculatedHeight = "calc(100vh - " + headerElemHeight+"px"+")"
|
23
|
-
$('.
|
23
|
+
$('.table-wrapper').css("maxHeight", calculatedHeight);
|
24
24
|
});
|
@@ -25,8 +25,8 @@
|
|
25
25
|
.table-top.hidden data-section="bulk-action"
|
26
26
|
- bulk_actions.each do |action|
|
27
27
|
= custom_action_items(action, 'index')
|
28
|
-
.
|
29
|
-
table.
|
28
|
+
.table-wrapper
|
29
|
+
table.index-table
|
30
30
|
thead.cm-table__header
|
31
31
|
tr.header-row
|
32
32
|
- if bulk_actions.present?
|
@@ -57,9 +57,7 @@
|
|
57
57
|
- if @associated_model
|
58
58
|
== render partial: 'cm_admin/main/actions_dropdown', locals: { cm_model: @associated_model, ar_object: ar_object }
|
59
59
|
|
60
|
-
.
|
61
|
-
.
|
62
|
-
.
|
63
|
-
== render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @associated_ar_object.pagy }
|
64
|
-
|
60
|
+
.pagination-bar
|
61
|
+
p.count-text.m-0 Showing #{@associated_ar_object.pagy.from} to #{@associated_ar_object.pagy.to} out of #{@associated_ar_object.pagy.count}
|
62
|
+
== render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @associated_ar_object.pagy }
|
65
63
|
= render partial: 'cm_admin/main/member_custom_action_modal', locals: { cm_model: @associated_model, ar_collection: @associated_ar_object }
|
@@ -0,0 +1,71 @@
|
|
1
|
+
// Card view right now is application specific, so card partial will be overwritten in the application
|
2
|
+
|
3
|
+
.table-top
|
4
|
+
p.table-top__total-count = "#{humanized_ar_collection_count(@ar_object.pagy.count, @model.ar_model.table_name)}"
|
5
|
+
.table-top__column-action
|
6
|
+
.btn-group[role="group" aria-label="Basic example"]
|
7
|
+
a.btn.btn-ghost href="#{cm_admin.send("#{@model.name.underscore}_index_path")}?page=#{params[:page] || 1}"
|
8
|
+
i.fa.fa-table
|
9
|
+
a.btn.btn-ghost href="#{cm_admin.send("#{@model.name.underscore}_index_path")}?page=#{params[:page] || 1}&list_type=card"
|
10
|
+
i.fa.fa-table-cells
|
11
|
+
/ button.secondary-btn.column-btn data-bs-target="#columnActionModal" data-bs-toggle="modal"
|
12
|
+
/ span
|
13
|
+
/ i.fa.fa-columns.bolder
|
14
|
+
/ span
|
15
|
+
/ i.fa.fa-angle-down
|
16
|
+
- if flash[:alert].present?
|
17
|
+
.alert.alert-danger role="alert"
|
18
|
+
= flash[:alert].html_safe
|
19
|
+
- elsif flash[:notice].present?
|
20
|
+
.alert.alert-success
|
21
|
+
= flash[:notice].html_safe
|
22
|
+
|
23
|
+
- bulk_actions = actions_filter(@model, :bulk_action)
|
24
|
+
- if bulk_actions.present?
|
25
|
+
.table-top.hidden data-section="bulk-action"
|
26
|
+
- bulk_actions.each do |action|
|
27
|
+
= custom_action_items(action, 'index')
|
28
|
+
.card-list-container
|
29
|
+
.card-grid
|
30
|
+
- @ar_object.data.each_slice(3) do |chunk|
|
31
|
+
- chunk.each do |ar_object|
|
32
|
+
.col
|
33
|
+
.item-card
|
34
|
+
.card-menu
|
35
|
+
.row-action-cell
|
36
|
+
== render partial: 'cm_admin/main/actions_dropdown', locals: { cm_model: @model, ar_object: ar_object }
|
37
|
+
img.card-img-top[src="https://images.unsplash.com/photo-1658211312038-4293c7bdd37e?auto=format&fit=crop&q=80&w=3280&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" alt="..."]
|
38
|
+
.card-body
|
39
|
+
- @model.available_fields[:index].each_with_index do |column, index|
|
40
|
+
- if column.display_if.call(Current.user) && column.viewable
|
41
|
+
- if index == 0 && is_show_action_available(@model) && !([:link, :custom, :attachment, :drawer, :image].include?(column.field_type))
|
42
|
+
h6.card-title
|
43
|
+
| Coffee table
|
44
|
+
.card-subtitle
|
45
|
+
p.item-id
|
46
|
+
| TB-6910
|
47
|
+
span
|
48
|
+
| Table
|
49
|
+
p.m-0
|
50
|
+
| Nadim
|
51
|
+
/ h6.card-title
|
52
|
+
/ = link_to ar_object.send(column.field_name), cm_admin.send("#{ar_object.model_name.singular}_show_path", ar_object.id)
|
53
|
+
- else
|
54
|
+
p.card-text
|
55
|
+
= show_field_value(ar_object, column)
|
56
|
+
- if column.field_type == :drawer
|
57
|
+
= render partial: column.drawer_partial, locals: { ar_object: ar_object }
|
58
|
+
.card-footer
|
59
|
+
p.item-price
|
60
|
+
| L.E 100,000
|
61
|
+
.item-status
|
62
|
+
span.status-tag.danger
|
63
|
+
| Out of stock
|
64
|
+
span.status-tag.active.ms-1
|
65
|
+
| Active
|
66
|
+
|
67
|
+
.pagination-bar
|
68
|
+
p.count-text.m-0 Showing #{@ar_object.pagy.from} to #{@ar_object.pagy.to} out of #{@ar_object.pagy.count}
|
69
|
+
== render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @ar_object.pagy }
|
70
|
+
|
71
|
+
/ = render partial: 'cm_admin/main/member_custom_action_modal', locals: { cm_model: @model, ar_collection: @ar_object }
|
@@ -10,4 +10,7 @@
|
|
10
10
|
h5.modal-title id="#{custom_action.name.classify}ModalLabel" = custom_action_title(custom_action)
|
11
11
|
button.btn-close aria-label='Close' data-bs-dismiss='modal'
|
12
12
|
.modal-body
|
13
|
-
|
13
|
+
- if custom_action.partial
|
14
|
+
= render partial: custom_action.partial
|
15
|
+
- else
|
16
|
+
= render partial: 'cm_admin/main/custom_action_modal_form', locals: { custom_action: custom_action, ar_object: ar_object }
|
@@ -3,7 +3,7 @@
|
|
3
3
|
td.item-delete-cell
|
4
4
|
= link_to_remove_association "", f, class: 'fa-regular fa-trash-can btn-ghost'
|
5
5
|
- nested_table_field.fields.each do |field|
|
6
|
-
td
|
6
|
+
td data-field-type="#{field.input_type}"
|
7
7
|
= input_field_for_column(f, field)
|
8
8
|
- else
|
9
9
|
.form-card.nested-fields
|
@@ -3,22 +3,22 @@
|
|
3
3
|
div class="#{nested_field.label ? 'card-info' : ''}"
|
4
4
|
- if nested_field.label
|
5
5
|
p.card-info__label = nested_field.label.to_s.titleize
|
6
|
-
.card-info__description.nested-table-wrapper
|
6
|
+
.card-info__description.nested-table-wrapper data-table-name="#{nested_field.field_name}"
|
7
7
|
table.nested-table
|
8
8
|
thead
|
9
9
|
tr
|
10
10
|
- nested_field.fields.each do |field|
|
11
|
-
th scope="col"
|
11
|
+
th scope="col" data-field-type="#{field.field_type}"
|
12
12
|
= field.label || field.field_name.to_s.titleize
|
13
13
|
tbody
|
14
14
|
- associated_records.each do |record|
|
15
15
|
tr
|
16
16
|
- nested_field.fields.each do |field|
|
17
|
-
td
|
17
|
+
td data-field-type="#{field.field_type}"
|
18
18
|
= record.send(field.field_name)
|
19
19
|
- else
|
20
20
|
- associated_records.each do |record|
|
21
|
-
.card.mb-3
|
21
|
+
.card.mb-3 data-table-name="#{nested_field.field_name}"
|
22
22
|
.card-body
|
23
23
|
.card-info
|
24
24
|
.card-info__title = nested_section_title(record, nested_field)
|
@@ -1,6 +1,12 @@
|
|
1
1
|
.table-top
|
2
2
|
p.table-top__total-count = "#{humanized_ar_collection_count(@ar_object.pagy.count, @model.ar_model.table_name)}"
|
3
|
-
|
3
|
+
.table-top__column-action
|
4
|
+
- if @current_action.card_layout
|
5
|
+
.btn-group[role="group" aria-label="Card Toggle"]
|
6
|
+
a.btn.btn-ghost href="#{cm_admin.send("#{@model.name.underscore}_index_path")}?page=#{params[:page] || 1}"
|
7
|
+
i.fa.fa-table
|
8
|
+
a.btn.btn-ghost href="#{cm_admin.send("#{@model.name.underscore}_index_path")}?page=#{params[:page] || 1}&list_type=card"
|
9
|
+
i.fa.fa-table-cells
|
4
10
|
/ button.secondary-btn.column-btn data-bs-target="#columnActionModal" data-bs-toggle="modal"
|
5
11
|
/ span
|
6
12
|
/ i.fa.fa-columns.bolder
|
@@ -18,37 +24,34 @@
|
|
18
24
|
.table-top.hidden data-section="bulk-action"
|
19
25
|
- bulk_actions.each do |action|
|
20
26
|
= custom_action_items(action, 'index')
|
21
|
-
.
|
22
|
-
table.
|
23
|
-
thead
|
24
|
-
tr
|
27
|
+
.table-wrapper
|
28
|
+
table.index-table
|
29
|
+
thead
|
30
|
+
tr
|
25
31
|
- if bulk_actions.present?
|
26
32
|
th.check-box-space
|
27
|
-
|
28
|
-
input.cm-checkbox type="checkbox" data-behaviour="bulk-action-select-all"
|
33
|
+
input.form-check-input type="checkbox" data-behaviour="bulk-action-select-all"
|
29
34
|
- @model.available_fields[:index].each do |column|
|
30
35
|
- if column.display_if.call(Current.user) && column.viewable
|
31
|
-
th = column.header
|
32
|
-
|
36
|
+
th data-field-type="#{column.field_type}" = column.header
|
37
|
+
th
|
38
|
+
tbody
|
33
39
|
- @ar_object.data.each do |ar_object|
|
34
40
|
tr.body-row
|
35
41
|
- if bulk_actions.present?
|
36
42
|
td.check-box-space
|
37
|
-
|
38
|
-
input.cm-checkbox type="checkbox" data-behaviour="bulk-action-checkbox" data-ar-object-id="#{ar_object.id}"
|
43
|
+
input.form-check-input type="checkbox" data-behaviour="bulk-action-checkbox" data-ar-object-id="#{ar_object.id}"
|
39
44
|
- @model.available_fields[:index].each_with_index do |column, index|
|
40
45
|
- if column.display_if.call(Current.user) && column.viewable
|
41
|
-
td.text-ellipsis
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
= render partial: column.drawer_partial, locals: { ar_object: ar_object }
|
46
|
+
td.text-ellipsis data-field-type="#{column.field_type || 'string'}"
|
47
|
+
- if index == 0 && is_show_action_available(@model) && !([:link, :custom, :attachment, :drawer, :image].include?(column.field_type))
|
48
|
+
= link_to ar_object.send(column.field_name), cm_admin.send("#{ar_object.model_name.singular}_show_path", ar_object.id)
|
49
|
+
- else
|
50
|
+
= show_field_value(ar_object, column)
|
51
|
+
- if column.field_type == :drawer
|
52
|
+
= render partial: column.drawer_partial, locals: { ar_object: ar_object }
|
49
53
|
- if @model
|
50
54
|
== render partial: 'cm_admin/main/actions_dropdown', locals: { cm_model: @model, ar_object: ar_object }
|
51
|
-
|
52
55
|
.pagination-bar
|
53
56
|
p.count-text.m-0 Showing #{@ar_object.pagy.from} to #{@ar_object.pagy.to} out of #{@ar_object.pagy.count}
|
54
57
|
== render partial: 'cm_admin/main/cm_pagy_nav', locals: { pagy: @ar_object.pagy }
|
@@ -6,7 +6,7 @@ module CmAdmin
|
|
6
6
|
include Actions::Blocks
|
7
7
|
attr_accessor :name, :display_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, :redirection_url, :sort_direction, :sort_column, :icon_name, :scopes
|
9
|
+
:display_type, :action_type, :redirection_url, :sort_direction, :sort_column, :icon_name, :scopes, :card_layout
|
10
10
|
|
11
11
|
VALID_SORT_DIRECTION = Set[:asc, :desc].freeze
|
12
12
|
|
@@ -39,13 +39,14 @@ module CmAdmin
|
|
39
39
|
self.verb = :get
|
40
40
|
self.route_type = nil
|
41
41
|
self.display_type = nil
|
42
|
-
|
42
|
+
self.card_layout = false
|
43
43
|
end
|
44
44
|
|
45
|
-
def set_values(page_title, page_description, partial)
|
45
|
+
def set_values(page_title, page_description, partial, card_layout=false)
|
46
46
|
self.page_title = page_title
|
47
47
|
self.page_description = page_description
|
48
48
|
self.partial = partial
|
49
|
+
self.card_layout = card_layout
|
49
50
|
end
|
50
51
|
|
51
52
|
def controller_action_name
|
@@ -3,9 +3,9 @@ module CmAdmin
|
|
3
3
|
module DslMethod
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
def cm_index(page_title: nil, page_description: nil, partial: nil, &block)
|
6
|
+
def cm_index(page_title: nil, page_description: nil, partial: nil, card_layout: false, &block)
|
7
7
|
@current_action = CmAdmin::Models::Action.find_by(self, name: 'index')
|
8
|
-
@current_action.set_values(page_title, page_description, partial)
|
8
|
+
@current_action.set_values(page_title, page_description, partial, card_layout)
|
9
9
|
yield
|
10
10
|
end
|
11
11
|
|
data/lib/cm_admin/version.rb
CHANGED
@@ -49,6 +49,10 @@ module CmAdmin
|
|
49
49
|
local_date(ar_object.send(field.field_name), (field.format || '%B %e, %Y'))
|
50
50
|
when :text
|
51
51
|
ar_object.send(field.field_name)
|
52
|
+
when :money
|
53
|
+
humanized_money(ar_object.send(field.field_name))
|
54
|
+
when :money_with_symbol
|
55
|
+
humanized_money_with_symbol(ar_object.send(field.field_name))
|
52
56
|
when :custom
|
53
57
|
send(field.helper_method, ar_object, field.field_name)
|
54
58
|
when :link
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sajinmp
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-11-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- app/assets/javascripts/cm_admin/scaffolds.js
|
202
202
|
- app/assets/javascripts/cm_admin/shared_scaffolds.js
|
203
203
|
- app/assets/stylesheets/cm_admin/base/auth.scss
|
204
|
+
- app/assets/stylesheets/cm_admin/base/cardView.scss
|
204
205
|
- app/assets/stylesheets/cm_admin/base/common.scss
|
205
206
|
- app/assets/stylesheets/cm_admin/base/filters.scss
|
206
207
|
- app/assets/stylesheets/cm_admin/base/form.scss
|
@@ -348,6 +349,7 @@ files:
|
|
348
349
|
- app/policies/cm_admin/file_import_policy.rb
|
349
350
|
- app/views/cm_admin/main/_actions_dropdown.html.slim
|
350
351
|
- app/views/cm_admin/main/_associated_table.html.slim
|
352
|
+
- app/views/cm_admin/main/_card.html.slim
|
351
353
|
- app/views/cm_admin/main/_cm_pagy_nav.html.slim
|
352
354
|
- app/views/cm_admin/main/_custom_action_modal_form.html.slim
|
353
355
|
- app/views/cm_admin/main/_drawer.html.slim
|