cm-admin 3.0.9 → 3.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7470565c394ee297e76878ead64578e8fcb5cc7458b69516fc397f2577374d76
4
- data.tar.gz: bf8f4e1694b6e8b4f5095f05eb9df1919a1fb4ce49d588d1fe576346cc76dd46
3
+ metadata.gz: ff19f67d38436ec27a855939e767014dd4f5141ab77bab65a008214335bbc173
4
+ data.tar.gz: '085404b4f42517231f0afdf48ea0616a3333eb4a1492d82234bbdaebeb75c8fa'
5
5
  SHA512:
6
- metadata.gz: 7e3de3b4dd2892626348a9feab18726c4cc370cca3d9a98625cb7e0a228f21b760413adb5f0e55607cfb4c02fb11625833f0dbd601e134d3dd14eb7aae733945
7
- data.tar.gz: 9624eb827a4a5459f4f254e8f57f771afe8f9f6109493e136def8d1e9a0012aa76676fab59fbcd0851b8fcc6c9c9ef073c6a909e5b36bd393de269ec63b3ec82
6
+ metadata.gz: 7a11b38ef299303693933134bea4bdbe55136f49890839e2628ef7fb9c7a4615913b492560a8bb5b2d09642aa914138604ae78349c19cabdf0dcd6cffd08ad25
7
+ data.tar.gz: 5cd4341e3125c9627bfb0dab6ad8a42acbbaeb91e27324c48bdccca80e0c30039b20178fffb689e549d482c4f5a977a9ccf2a2906c13e0c15f2508ff822758bd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (3.0.9)
4
+ cm-admin (3.0.11)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -3,14 +3,16 @@ var currentRequest = null;
3
3
  var CmFilter = {
4
4
  // Generate or remove elements of the dropdown based on the search value.
5
5
  dropdown_search: function(element) {
6
- var filter = element.val().toUpperCase();
7
- var dropdownElements = element.parents(':nth(1)').find('.list-area').children();
8
- for (var i = 0; i < dropdownElements.length; i++) {
9
- var txtValue = $(dropdownElements[i]).children().text();
10
- if (txtValue.toUpperCase().indexOf(filter) > -1) {
11
- $(dropdownElements[i]).css('display', 'flex');
12
- } else {
13
- $(dropdownElements[i]).css('display', 'none');
6
+ if(element.val()) {
7
+ var filter = element.val().toUpperCase();
8
+ var dropdownElements = element.parents(':nth(1)').find('.list-area').children();
9
+ for (var i = 0; i < dropdownElements.length; i++) {
10
+ var txtValue = $(dropdownElements[i]).children().text();
11
+ if (txtValue.toUpperCase().indexOf(filter) > -1) {
12
+ $(dropdownElements[i]).css('display', 'flex');
13
+ } else {
14
+ $(dropdownElements[i]).css('display', 'none');
15
+ }
14
16
  }
15
17
  }
16
18
  }
@@ -63,6 +65,21 @@ var getFilteredData = function(filterType, filterValue, filterColumn=null, sortD
63
65
  var availableParams = searchParams + '&' + filterParams
64
66
  var queryString = getParamsAsObject(availableParams)
65
67
  }
68
+
69
+ if (filterColumn) {
70
+ const filterChip = $(`[data-db-column="${filterColumn}"]`);
71
+ const filterName = filterChip.find('.filter-name');
72
+
73
+ if (isValueEmpty(filterValue)) {
74
+ if (!filterName.data('appended')) {
75
+ filterName.html(`${filterName.text()} is `);
76
+ filterName.data('appended', true);
77
+ }
78
+ } else {
79
+ filterName.html(filterName.text().replace(/\s*is $/, ''));
80
+ filterName.data('appended', false);
81
+ }
82
+ }
66
83
 
67
84
  return currentRequest = $.ajax(url, {
68
85
  type: 'GET',
@@ -100,6 +117,10 @@ var getFilteredData = function(filterType, filterValue, filterColumn=null, sortD
100
117
  });
101
118
  }
102
119
 
120
+ const isValueEmpty = function(value) {
121
+ return value !== undefined && value !== null && value !== '' && (!Array.isArray(value) || value.length !== 0);
122
+ }
123
+
103
124
  $(document).on('change', '[data-behaviour="filter"]', function(e) {
104
125
  var filterType = $(this).data('filter-type')
105
126
  var filterColumn = $(this).data('db-column')
@@ -206,8 +227,6 @@ $(document).on('click', '[data-behaviour="filter-input"]', function(e) {
206
227
 
207
228
  if (filterType == 'range') {
208
229
  filterElement.parent().toggleClass('hidden')
209
- } else if (filterType == 'multi_select') {
210
- $(this).parent().children(':last').toggleClass('hidden')
211
230
  } else if (filterType == 'date') {
212
231
  filterElement.click()
213
232
  }
@@ -219,12 +238,12 @@ $(document).on('click', '.clear-btn', function(e) {
219
238
  })
220
239
 
221
240
  var unhideClearFilterBtn = function(filterValue) {
222
- if (filterValue) {
241
+ if (isValueEmpty(filterValue)) {
223
242
  $('.clear-btn').removeClass('hidden')
224
243
  }
225
244
  }
226
245
 
227
- $(document).on('click', '[data-behaviour="select-option"] .cm-checkbox', function(e) {
246
+ $(document).on('click', '[data-behaviour="select-option"] [data-behaviour="multi-select-filter-checkbox"]', function(e) {
228
247
  $(this).prop('checked', !$(this).prop('checked'));
229
248
  })
230
249
  // Selecting options for single and multi select filters
@@ -255,9 +274,11 @@ $(document).on('click', '[data-behaviour="select-option"]', function(e) {
255
274
  }
256
275
  else if (filterType == 'multi_select') {
257
276
  var parentChip = $(this).parent().siblings(':first')
258
- var checkboxElement = $(this).find('.cm-checkbox')
277
+ var checkboxElement = $(this).find('[data-behaviour="multi-select-filter-checkbox"]')
259
278
  checkboxElement.prop('checked', !checkboxElement.prop('checked'))
260
- var checkedCount = $(this).parent().find('.cm-checkbox').filter(':checked').length
279
+ var checkedCount = $(this).parent().find('[data-behaviour="multi-select-filter-checkbox"]').filter(':checked').length
280
+ var filterValue = []
281
+ var filterValueText = []
261
282
  if (checkboxElement.prop('checked')) {
262
283
  var chip = $('<div class="chip"></div>')
263
284
  var firstSpan = $('<span></span>').text($(this).text())
@@ -272,53 +293,42 @@ $(document).on('click', '[data-behaviour="select-option"]', function(e) {
272
293
  }
273
294
  }
274
295
  }
296
+ $(this).parent().find('[data-behaviour="multi-select-filter-checkbox"]').filter(':checked').each(function() {
297
+ filterValue.push($(this).parent().data('value'))
298
+ filterValueText.push($(this).parent().text())
299
+ })
275
300
 
276
301
  if (checkedCount > 0) {
277
- parentChip.addClass('search-with-chips').removeClass('search-area')
302
+ parentChip.addClass('active')
278
303
  $(this).parents(':nth(1)').children(':last').addClass('active')
279
304
  } else {
280
- parentChip.addClass('search-area').removeClass('search-with-chips')
305
+ parentChip.removeClass('active')
281
306
  $(this).parents(':nth(1)').children(':last').removeClass('active')
282
307
  }
283
- }
284
- });
285
-
286
- // Apply button for multi select filters
287
- $(document).on('click', '.apply-area', function(e) {
288
- var filterInputElement = $(this).parents(':nth(3)').children(':first')
289
- var filterType = filterInputElement.data('filter-type')
290
- var filterColumn = filterInputElement.data('db-column')
291
- var filterValue = []
292
- var filterValueText = []
293
-
294
- var selectFilterElement = $('[data-behaviour="select-option"][data-filter-type=' + filterType + '][data-db-column=' + filterColumn + ']')
295
- var checkedElements = selectFilterElement.find('.cm-checkbox').filter(':checked')
296
-
297
- if (checkedElements.length > 0) {
298
- for(var i = 0; i < checkedElements.length; i++) {
299
- filterValue.push($(checkedElements[i]).parent().data('value'))
300
- filterValueText.push($(checkedElements[i]).parent().text())
301
- }
302
-
308
+ // Truncate filter value logic
303
309
  var truncatedFilterValue = filterValueText[0]
304
310
  if (filterValue.length > 1) {
305
- truncatedFilterValue += ' + ' + (filterValue.length - 1) + ' more'
311
+ truncatedFilterValue += ' + ' + (filterValue.length - 1);
312
+ }
313
+ // Update the filter input element with the truncated value
314
+ var filterInputElement = $(this).parents(':nth(4)').children(':first')
315
+ if (filterValue.length > 0) {
316
+ filterInputElement.children(':nth(1)').text(truncatedFilterValue)
317
+ filterInputElement.children(':last').removeClass('hidden')
318
+ } else {
319
+ filterInputElement.children(':nth(1)').text('')
320
+ filterInputElement.children(':last').addClass('hidden')
306
321
  }
307
-
308
- filterInputElement.children(':nth(1)').text(truncatedFilterValue)
309
- filterInputElement.children(':last').removeClass('hidden')
310
- selectFilterElement.parents(':nth(3)').addClass('hidden')
311
-
312
322
  // Clear the search value post selection and regenerate the dropdown elements.
313
- var searchInputElement = $(this).parent().children(':first').children(':last')
323
+ var searchInputElement = $(this).parents(':nth(1)').children(':first').children(':last')
314
324
  searchInputElement.val('')
315
325
  CmFilter.dropdown_search(searchInputElement)
316
-
317
326
  unhideClearFilterBtn(filterValue)
318
327
  getFilteredData(filterType, filterValue, filterColumn)
319
328
  }
320
329
  });
321
330
 
331
+
322
332
  // Remove single applied filter.
323
333
  $(document).on('click', '.filter-chip-remove', function(e) {
324
334
  var url = window.location.pathname
@@ -338,26 +348,30 @@ $(document).on('click', '.filter-chip-remove', function(e) {
338
348
  });
339
349
 
340
350
  $(document).on('click', '[data-behaviour="selected-chip"]', function(e) {
341
- var filterType = $(this).parents(':nth(5)').find('.filter-chip').data('filter-type')
342
- var filterColumn = $(this).parents(':nth(5)').find('.filter-chip').data('db-column')
343
- var filterValue = $(this).siblings().text()
344
- var selectElement = $('[data-behaviour="select-option"][data-filter-type=' + filterType + '][data-db-column=' + filterColumn + ']')
345
- $(this).parent().remove()
346
-
347
- for(var i = 0; i < selectElement.length; i++) {
348
- if ($(selectElement[i]).data('value') == filterValue) {
349
- var checkboxElement = $(selectElement[i]).find('.cm-checkbox')
350
- checkboxElement.prop('checked', !checkboxElement.prop('checked'))
351
- break
352
- }
351
+ var filterType = $(this).parents(':nth(5)').find('.filter-chip').data('filter-type');
352
+ var filterColumn = $(this).parents(':nth(5)').find('.filter-chip').data('db-column');
353
+ var filterValue = [];
354
+ var filterValueText = $(this).siblings().text();
355
+ var selectElement = $('[data-behaviour="select-option"][data-filter-type=' + filterType + '][data-db-column=' + filterColumn + ']');
356
+ $(this).parent().remove();
357
+ for (var i = 0; i < selectElement.length; i++) {
358
+ if ($(selectElement[i]).text() == filterValueText) {
359
+ var checkboxElement = $(selectElement[i]).find('[data-behaviour="multi-select-filter-checkbox"]');
360
+ checkboxElement.prop('checked', false); // Uncheck the box
361
+ break;
362
+ }
353
363
  }
354
-
355
- var checkedCount = $(selectElement).find('.cm-checkbox').filter(':checked').length
364
+ selectElement.find('[data-behaviour="multi-select-filter-checkbox"]').filter(':checked').each(function() {
365
+ filterValue.push($(this).parent().data('value'));
366
+ });
367
+ var checkedCount = selectElement.find('[data-behaviour="multi-select-filter-checkbox"]').filter(':checked').length;
356
368
  if (checkedCount < 1) {
357
- $(selectElement).parent().siblings(':first').addClass('search-area').removeClass('search-with-chips')
358
- $(selectElement).parent().siblings(':last').removeClass('active')
369
+ selectElement.parent().siblings(':first').removeClass('active');
370
+ selectElement.parent().siblings(':last').removeClass('active');
359
371
  }
360
- })
372
+ unhideClearFilterBtn(filterValue);
373
+ getFilteredData(filterType, filterValue, filterColumn);
374
+ });
361
375
 
362
376
  $(document).on("change", '[data-behaviour="sort-column"], [data-behaviour="sort-direction"]', function (e) {
363
377
  getFilteredData(null, null, null, true);
@@ -381,3 +395,71 @@ $(document).on("click", '[data-behaviour="reset-sort"]', function (e) {
381
395
  }
382
396
  });
383
397
  });
398
+
399
+ $(document).on(
400
+ "click",
401
+ '[data-behaviour="multi-select-filter-apply"]',
402
+ function (e) {
403
+ $(this).parent();
404
+ $(this).closest('[data-behaviour="multi-select-filter-dropdown"]').removeClass('show');
405
+ $(this).closest('[data-behaviour="multi-select-filter-wrapper"]').find('[data-behaviour="filter-input"]').removeClass('show');
406
+ }
407
+ );
408
+
409
+ $(document).on(
410
+ "click",
411
+ '[data-behaviour="multi-select-filter-clear"]',
412
+ function (e) {
413
+ const dropdown = $(this).closest('[data-behaviour="multi-select-filter-dropdown"]');
414
+
415
+ const filterInputElement = $(this).parents(':nth(4)').children(':first')
416
+ filterInputElement.children(':nth(1)').text('')
417
+
418
+ const checkboxes = dropdown.find('[data-behaviour="multi-select-filter-checkbox"]:checked');
419
+ checkboxes.each(function() {
420
+ this.checked = false;
421
+ });
422
+
423
+ const chips = dropdown.find('.chip');
424
+ chips.each(function() {
425
+ $(this).remove();
426
+ });
427
+
428
+ const chipsArea = dropdown.find('[data-behaviour="multi-select-filter-chips-area"]');
429
+ chipsArea.removeClass('active');
430
+
431
+ const filter_element = dropdown.prev();
432
+ const db_column = filter_element.attr('data-db-column');
433
+ getFilteredData(filter_element.attr('data-filter-type'), [], db_column);
434
+ }
435
+ );
436
+
437
+ const initializeFilterLabels = function(filterParams) {
438
+ Object.keys(filterParams).forEach(filterType => {
439
+ const filterObj = filterParams[filterType];
440
+ Object.keys(filterObj).forEach(filterColumn => {
441
+ const filterChip = $(`[data-db-column="${filterColumn}"]`);
442
+ const filterName = filterChip.find('.filter-name');
443
+
444
+ // Append "is" to indicate active filter
445
+ if (filterName.length && !filterName.text().endsWith('is')) {
446
+ filterName.html(`${filterName.text()} is `);
447
+ filterName.data('appended', true);
448
+ }
449
+ });
450
+ });
451
+ };
452
+
453
+ $(document).ready(function() {
454
+ const initialFilterParams = getParamsAsObject(window.location.search);
455
+ initializeFilterLabels(initialFilterParams.filters || {});
456
+ });
457
+
458
+ $(document).ready(function() {
459
+ const chipsAreas = document.querySelectorAll('[data-behaviour="multi-select-filter-chips-area"]');
460
+ chipsAreas.forEach(function(chipsArea) {
461
+ chipsArea.classList.add('active');
462
+ });
463
+ });
464
+
465
+
@@ -4,6 +4,7 @@
4
4
  z-index: 1;
5
5
  &__inner {
6
6
  @include flex(row, flex-start, center, wrap);
7
+ gap: 8px;
7
8
  .filter-chips-wrapper {
8
9
  .filter-chip {
9
10
  margin-left: 16px;
@@ -76,7 +77,8 @@
76
77
  &:focus {
77
78
  border-color: $brand-color !important;
78
79
  outline: 0 !important;
79
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
80
+ box-shadow:
81
+ inset 0 1px 1px rgba(0, 0, 0, 0.075),
80
82
  0 0 8px rgba(102, 175, 233, 0.6) !important;
81
83
  }
82
84
  }
@@ -94,7 +96,8 @@
94
96
  &:focus {
95
97
  border-color: $brand-color;
96
98
  outline: 0;
97
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
99
+ box-shadow:
100
+ inset 0 1px 1px rgba(0, 0, 0, 0.075),
98
101
  0 0 8px rgba(102, 175, 233, 0.6);
99
102
  }
100
103
  .select2-selection__rendered {
@@ -61,18 +61,18 @@
61
61
  }
62
62
 
63
63
  //upload attachment style
64
- [data-section="destroy-attachment"] {
65
- margin-top: 4px;
66
- }
67
64
  [data-section="image-preview"] {
68
65
  [data-section="destroy-attachment"] {
69
66
  background-color: $grey-lightest-clr;
70
67
  mix-blend-mode: multiply;
71
68
  padding: 8px;
72
69
  margin-bottom: 5px;
73
- .btn-ghost {
74
- float: right;
75
- margin-top: 12px;
70
+ display: flex;
71
+ justify-content: space-between;
72
+ align-items: center;
73
+ .btn-link {
74
+ width: 125px;
75
+ justify-content: start !important;
76
76
  }
77
77
  }
78
78
  }
@@ -2,48 +2,34 @@
2
2
 
3
3
  .dropdown-popup {
4
4
  border: none !important;
5
- .popup-base {
6
- position: absolute;
7
- min-width: 256px;
8
- height: 56px;
9
- padding: 8px;
10
- background: $white;
11
- border: 1px solid $grey-lighter-clr;
12
- box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.16);
13
- border-radius: $radius-4;
14
- }
5
+
15
6
  .popup-inner {
16
7
  position: relative;
17
8
  min-width: 240px;
18
9
  margin: 0 auto;
19
10
  background-color: $white;
20
- border: 1px solid #e0e0e0;
11
+ border: 1px solid $dropdown-border-clr;
21
12
  box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.16);
22
13
  border-radius: $radius-4;
14
+
23
15
  .search-area {
24
16
  input {
25
- width: 100%;
26
- min-height: 40px;
27
- padding: 9px 16px;
28
- font-size: $t4-text;
17
+ @extend .form-control;
29
18
  border: none;
30
- border-radius: 4px 4px 0 0;
31
19
  &::placeholder {
32
- color: $ink-lightest-clr;
33
- }
34
- &:focus {
35
- outline: none;
36
- border: 1px solid $brand-color;
20
+ font-size: $t4-text;
37
21
  }
38
22
  }
39
23
  }
40
- .search-with-chips {
41
- display: flex;
42
- flex-wrap: wrap;
43
- padding: 8px 16px;
24
+
25
+ .chips-area {
26
+ @include flex($wrap: wrap);
27
+ &.active {
28
+ padding: 8px 16px;
29
+ border-bottom: 1px solid $dropdown-border-clr;
30
+ }
44
31
  .chip {
45
- display: inline-flex;
46
- align-items: center;
32
+ @extend .d-inline-flex, .align-items-center;
47
33
  margin: 2px;
48
34
  padding: 0 4px;
49
35
  background: $grey-lighter-clr;
@@ -54,26 +40,18 @@
54
40
  }
55
41
  span:nth-child(2) {
56
42
  @include font($size: 10px, $color: $ink-lightest-clr);
57
- margin-left: 4px;
43
+ margin: 4px 0 0 4px;
58
44
  cursor: pointer;
59
45
  }
60
46
  }
61
- input {
62
- border: none;
63
- font-size: $t4-text;
64
- margin: 2px;
65
- &:focus {
66
- outline: 3px auto rgba(47, 128, 237, 0.3);
67
- }
68
- }
69
47
  }
48
+
70
49
  .list-area {
71
50
  max-height: 240px;
72
51
  overflow-y: auto;
73
- border-top: 1px solid #e0e0e0;
52
+ border-top: 1px solid $dropdown-border-clr;
74
53
  .list-item {
75
- display: flex;
76
- align-items: center;
54
+ @include flex($align: center);
77
55
  padding: 9px 16px;
78
56
  @include font($size: $t4-text, $color: $primary-text-clr);
79
57
  line-height: 22px;
@@ -88,65 +66,16 @@
88
66
  }
89
67
  }
90
68
  .selected {
91
- color: $brand-color;
92
- }
93
- }
94
- .apply-area {
95
- @include font($size: $t4-text, $color: $ink-lightest-clr, $weight: 600);
96
- line-height: 22px;
97
- text-align: center;
98
- padding: 9px 16px;
99
- box-shadow: inset 0px 1px 0px rgba(148, 151, 155, 0.15);
100
- cursor: not-allowed;
101
- &.active {
102
- cursor: pointer;
103
69
  color: $blue-regular-clr;
104
70
  }
105
71
  }
106
- }
107
- }
108
-
109
- .applied-select {
110
- margin-left: 20rem;
111
- }
112
72
 
113
- .column-popup {
114
- display: inline-block;
115
- min-width: 156px;
116
- max-height: 295px;
117
- background-color: $white;
118
- filter: drop-shadow(0px 4px 16px rgba(0, 0, 0, 0.16));
119
- border-radius: $radius-4;
120
- z-index: 1;
121
- .column-option {
122
- .option-title {
123
- @include font($size: $t6-text, $color: $ink-lightest-clr, $weight: 600);
124
- line-height: 16px;
125
- text-transform: uppercase;
126
- margin: 0;
127
- padding: 18px 16px 9px;
128
- }
129
- .option-action {
130
- padding: 9px 16px;
131
- cursor: pointer;
132
- @include transition-linear;
133
- &:hover {
134
- background-color: $grey-lighter-clr;
135
- }
136
- .action-icon {
137
- font-size: $t4-text;
138
- }
139
- .action-name {
140
- @include font($size: $t4-text, $color: $primary-text-clr);
141
- line-height: 22px;
142
- margin-left: 8px;
143
- }
144
- }
145
- .cannot-sort {
146
- @include font($size: $t6-text, $color: $ink-lightest-clr);
147
- line-height: 16px;
148
- margin-bottom: 9px;
149
- padding: 0 16px;
73
+ .popup-footer {
74
+ display: grid;
75
+ grid-template-columns: 50px 1fr;
76
+ grid-gap: 8px;
77
+ padding: 8px 16px;
78
+ background-color: $grey-lightest-clr;
150
79
  }
151
80
  }
152
81
  }
@@ -43,7 +43,8 @@
43
43
  .filter-chip {
44
44
  display: inline-block;
45
45
  position: relative;
46
- padding: 5px 16px;
46
+ height: 32px;
47
+ padding: 4px 16px;
47
48
  font-size: $t4-text;
48
49
  font-weight: 600;
49
50
  line-height: 22px;
@@ -38,6 +38,7 @@ $grey-lighter-clr: #f3f4f6;
38
38
  $grey-lightest-clr: #f8f9fa;
39
39
  $grey-dark-clr: #828282;
40
40
  $card-grey-lighter-clr: #f3f4f6;
41
+ $dropdown-border-clr: #e0e0e0;
41
42
 
42
43
  /* Ink Colors */
43
44
  $ink-regular-clr: #1d2129;
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '3.0.9'
2
+ VERSION = '3.0.11'
3
3
  end
@@ -27,7 +27,7 @@ module CmAdmin
27
27
  concat(content_tag(:div, class: 'popup-base') do
28
28
  concat(content_tag(:div, class: 'popup-inner') do
29
29
  concat(content_tag(:div, class: 'search-area') do
30
- concat tag.input placeholder: 'Search for filter', data: { behaviour: 'dropdown-filter-search' }
30
+ concat tag.input placeholder: 'Search', data: { behaviour: 'dropdown-filter-search' }
31
31
  end)
32
32
  concat(content_tag(:div, class: 'list-area') do
33
33
  filters.each do |filter|
@@ -67,14 +67,14 @@ module CmAdmin
67
67
 
68
68
  def filter_chip(value, filter)
69
69
  data_hash = { behaviour: 'filter-input', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}" }
70
- data_hash.merge!(bs_toggle: 'dropdown') if filter.filter_type.to_s.eql?('single_select')
70
+ data_hash.merge!(bs_toggle: 'dropdown', bs_auto_close: 'outside') if ['single_select', 'multi_select'].include?(filter.filter_type.to_s)
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 value.size > 1
74
+ truncated_value += " + #{value.size - 1}" if value.size > 1
75
75
  end
76
76
  concat(content_tag(:div, class: "filter-chip #{filter.filter_type.to_s.eql?('single_select') ? 'dropdown' : ''}", data: data_hash) do
77
- concat tag.span "#{filter.display_name} is "
77
+ concat tag.span "#{filter.display_name} ", class: 'filter-name'
78
78
  concat tag.span "#{filter.filter_type.to_s.eql?('multi_select') ? truncated_value : value}"
79
79
  concat(content_tag(:div, class: "filter-chip-remove #{value ? '' : 'hidden'}") do
80
80
  tag.i class: 'fa fa-times bolder'
@@ -84,7 +84,7 @@ module CmAdmin
84
84
  end
85
85
 
86
86
  def add_search_filter(filter)
87
- tag.div class: 'filter-search me-3' do
87
+ tag.div class: 'filter-search' do
88
88
  concat(content_tag(:div, class: 'input-group input-group-sm') do
89
89
  concat(content_tag(:span, class: 'input-group-text') do
90
90
  tag.i class: 'fa fa-search'
@@ -97,7 +97,7 @@ module CmAdmin
97
97
  def add_range_filter(filter)
98
98
  value = params.dig(:filters, :range, :"#{filter.db_column_name}")
99
99
  is_active = value || filter.active_by_default
100
- concat(content_tag(:div, class: "position-relative me-3 #{is_active ? '' : 'hidden'}") do
100
+ concat(content_tag(:div, class: "position-relative #{is_active ? '' : 'hidden'}") do
101
101
  concat filter_chip(value, filter)
102
102
 
103
103
  concat(content_tag(:div, class: 'position-absolute mt-2 range-container hidden') do
@@ -111,7 +111,7 @@ module CmAdmin
111
111
  def add_date_filter(filter)
112
112
  value = params.dig(:filters, :date, :"#{filter.db_column_name}")
113
113
  is_active = value || filter.active_by_default
114
- concat(content_tag(:div, class: "position-relative me-3 #{is_active ? '' : 'hidden'}") do
114
+ concat(content_tag(:div, class: "position-relative #{is_active ? '' : 'hidden'}") do
115
115
  concat filter_chip(value, filter)
116
116
 
117
117
  concat(content_tag(:div, class: 'date-filter-wrapper w-100') do
@@ -131,7 +131,7 @@ module CmAdmin
131
131
  else
132
132
  []
133
133
  end
134
- concat(content_tag(:div, class: "position-relative me-3 #{is_active ? '' : 'hidden'}") do
134
+ concat(content_tag(:div, class: "position-relative #{is_active ? '' : 'hidden'}") do
135
135
  selected_value_text = if value && select_options[0].class == Array
136
136
  select_options.map { |collection| collection[0] if collection[1].to_s.eql?(value) }.compact.join(', ')
137
137
  else
@@ -143,7 +143,7 @@ module CmAdmin
143
143
  concat(content_tag(:div, class: 'popup-base') do
144
144
  concat(content_tag(:div, class: 'popup-inner') do
145
145
  concat(content_tag(:div, class: 'search-area') do
146
- concat tag.input placeholder: "#{filter.placeholder}", data: { behaviour: 'dropdown-filter-search' }
146
+ concat tag.input placeholder: "Search", data: { behaviour: 'dropdown-filter-search' }
147
147
  end)
148
148
  concat(content_tag(:div, class: 'list-area') do
149
149
  select_options.each do |val|
@@ -184,13 +184,13 @@ module CmAdmin
184
184
  value_mapped_text = value
185
185
  end
186
186
 
187
- concat(content_tag(:div, class: "position-relative me-3 #{is_active ? '' : 'hidden'}") do
187
+ concat(content_tag(:div, class: "position-relative #{is_active ? '' : 'hidden'}", data: { behaviour: 'multi-select-filter-wrapper' }) do
188
188
  concat filter_chip(value_mapped_text, filter)
189
189
 
190
- concat(content_tag(:div, class: 'position-absolute mt-2 dropdown-popup hidden') do
190
+ concat(content_tag(:div, class: 'dropdown-menu dropdown-popup', data: { behaviour: 'multi-select-filter-dropdown' }) do
191
191
  concat(content_tag(:div, class: 'popup-base') do
192
192
  concat(content_tag(:div, class: 'popup-inner') do
193
- concat(content_tag(:div, class: "#{value ? 'search-with-chips' : 'search-area'}") do
193
+ concat(content_tag(:div, class: 'chips-area', data: { behaviour: 'multi-select-filter-chips-area' }) do
194
194
  if value_mapped_text
195
195
  value_mapped_text.each do |val|
196
196
  concat(content_tag(:div, class: 'chip') do
@@ -201,7 +201,9 @@ module CmAdmin
201
201
  end)
202
202
  end
203
203
  end
204
- concat tag.input placeholder: "#{filter.placeholder}", data: { behaviour: 'dropdown-filter-search' }
204
+ end)
205
+ concat(content_tag(:div, class: 'search-area') do
206
+ concat tag.input placeholder: "Search", data: { behaviour: 'dropdown-filter-search' }
205
207
  end)
206
208
  concat(content_tag(:div, class: 'list-area') do
207
209
  select_options.each do |val|
@@ -211,13 +213,16 @@ module CmAdmin
211
213
  elsif val.class.eql?(String)
212
214
  filter_value = filter_text = val
213
215
  end
214
- 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
215
- concat tag.input class: 'cm-checkbox', type: 'checkbox', checked: value ? value.include?(filter_value.to_s) : false
216
- concat tag.label filter_text.to_s.titleize, class: 'pointer'
216
+ concat(content_tag(:div, class: "list-item pointer", data: { behaviour: 'select-option', filter_type: "#{filter.filter_type}", db_column: "#{filter.db_column_name}", value: filter_value }) do
217
+ concat tag.input class: 'form-check-input m-0 pointer', type: 'checkbox', checked: value ? value.include?(filter_value.to_s) : false, data: { behaviour: 'multi-select-filter-checkbox', value: filter_value }
218
+ concat tag.label filter_text.to_s.titleize, class: 'form-check-label pointer'
217
219
  end)
218
220
  end
219
221
  end)
220
- concat tag.div 'Apply', class: "apply-area #{value ? 'active' : ''}"
222
+ concat(content_tag(:div, class: 'popup-footer') do
223
+ concat tag.button 'Clear', class: 'btn-ghost', data: { behaviour: 'multi-select-filter-clear' }
224
+ concat tag.button 'Apply', class: 'btn-primary', data: { behaviour: 'multi-select-filter-apply' }
225
+ end)
221
226
  end)
222
227
  end)
223
228
  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: 3.0.9
4
+ version: 3.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael