cm-admin 0.8.3 → 0.8.5
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 +2 -2
- data/app/javascript/packs/cm_admin/filters.js +7 -7
- data/app/models/concerns/cm_admin/file_import.rb +1 -1
- data/app/views/cm_admin/main/_top_navbar.html.slim +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/filter_helper.rb +36 -11
- 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: 8f213806205dddde4c26ef831ca86ff31fdd612f054ca899d579276abec08af9
|
4
|
+
data.tar.gz: 6cfd6cacae15a3939dc6f0f45c898e58d0276836db665a84823d142e8f3806f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e2cc59b2ed25bcb3041065288a352352d74be6ddfe44dc643aeabd748bb3779615418f60eab139e6757a5f2be9da28430a411ea919edc7e1f762765a98a30e6
|
7
|
+
data.tar.gz: 1877097421a3bb47a51d2483c7361d1d906502306f98732150706d31f933535d17e0e196927c84d702c7e3103d96f98e4cd108b14cb288e8fcac1a610cb8af8d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cm-admin (0.8.
|
4
|
+
cm-admin (0.8.5)
|
5
5
|
caxlsx_rails
|
6
6
|
cocoon (~> 1.2.15)
|
7
7
|
csv-importer (~> 0.8.2)
|
@@ -146,7 +146,7 @@ GEM
|
|
146
146
|
rack-proxy (>= 0.6.1)
|
147
147
|
railties (>= 5.2)
|
148
148
|
semantic_range (>= 2.3.0)
|
149
|
-
zeitwerk (2.6.
|
149
|
+
zeitwerk (2.6.1)
|
150
150
|
|
151
151
|
PLATFORMS
|
152
152
|
ruby
|
@@ -193,6 +193,7 @@ $(document).on('click', '[data-behaviour="select-option"]', function(e) {
|
|
193
193
|
|
194
194
|
if (filterType == 'single_select') {
|
195
195
|
var filterValue = $(this).data('value')
|
196
|
+
var filterText = $(this).text()
|
196
197
|
if (!this.classList.contains('selected')) {
|
197
198
|
if (this.parentNode.querySelector('.list-item.selected') != null) {
|
198
199
|
this.parentNode.querySelector('.list-item.selected').classList.remove('selected');
|
@@ -200,7 +201,7 @@ $(document).on('click', '[data-behaviour="select-option"]', function(e) {
|
|
200
201
|
$(this).addClass('selected')
|
201
202
|
}
|
202
203
|
|
203
|
-
$(this).parents(':nth(4)').children(':first').children(':nth(1)').text(
|
204
|
+
$(this).parents(':nth(4)').children(':first').children(':nth(1)').text(filterText)
|
204
205
|
$(this).parents(':nth(4)').children(':first').children(':last').removeClass('hidden')
|
205
206
|
|
206
207
|
// Clear the search value post selection and regenerate the dropdown elements.
|
@@ -216,16 +217,15 @@ $(document).on('click', '[data-behaviour="select-option"]', function(e) {
|
|
216
217
|
var checkboxElement = $(this).find('.cm-checkbox')
|
217
218
|
checkboxElement.prop('checked', !checkboxElement.prop('checked'))
|
218
219
|
var checkedCount = $(this).parent().find('.cm-checkbox').filter(':checked').length
|
219
|
-
|
220
220
|
if (checkboxElement.prop('checked')) {
|
221
221
|
var chip = $('<div class="chip"></div>')
|
222
|
-
var firstSpan = $('<span></span>').text($(this).
|
222
|
+
var firstSpan = $('<span></span>').text($(this).text())
|
223
223
|
var secondSpan = $('<span data-behaviour="selected-chip"><i class="fa fa-times"></i></span>')
|
224
224
|
parentChip.prepend(chip.append(firstSpan).append(secondSpan))
|
225
225
|
} else {
|
226
226
|
var chipElement = parentChip.find('.chip')
|
227
227
|
for(var i = 0; i < chipElement.length; i++) {
|
228
|
-
if ($(chipElement[i]).text() == $(this).
|
228
|
+
if ($(chipElement[i]).text() == $(this).text()) {
|
229
229
|
$(chipElement[i]).remove()
|
230
230
|
break
|
231
231
|
}
|
@@ -248,6 +248,7 @@ $(document).on('click', '.apply-area', function(e) {
|
|
248
248
|
var filterType = filterInputElement.data('filter-type')
|
249
249
|
var filterColumn = filterInputElement.data('db-column')
|
250
250
|
var filterValue = []
|
251
|
+
var filterValueText = []
|
251
252
|
|
252
253
|
var selectFilterElement = $('[data-behaviour="select-option"][data-filter-type=' + filterType + '][data-db-column=' + filterColumn + ']')
|
253
254
|
var checkedElements = selectFilterElement.find('.cm-checkbox').filter(':checked')
|
@@ -255,9 +256,10 @@ $(document).on('click', '.apply-area', function(e) {
|
|
255
256
|
if (checkedElements.length > 0) {
|
256
257
|
for(var i = 0; i < checkedElements.length; i++) {
|
257
258
|
filterValue.push($(checkedElements[i]).parent().data('value'))
|
259
|
+
filterValueText.push($(checkedElements[i]).parent().text())
|
258
260
|
}
|
259
261
|
|
260
|
-
truncatedFilterValue =
|
262
|
+
truncatedFilterValue = filterValueText[0]
|
261
263
|
if (filterValue.length > 1) {
|
262
264
|
truncatedFilterValue += ' + ' + (filterValue.length - 1) + ' more'
|
263
265
|
}
|
@@ -335,8 +337,6 @@ CmFilter = {
|
|
335
337
|
var filter = element.val().toUpperCase();
|
336
338
|
var searchElements = element.parents(':nth(3)').find('.list-area').children();
|
337
339
|
searchElements.removeClass('visible').addClass('hidden')
|
338
|
-
console.log("Filter is ", filter)
|
339
|
-
console.log("Search elements are ", searchElements)
|
340
340
|
for (var i = 0; i < searchElements.length; i++) {
|
341
341
|
txtValue = $(searchElements[i]).children().text();
|
342
342
|
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
@@ -4,7 +4,7 @@ module CmAdmin::FileImport
|
|
4
4
|
cm_admin do
|
5
5
|
STATUS_TAG_COLOR = { in_progress: 'yellow-tag', success: 'success'}
|
6
6
|
actions only: [:index, :show]
|
7
|
-
set_icon 'fa fa-
|
7
|
+
set_icon 'fa fa-file-upload'
|
8
8
|
cm_index do
|
9
9
|
page_title 'File Import'
|
10
10
|
page_description 'Manage all file import progress here'
|
@@ -23,7 +23,7 @@
|
|
23
23
|
li
|
24
24
|
.popup-option.pointer data-bs-toggle='modal' data-bs-target='#exportmodal'
|
25
25
|
span Export
|
26
|
-
- if @model.importer
|
26
|
+
- if @model.importer && has_valid_policy(@model.name, :importable)
|
27
27
|
= link_to 'Import', cm_admin.send(:"#{@model.name.underscore}_import_path"), class: 'primary-btn ml-2'
|
28
28
|
- new_action = @model.available_actions.select{|act| act if act.action_type.eql?(:default) && act.name.eql?('new')}
|
29
29
|
- if new_action.any? && policy([:cm_admin, @model.name.classify.constantize]).new?
|
data/lib/cm_admin/version.rb
CHANGED
@@ -71,7 +71,7 @@ module CmAdmin
|
|
71
71
|
|
72
72
|
if value && filter.filter_type.to_s.eql?('multi_select')
|
73
73
|
truncated_value = value[0]
|
74
|
-
truncated_value += " + #{value.size - 1} more" if
|
74
|
+
truncated_value += " + #{value.size - 1} more" if value.size > 1
|
75
75
|
end
|
76
76
|
|
77
77
|
concat(content_tag(:div, class: "filter-chip #{filter.filter_type.to_s.eql?('single_select') ? 'dropdown' : ''}", data: data_hash) do
|
@@ -126,7 +126,12 @@ module CmAdmin
|
|
126
126
|
def add_single_select_filter(filter)
|
127
127
|
value = params.dig(:filters, :"#{filter.filter_type}", :"#{filter.db_column_name}")
|
128
128
|
concat(content_tag(:div, class: "position-relative mr-3 #{value ? '' : 'hidden'}") do
|
129
|
-
|
129
|
+
if value && filter.collection[0].class == Array
|
130
|
+
selected_value_text = filter.collection.map{|collection| collection[0] if collection[1].to_s.eql?(value) }.compact.join(', ')
|
131
|
+
else
|
132
|
+
selected_value_text = value
|
133
|
+
end
|
134
|
+
concat filter_chip(selected_value_text, filter)
|
130
135
|
|
131
136
|
concat(content_tag(:div, class: 'dropdown-menu dropdown-popup') do
|
132
137
|
concat(content_tag(:div, class: 'popup-base') do
|
@@ -136,8 +141,14 @@ module CmAdmin
|
|
136
141
|
end)
|
137
142
|
concat(content_tag(:div, class: 'list-area') do
|
138
143
|
filter.collection.each do |val|
|
139
|
-
|
140
|
-
|
144
|
+
if val.class.eql?(Array)
|
145
|
+
filter_value = val[1]
|
146
|
+
filter_text = val[0]
|
147
|
+
elsif val.class.eql?(String)
|
148
|
+
filter_value = filter_text = val
|
149
|
+
end
|
150
|
+
concat(content_tag(:div, class: "pointer list-item #{(value.present? && value.eql?(filter_value.to_s)) ? 'selected' : ''}", data: {behaviour: 'select-option', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}", value: filter_value}) do
|
151
|
+
concat tag.span filter_text.to_s
|
141
152
|
end)
|
142
153
|
end
|
143
154
|
end)
|
@@ -150,16 +161,24 @@ module CmAdmin
|
|
150
161
|
|
151
162
|
def add_multi_select_filter(filter)
|
152
163
|
value = params.dig(:filters, :"#{filter.filter_type}", :"#{filter.db_column_name}")
|
153
|
-
|
164
|
+
if value && filter.collection[0].class == Array
|
165
|
+
value_mapped_text = []
|
166
|
+
filter.collection.each do |array|
|
167
|
+
value_mapped_text << array[0].titleize if value.include?(array[1].to_s)
|
168
|
+
end
|
169
|
+
else
|
170
|
+
value_mapped_text = value
|
171
|
+
end
|
172
|
+
|
154
173
|
concat(content_tag(:div, class: "position-relative mr-3 #{value ? '' : 'hidden'}") do
|
155
|
-
concat filter_chip(
|
174
|
+
concat filter_chip(value_mapped_text, filter)
|
156
175
|
|
157
176
|
concat(content_tag(:div, class: 'position-absolute mt-2 dropdown-popup hidden') do
|
158
177
|
concat(content_tag(:div, class: 'popup-base') do
|
159
178
|
concat(content_tag(:div, class: 'popup-inner') do
|
160
179
|
concat(content_tag(:div, class: "#{value ? 'search-with-chips' : 'search-area'}") do
|
161
|
-
if
|
162
|
-
|
180
|
+
if value_mapped_text
|
181
|
+
value_mapped_text.each do |val|
|
163
182
|
concat(content_tag(:div, class: 'chip') do
|
164
183
|
concat tag.span val
|
165
184
|
concat(content_tag(:span, data: { behaviour: 'selected-chip' }) do
|
@@ -172,9 +191,15 @@ module CmAdmin
|
|
172
191
|
end)
|
173
192
|
concat(content_tag(:div, class: 'list-area') do
|
174
193
|
filter.collection.each do |val|
|
175
|
-
|
176
|
-
|
177
|
-
|
194
|
+
if val.class.eql?(Array)
|
195
|
+
filter_value = val[1]
|
196
|
+
filter_text = val[0]
|
197
|
+
elsif val.class.eql?(String)
|
198
|
+
filter_value = filter_text = val
|
199
|
+
end
|
200
|
+
concat(content_tag(:div, class: "pointer list-item #{(value && (value.eql?(val) || value.include?(filter_value.to_s))) ? 'selected' : ''}", data: {behaviour: 'select-option', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}", value: filter_value}) do
|
201
|
+
concat tag.input class: 'cm-checkbox', type: 'checkbox', checked: value ? value.include?(filter_value.to_s) : false
|
202
|
+
concat tag.label filter_text.to_s.titleize, class: 'pointer'
|
178
203
|
end)
|
179
204
|
end
|
180
205
|
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: 0.8.
|
4
|
+
version: 0.8.5
|
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: 2022-10-
|
13
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: caxlsx_rails
|