cm-admin 2.4.3 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/cm_admin/bulk_actions.js +9 -7
- data/app/assets/stylesheets/cm_admin/base/form.scss +34 -0
- data/app/views/cm_admin/main/_table.html.slim +1 -2
- data/lib/cm_admin/models/bulk_action.rb +1 -5
- data/lib/cm_admin/models/dsl_method.rb +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/page_info_helper.rb +70 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0637794147d28cbeb2b09c9162104aabb3c5b7f52e3fb9e42c6a291e89b8e5e
|
4
|
+
data.tar.gz: 7971b87140570d9a486c65522fa762a960b5d5bc1e2cb392abcb36beec867003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e61028998a91e7279541570fd4e881cdc9263f3bd89f03db97e0b057c6667e32f69481164cf294bd6c517a55ec34de5c744b50e98340192c56861325eb9a7bb
|
7
|
+
data.tar.gz: 2cacfa59737f253733fe9b362464515f944e876e4e67b5e21f0895bd5691c6888c7a9d4013432d80b0ad24b04b4e9f52712786e445826ab539aef4d490a6a1cc
|
data/Gemfile.lock
CHANGED
@@ -23,14 +23,16 @@ function setBulkActionParams() {
|
|
23
23
|
$('[data-behaviour="bulk-action-checkbox"]:checked').each(function(){ selected_ids.push($(this).data('ar-object-id')) })
|
24
24
|
var bulk_action_form = '[data-section="bulk-action"] form'
|
25
25
|
if ($(bulk_action_form)) {
|
26
|
-
|
27
|
-
$('
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
$(bulk_action_form).each(function( i ) {
|
27
|
+
if ($(this).find('[name="selected_ids"]').length == 0) {
|
28
|
+
$('<input>').attr({
|
29
|
+
type: 'hidden',
|
30
|
+
name: 'selected_ids'
|
31
|
+
}).appendTo(this);
|
32
|
+
}
|
33
|
+
})
|
32
34
|
}
|
33
35
|
$('[data-section="bulk-action"] [name="selected_ids"]').each(function( i ) {
|
34
36
|
$(this).val(selected_ids)
|
35
37
|
})
|
36
|
-
}
|
38
|
+
}
|
@@ -118,3 +118,37 @@
|
|
118
118
|
.discard-form {
|
119
119
|
margin-left: 16px;
|
120
120
|
}
|
121
|
+
|
122
|
+
// Bulk Actions Dropdown
|
123
|
+
.bulk-action-item {
|
124
|
+
|
125
|
+
form {
|
126
|
+
width: 100%;
|
127
|
+
}
|
128
|
+
|
129
|
+
.bulk-action-icon {
|
130
|
+
width: 20px;
|
131
|
+
height: 20px;
|
132
|
+
|
133
|
+
svg {
|
134
|
+
width: 100%;
|
135
|
+
height: 100%;
|
136
|
+
object-fit: contain;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
.bulk-action-button {
|
141
|
+
@extend .d-flex, .align-items-center, .gap-2;
|
142
|
+
|
143
|
+
&:hover {
|
144
|
+
color: inherit;
|
145
|
+
text-decoration: none;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
a {
|
150
|
+
display: flex;
|
151
|
+
gap: 8px;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
@@ -20,8 +20,7 @@
|
|
20
20
|
- bulk_actions = actions_filter(@model, @ar_object, :bulk_action)
|
21
21
|
- if bulk_actions.present?
|
22
22
|
.table-top.hidden data-section="bulk-action"
|
23
|
-
|
24
|
-
= custom_action_items(action, 'index')
|
23
|
+
= bulk_action_items(bulk_actions, 'index')
|
25
24
|
.table-wrapper
|
26
25
|
table.index-table data-bulk-actions=(bulk_actions.present? && "present")
|
27
26
|
thead
|
@@ -282,7 +282,7 @@ module CmAdmin
|
|
282
282
|
# @param redirection_url [String] the redirection url of action
|
283
283
|
# @param icon_name [String] the icon name of action, follow font-awesome icon name
|
284
284
|
# @param verb [String] the verb of action, +get+, +post+, +put+, +patch+ or +delete+
|
285
|
-
# @param display_type [Symbol] the display type of action, +:page+, +:modal+
|
285
|
+
# @param display_type [Symbol] the display type of action, +:page+, +:modal+, +:button+, +:icon_only+[deprecated]
|
286
286
|
# @param modal_configuration [Hash] the configuration of modal
|
287
287
|
# @param route_type [String] the route type of action, +member+, +collection+
|
288
288
|
# @param partial [String] the partial path of action
|
data/lib/cm_admin/version.rb
CHANGED
@@ -86,6 +86,76 @@ module CmAdmin
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
def bulk_action_items(bulk_items, current_action_name)
|
90
|
+
content_tag :div, class: 'dropdown' do
|
91
|
+
concat(link_to('Bulk Actions', '#', class: 'dropdown-toggle', role: 'button', id: 'dropdownMenuLink', data: { bs_toggle: 'dropdown' }, aria: { expanded: false }))
|
92
|
+
|
93
|
+
concat(
|
94
|
+
content_tag(:ul, class: 'dropdown-menu', aria: { labelledby: 'dropdownMenuLink' }) do
|
95
|
+
bulk_action_dropdown_items(bulk_items, current_action_name)
|
96
|
+
end
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def bulk_action_dropdown_items(bulk_items, current_action_name)
|
102
|
+
bulk_items.each do |bulk_action|
|
103
|
+
next unless bulk_action.name.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{bulk_action.name}?")
|
104
|
+
|
105
|
+
scoped_model = bulk_action.name.present? && policy([:cm_admin, @model.name.classify.constantize]).send(:"#{bulk_action.name}?")
|
106
|
+
|
107
|
+
has_scoped_record = if current_action_name == 'index'
|
108
|
+
scoped_model.present?
|
109
|
+
else
|
110
|
+
scoped_model.find_by(id: ar_object.id).present?
|
111
|
+
end
|
112
|
+
|
113
|
+
next unless bulk_action.display_if.call(@ar_object) && has_scoped_record
|
114
|
+
|
115
|
+
case bulk_action.display_type
|
116
|
+
when :button
|
117
|
+
bulk_action_button(bulk_action)
|
118
|
+
when :modal
|
119
|
+
bulk_action_modal(bulk_action)
|
120
|
+
when :page
|
121
|
+
bulk_action_page(bulk_action)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def bulk_action_button(bulk_action)
|
127
|
+
concat(content_tag(:li, class: 'bulk-action-item', data: { action: bulk_action.name }) do
|
128
|
+
button_to cm_admin.send("#{@model.name.underscore}_#{bulk_action.name}_path"), method: :post, params: { selected_ids: '' }, class: 'bulk-action-button dropdown-item' do
|
129
|
+
concat(content_tag(:div, class: 'bulk-action-icon') do
|
130
|
+
concat(content_tag(:i, '', class: bulk_action.icon_name))
|
131
|
+
end)
|
132
|
+
concat(content_tag(:span, custom_action_title(bulk_action)))
|
133
|
+
end
|
134
|
+
end)
|
135
|
+
end
|
136
|
+
|
137
|
+
def bulk_action_modal(bulk_action)
|
138
|
+
concat(content_tag(:li, class: 'bulk-action-item', data: { action: bulk_action.name }) do
|
139
|
+
link_to '#', data: { bs_toggle: 'modal', bs_target: "##{bulk_action.name.classify}Modal-#{@ar_object.id}" }, class: 'dropdown-item' do
|
140
|
+
concat(content_tag(:div, class: 'bulk-action-icon') do
|
141
|
+
concat(content_tag(:i, '', class: bulk_action.icon_name))
|
142
|
+
end)
|
143
|
+
concat(content_tag(:span, bulk_action.display_name))
|
144
|
+
end
|
145
|
+
end)
|
146
|
+
end
|
147
|
+
|
148
|
+
def bulk_action_page(bulk_action)
|
149
|
+
concat(content_tag(:li, class: 'bulk-action-item', data: { action: bulk_action.name }) do
|
150
|
+
link_to cm_admin.send("#{@model.name.underscore}_#{bulk_action.name}_path", @ar_object, bulk_action.url_params), class: 'dropdown-item' do
|
151
|
+
concat(content_tag(:div, class: 'bulk-action-icon') do
|
152
|
+
concat(content_tag(:i, '', class: bulk_action.icon_name))
|
153
|
+
end)
|
154
|
+
concat(content_tag(:span, bulk_action.display_name))
|
155
|
+
end
|
156
|
+
end)
|
157
|
+
end
|
158
|
+
|
89
159
|
def custom_action_title(custom_action)
|
90
160
|
custom_action.display_name.to_s.presence || custom_action.name.to_s.titleize
|
91
161
|
end
|
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: 2.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
|
-
date: 2024-10-
|
17
|
+
date: 2024-10-18 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: caxlsx_rails
|