cm-admin 0.3.0 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +25 -24
- data/README.md +5 -3
- data/app/assets/stylesheets/cm_admin/base/auth.scss +0 -12
- data/app/assets/stylesheets/cm_admin/base/common.scss +1 -1
- data/app/assets/stylesheets/cm_admin/base/filters.scss +8 -7
- data/app/assets/stylesheets/cm_admin/base/form.scss +7 -73
- data/app/assets/stylesheets/cm_admin/base/navbar.scss +1 -3
- data/app/assets/stylesheets/cm_admin/base/quicksearch.scss +7 -0
- data/app/assets/stylesheets/cm_admin/base/scaffold.scss +39 -2
- data/app/assets/stylesheets/cm_admin/base/show.scss +24 -2
- data/app/assets/stylesheets/cm_admin/base/table.scss +270 -253
- data/app/assets/stylesheets/cm_admin/cm_admin.css.scss +1 -0
- data/app/assets/stylesheets/cm_admin/components/_dropdown-popup.scss +22 -10
- data/app/assets/stylesheets/cm_admin/components/_range.scss +13 -2
- data/app/assets/stylesheets/cm_admin/components/_status-tag.scss +7 -6
- data/app/assets/stylesheets/cm_admin/helpers/_variable.scss +1 -0
- data/app/assets/stylesheets/cm_admin/scaffold.scss +14 -0
- data/app/controllers/cm_admin/application_controller.rb +5 -0
- data/app/controllers/cm_admin/exports_controller.rb +1 -1
- data/app/controllers/cm_admin/static_controller.rb +12 -0
- data/app/helpers/cm_admin/custom_helper.rb +4 -0
- data/app/javascript/packs/cm_admin/application.js +15 -1
- data/app/javascript/packs/cm_admin/filters.js +331 -16
- data/app/javascript/packs/cm_admin/quick_search.js +67 -0
- data/app/javascript/packs/cm_admin/scaffolds.js +30 -1
- data/app/javascript/stylesheets/cm_admin/application.scss +4 -0
- data/app/views/cm_admin/main/_associated_table.html.slim +60 -0
- data/app/views/cm_admin/main/_cm_pagy_nav.html.slim +6 -6
- data/app/views/cm_admin/main/_filters.html.slim +1 -10
- data/app/views/cm_admin/main/_nested_fields.html.slim +7 -0
- data/app/views/cm_admin/main/_nested_table_form.html.slim +6 -0
- data/app/views/cm_admin/main/_table.html.slim +9 -20
- data/app/views/cm_admin/main/_tabs.html.slim +5 -0
- data/app/views/cm_admin/main/_top_navbar.html.slim +12 -6
- data/app/views/cm_admin/main/associated_index.html.slim +6 -0
- data/app/views/cm_admin/main/associated_show.html.slim +6 -0
- data/app/views/cm_admin/main/edit.html.slim +10 -7
- data/app/views/cm_admin/main/index.html.slim +11 -8
- data/app/views/cm_admin/main/show.html.slim +12 -13
- data/app/views/cm_admin/static/error_401.html.slim +4 -0
- data/app/views/layouts/_flash_message.html.slim +9 -0
- data/app/views/layouts/_left_sidebar_nav.html.slim +7 -3
- data/app/views/layouts/_quick_links.html.slim +25 -0
- data/app/views/layouts/cm_admin.html.slim +25 -1
- data/app/views/layouts/static.html.slim +18 -0
- data/bin/console +0 -1
- data/cm_admin.gemspec +2 -1
- data/config/routes.rb +2 -1
- data/config/webpack/environment.js +3 -2
- data/lib/.DS_Store +0 -0
- data/lib/cm_admin/constants.rb +3 -0
- data/lib/cm_admin/model.rb +66 -167
- data/lib/cm_admin/models/action.rb +18 -2
- data/lib/cm_admin/models/cm_show_section.rb +20 -0
- data/lib/cm_admin/models/column.rb +49 -4
- data/lib/cm_admin/models/controller_method.rb +76 -0
- data/lib/cm_admin/models/custom_action.rb +13 -0
- data/lib/cm_admin/models/dsl_method.rb +122 -0
- data/lib/cm_admin/models/export.rb +16 -5
- data/lib/cm_admin/models/field.rb +2 -1
- data/lib/cm_admin/models/filter.rb +67 -2
- data/lib/cm_admin/models/form_field.rb +21 -0
- data/lib/cm_admin/models/tab.rb +13 -0
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/column_field_helper.rb +29 -0
- data/lib/cm_admin/view_helpers/field_display_helper.rb +71 -0
- data/lib/cm_admin/view_helpers/filter_helper.rb +190 -0
- data/lib/cm_admin/view_helpers/form_field_helper.rb +21 -4
- data/lib/cm_admin/view_helpers/form_helper.rb +22 -12
- data/lib/cm_admin/view_helpers/manage_column_popup_helper.rb +75 -0
- data/lib/cm_admin/view_helpers/navigation_helper.rb +22 -6
- data/lib/cm_admin/view_helpers/page_info_helper.rb +36 -0
- data/lib/cm_admin/view_helpers.rb +3 -1
- data/lib/cm_admin.rb +3 -1
- data/lib/generators/cm_admin/install_generator.rb +20 -8
- data/package.json +7 -1
- data/tmp/cache/webpacker/last-compilation-digest-development +1 -0
- data/yarn.lock +52 -17
- metadata +46 -9
- data/app/controllers/cm_admin/main_controller.rb +0 -8
- data/lib/c.png +0 -0
- data/lib/cm_admin/view_helpers/field_column_helper.rb +0 -23
- data/lib/generators/cm_admin/templates/cm_admin_initializer.rb +0 -4
- data/yarn-error.log +0 -44
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
.range-container {
|
4
4
|
display: flex;
|
5
|
-
width:
|
5
|
+
width: 424px;
|
6
6
|
height: 54px;
|
7
7
|
padding: 8px;
|
8
8
|
background: $white;
|
@@ -10,11 +10,22 @@
|
|
10
10
|
box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.16);
|
11
11
|
border-radius: $radius-4;
|
12
12
|
.range-item {
|
13
|
+
width: 200px;
|
14
|
+
border: 1px solid $grey-light-clr;
|
15
|
+
border-radius: $radius-4;
|
16
|
+
padding: 8px 0 8px 16px;
|
13
17
|
&:nth-child(1) {
|
14
18
|
margin-right: 4px;
|
15
19
|
}
|
16
20
|
&:nth-child(2) {
|
17
21
|
margin-left: 4px;
|
18
22
|
}
|
23
|
+
&:hover {
|
24
|
+
border: 1px solid $grey-dark-clr;
|
25
|
+
}
|
26
|
+
&:focus {
|
27
|
+
outline: none;
|
28
|
+
border: 1px solid $brand-color;
|
29
|
+
}
|
19
30
|
}
|
20
|
-
}
|
31
|
+
}
|
@@ -4,23 +4,23 @@
|
|
4
4
|
font-size: $t4-text;
|
5
5
|
line-height: 22px;
|
6
6
|
padding: 4px;
|
7
|
-
&.default-
|
7
|
+
&.default-0 {
|
8
8
|
color: $primary-text-clr;
|
9
9
|
background: $grey-lighter-clr;
|
10
10
|
}
|
11
|
-
&.
|
11
|
+
&.default-1 {
|
12
12
|
color: $green-regular-clr;
|
13
13
|
background: $green-lightest-clr;
|
14
14
|
}
|
15
|
-
&.
|
15
|
+
&.default-2 {
|
16
16
|
color: $yellow-regular-clr;
|
17
17
|
background: $yellow-lightest-clr;
|
18
18
|
}
|
19
|
-
&.
|
19
|
+
&.default-3 {
|
20
20
|
color: $red-regular-clr;
|
21
21
|
background: $red-lightest-clr;
|
22
22
|
}
|
23
|
-
&.
|
23
|
+
&.default-4 {
|
24
24
|
color: $blue-regular-clr;
|
25
25
|
background: $blue-lightest-clr;
|
26
26
|
}
|
@@ -37,6 +37,7 @@
|
|
37
37
|
border-radius: $radius-4;
|
38
38
|
@include transition-linear;
|
39
39
|
cursor: pointer;
|
40
|
+
user-select: none;
|
40
41
|
&:hover {
|
41
42
|
background-color: #F3F4F6;
|
42
43
|
.filter-chip-remove {
|
@@ -64,4 +65,4 @@
|
|
64
65
|
color: $ink-lighter-clr;
|
65
66
|
}
|
66
67
|
}
|
67
|
-
}
|
68
|
+
}
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module CmAdmin
|
2
2
|
class ApplicationController < ::ActionController::Base
|
3
|
+
# before_action :check_cm_admin
|
3
4
|
layout 'cm_admin'
|
4
5
|
helper CmAdmin::ViewHelpers
|
6
|
+
|
7
|
+
def check_cm_admin
|
8
|
+
redirect_to CmAdmin::Engine.mount_path + '/access-denied' unless defined?(::Current) && ::Current.cm_admin_user
|
9
|
+
end
|
5
10
|
end
|
6
11
|
end
|
@@ -8,7 +8,7 @@ module CmAdmin
|
|
8
8
|
class ExportsController < ApplicationController
|
9
9
|
|
10
10
|
def export
|
11
|
-
file_path = CmAdmin::Models::Export.generate_excel(params[:class_name], params[:columns])
|
11
|
+
file_path = CmAdmin::Models::Export.generate_excel(params[:class_name], params[:columns], helpers)
|
12
12
|
send_file file_path, disposition: 'attachment'
|
13
13
|
end
|
14
14
|
|
@@ -1,9 +1,23 @@
|
|
1
1
|
require("@rails/ujs").start()
|
2
2
|
require("turbolinks").start()
|
3
3
|
require("@rails/activestorage").start()
|
4
|
+
require("stylesheets/cm_admin/application")
|
4
5
|
require("jquery")
|
6
|
+
require("moment")
|
7
|
+
require("bootstrap")
|
8
|
+
require('flatpickr')
|
9
|
+
require("jgrowl")
|
5
10
|
require('./scaffolds.js')
|
11
|
+
require('./quick_search.js')
|
6
12
|
require('./filters.js')
|
7
13
|
|
14
|
+
import jQuery from 'jquery'
|
15
|
+
window.$ = jQuery
|
16
|
+
window.jQuery = jQuery
|
17
|
+
|
18
|
+
require("@nathanvda/cocoon")
|
8
19
|
import "@fortawesome/fontawesome-free/css/all"
|
9
|
-
import "
|
20
|
+
import "daterangepicker"
|
21
|
+
|
22
|
+
|
23
|
+
|
@@ -1,27 +1,58 @@
|
|
1
|
-
var
|
1
|
+
var currentRequest = null;
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
// Main method which will structure the existing filter values with the newly
|
4
|
+
// applied filter. Send and receive the value from the backend.
|
5
|
+
var getFilteredData = function(filterType, filterValue, filterColumn=null) {
|
5
6
|
var url = window.location.pathname
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
|
8
|
+
// Based on the value changed for recent filter generate the filterParams hash
|
9
|
+
var filterParams = {};
|
10
|
+
if (filterColumn) {
|
11
|
+
filterParams[filterType] = {};
|
12
|
+
filterParams[filterType][filterColumn] = filterValue
|
13
|
+
} else {
|
14
|
+
filterParams[filterType] = filterValue
|
15
|
+
}
|
16
|
+
|
17
|
+
// TODO add sort params in the queryString
|
18
|
+
// page params is reinitialized to 1 when any new filter value is applied so
|
19
|
+
// that it won't throw the error when the user doesn't have sufficent data
|
20
|
+
// to display on the table.
|
21
|
+
var queryString = {
|
22
|
+
filters: filterParams,
|
23
|
+
page: 1
|
14
24
|
};
|
15
|
-
|
25
|
+
|
26
|
+
// Generate the queryString by concatenating the filterParams and
|
27
|
+
// searchParams that are already applied, if searchParams are present.
|
28
|
+
var searchParams = window.location.search
|
29
|
+
if (searchParams.length > 0) {
|
30
|
+
// Delete the previous applied value for multi_select filter from the
|
31
|
+
// searchParams as altering the array with new and old value will create
|
32
|
+
// more complicated logic. The new value is passed and structured in
|
33
|
+
// filterParams and will be concadinated with the searchParams post deletion
|
34
|
+
if (filterType == 'multi_select') {
|
35
|
+
searchParams = getParamsAsObject(searchParams)
|
36
|
+
if (searchParams['filters'][filterType] != undefined) {
|
37
|
+
delete(searchParams['filters'][filterType][filterColumn])
|
38
|
+
}
|
39
|
+
searchParams = jQuery.param(searchParams)
|
40
|
+
}
|
41
|
+
filterParams = jQuery.param(queryString)
|
42
|
+
var availableParams = searchParams + '&' + filterParams
|
43
|
+
queryString = getParamsAsObject(availableParams)
|
44
|
+
}
|
45
|
+
|
46
|
+
return currentRequest = $.ajax(url, {
|
16
47
|
type: 'GET',
|
17
|
-
data:
|
48
|
+
data: queryString,
|
18
49
|
beforeSend: function() {
|
19
|
-
if (
|
20
|
-
|
50
|
+
if (currentRequest !== null) {
|
51
|
+
currentRequest.abort();
|
21
52
|
}
|
22
53
|
},
|
23
54
|
success: function(data) {
|
24
|
-
var queryParam = jQuery.param(
|
55
|
+
var queryParam = jQuery.param(queryString)
|
25
56
|
window.history.pushState("", "", url + '?' + queryParam);
|
26
57
|
$('.index-page__table-container').html(data);
|
27
58
|
},
|
@@ -29,4 +60,288 @@ $(document).on('keyup', '.search-input', function(e) {
|
|
29
60
|
console.log(errorThrown, textStatus);
|
30
61
|
}
|
31
62
|
});
|
63
|
+
}
|
64
|
+
|
65
|
+
$(document).on('change', '[data-behaviour="filter"]', function(e) {
|
66
|
+
var filterType = $(this).data('filter-type')
|
67
|
+
var filterColumn = $(this).data('db-column')
|
68
|
+
|
69
|
+
if (filterType == 'range') {
|
70
|
+
var rangeElements = $(this).parent().children()
|
71
|
+
var filterValue = $(rangeElements[0]).val() + ' to ' + $(rangeElements[1]).val()
|
72
|
+
} else {
|
73
|
+
var filterValue = $(this).val()
|
74
|
+
}
|
75
|
+
|
76
|
+
$(this).parents(':nth(1)').children(':first').children(':nth(1)').text(filterValue)
|
77
|
+
$(this).parents(':nth(1)').children(':first').children(':last').removeClass('hidden')
|
78
|
+
|
79
|
+
unhideClearFilterBtn(filterValue)
|
80
|
+
getFilteredData(filterType, filterValue, filterColumn)
|
81
|
+
});
|
82
|
+
|
83
|
+
$(document).on('keyup', '[data-behaviour="input-search"]', function(e) {
|
84
|
+
e.stopPropagation();
|
85
|
+
|
86
|
+
var searchValue = $(this).val();
|
87
|
+
unhideClearFilterBtn(searchValue)
|
88
|
+
getFilteredData('search', searchValue)
|
89
|
+
});
|
90
|
+
|
91
|
+
$(document).on('click', '[data-behaviour="filter-option"]', function(e) {
|
92
|
+
var filterType = $(this).data('filter-type')
|
93
|
+
var filterColumn = $(this).data('db-column')
|
94
|
+
|
95
|
+
// Clear the search value post selection and regenerate the dropdown elements.
|
96
|
+
var searchInputElement = $(this).parents(':nth(1)').children(':first').children()
|
97
|
+
searchInputElement.val('')
|
98
|
+
CmFilter.dropdown_search(searchInputElement)
|
99
|
+
|
100
|
+
unhideFilter(filterType, filterColumn)
|
101
|
+
});
|
102
|
+
|
103
|
+
var unhideFilter = function(filterType, filterColumn) {
|
104
|
+
var filterInputElement = $('[data-behaviour="filter-input"][data-filter-type=' + filterType + '][data-db-column='+ filterColumn + ']')
|
105
|
+
|
106
|
+
filterInputElement.parent().removeClass('hidden');
|
107
|
+
filterInputElement.click()
|
108
|
+
};
|
109
|
+
|
110
|
+
// Search inside the dropdowns
|
111
|
+
$(document).on('keyup', '[data-behaviour="dropdown-filter-search"]', function(e) {
|
112
|
+
CmFilter.dropdown_search($(this))
|
113
|
+
});
|
114
|
+
|
115
|
+
// Method to decode the encoded nested and/or complex hash and convert it to
|
116
|
+
// object that is used for filters while sending the data to the backend.
|
117
|
+
var getParamsAsObject = function (query) {
|
118
|
+
query = query.substring(query.indexOf('?') + 1);
|
119
|
+
|
120
|
+
var re = /([^&=]+)=?([^&]*)/g;
|
121
|
+
var decodeRE = /\+/g;
|
122
|
+
|
123
|
+
var decode = function (str) {
|
124
|
+
return decodeURIComponent(str.replace(decodeRE, " "));
|
125
|
+
};
|
126
|
+
|
127
|
+
var params = {}, e;
|
128
|
+
while (e = re.exec(query)) {
|
129
|
+
var k = decode(e[1]), v = decode(e[2]);
|
130
|
+
if (k.substring(k.length - 2) === '[]') {
|
131
|
+
k = k.substring(0, k.length - 2);
|
132
|
+
(params[k] || (params[k] = [])).push(v);
|
133
|
+
}
|
134
|
+
else params[k] = v;
|
135
|
+
}
|
136
|
+
|
137
|
+
var assign = function (obj, keyPath, value) {
|
138
|
+
var lastKeyIndex = keyPath.length - 1;
|
139
|
+
for (var i = 0; i < lastKeyIndex; ++i) {
|
140
|
+
var key = keyPath[i];
|
141
|
+
if (!(key in obj))
|
142
|
+
obj[key] = {}
|
143
|
+
obj = obj[key];
|
144
|
+
}
|
145
|
+
obj[keyPath[lastKeyIndex]] = value;
|
146
|
+
}
|
147
|
+
|
148
|
+
for (var prop in params) {
|
149
|
+
var structure = prop.split('[');
|
150
|
+
if (structure.length > 1) {
|
151
|
+
var levels = [];
|
152
|
+
structure.forEach(function (item, i) {
|
153
|
+
var key = item.replace(/[?[\]\\ ]/g, '');
|
154
|
+
levels.push(key);
|
155
|
+
});
|
156
|
+
assign(params, levels, params[prop]);
|
157
|
+
delete(params[prop]);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
return params;
|
161
|
+
};
|
162
|
+
|
163
|
+
$(document).on('click', '[data-behaviour="filter-input"]', function(e) {
|
164
|
+
var filterType = $(this).data('filter-type')
|
165
|
+
var filterColumn = $(this).data('db-column')
|
166
|
+
|
167
|
+
var filterElement = $('[data-behaviour="filter"][data-filter-type=' + filterType + '][data-db-column=' + filterColumn +']')
|
168
|
+
|
169
|
+
if (filterType == 'range') {
|
170
|
+
filterElement.parent().toggleClass('hidden')
|
171
|
+
} else if (filterType == 'multi_select') {
|
172
|
+
$(this).parent().children(':last').toggleClass('hidden')
|
173
|
+
} else if (filterType == 'date') {
|
174
|
+
filterElement.click()
|
175
|
+
}
|
176
|
+
})
|
177
|
+
|
178
|
+
// Remove all the applied filters and reload the page
|
179
|
+
$(document).on('click', '.clear-btn', function(e) {
|
180
|
+
window.location.href = window.location.href.split("?")[0]
|
181
|
+
})
|
182
|
+
|
183
|
+
var unhideClearFilterBtn = function(filterValue) {
|
184
|
+
if (filterValue) {
|
185
|
+
$('.clear-btn').removeClass('hidden')
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
// Selecting options for single and multi select filters
|
190
|
+
$(document).on('click', '[data-behaviour="select-option"]', function(e) {
|
191
|
+
var filterType = $(this).data('filter-type')
|
192
|
+
var filterColumn = $(this).data('db-column')
|
193
|
+
|
194
|
+
if (filterType == 'single_select') {
|
195
|
+
var filterValue = $(this).data('value')
|
196
|
+
if (!this.classList.contains('selected')) {
|
197
|
+
if (this.parentNode.querySelector('.list-item.selected') != null) {
|
198
|
+
this.parentNode.querySelector('.list-item.selected').classList.remove('selected');
|
199
|
+
}
|
200
|
+
$(this).addClass('selected')
|
201
|
+
}
|
202
|
+
|
203
|
+
$(this).parents(':nth(4)').children(':first').children(':nth(1)').text(filterValue)
|
204
|
+
$(this).parents(':nth(4)').children(':first').children(':last').removeClass('hidden')
|
205
|
+
|
206
|
+
// Clear the search value post selection and regenerate the dropdown elements.
|
207
|
+
var searchInputElement = $(this).parents(':nth(1)').children(':first').children()
|
208
|
+
searchInputElement.val('')
|
209
|
+
CmFilter.dropdown_search(searchInputElement)
|
210
|
+
|
211
|
+
unhideClearFilterBtn(filterValue)
|
212
|
+
getFilteredData(filterType, filterValue, filterColumn)
|
213
|
+
}
|
214
|
+
else if (filterType == 'multi_select') {
|
215
|
+
var parentChip = $(this).parent().siblings(':first')
|
216
|
+
var checkboxElement = $(this).find('.cm-checkbox')
|
217
|
+
checkboxElement.prop('checked', !checkboxElement.prop('checked'))
|
218
|
+
var checkedCount = $(this).parent().find('.cm-checkbox').filter(':checked').length
|
219
|
+
|
220
|
+
if (checkboxElement.prop('checked')) {
|
221
|
+
var chip = $('<div class="chip"></div>')
|
222
|
+
var firstSpan = $('<span></span>').text($(this).data('value'))
|
223
|
+
var secondSpan = $('<span data-behaviour="selected-chip"><i class="fa fa-times"></i></span>')
|
224
|
+
parentChip.prepend(chip.append(firstSpan).append(secondSpan))
|
225
|
+
} else {
|
226
|
+
var chipElement = parentChip.find('.chip')
|
227
|
+
for(var i = 0; i < chipElement.length; i++) {
|
228
|
+
if ($(chipElement[i]).text() == $(this).data('value')) {
|
229
|
+
$(chipElement[i]).remove()
|
230
|
+
break
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
if (checkedCount > 0) {
|
236
|
+
parentChip.addClass('search-with-chips').removeClass('search-area')
|
237
|
+
$(this).parents(':nth(1)').children(':last').addClass('active')
|
238
|
+
} else {
|
239
|
+
parentChip.addClass('search-area').removeClass('search-with-chips')
|
240
|
+
$(this).parents(':nth(1)').children(':last').removeClass('active')
|
241
|
+
}
|
242
|
+
}
|
243
|
+
});
|
244
|
+
|
245
|
+
// Apply button for multi select filters
|
246
|
+
$(document).on('click', '.apply-area', function(e) {
|
247
|
+
var filterInputElement = $(this).parents(':nth(3)').children(':first')
|
248
|
+
var filterType = filterInputElement.data('filter-type')
|
249
|
+
var filterColumn = filterInputElement.data('db-column')
|
250
|
+
var filterValue = []
|
251
|
+
|
252
|
+
var selectFilterElement = $('[data-behaviour="select-option"][data-filter-type=' + filterType + '][data-db-column=' + filterColumn + ']')
|
253
|
+
var checkedElements = selectFilterElement.find('.cm-checkbox').filter(':checked')
|
254
|
+
|
255
|
+
if (checkedElements.length > 0) {
|
256
|
+
for(var i = 0; i < checkedElements.length; i++) {
|
257
|
+
filterValue.push($(checkedElements[i]).parent().data('value'))
|
258
|
+
}
|
259
|
+
|
260
|
+
truncatedFilterValue = filterValue[0]
|
261
|
+
if (filterValue.length > 1) {
|
262
|
+
truncatedFilterValue += ' + ' + (filterValue.length - 1) + ' more'
|
263
|
+
}
|
264
|
+
|
265
|
+
filterInputElement.children(':nth(1)').text(truncatedFilterValue)
|
266
|
+
filterInputElement.children(':last').removeClass('hidden')
|
267
|
+
selectFilterElement.parents(':nth(3)').addClass('hidden')
|
268
|
+
|
269
|
+
// Clear the search value post selection and regenerate the dropdown elements.
|
270
|
+
var searchInputElement = $(this).parent().children(':first').children(':last')
|
271
|
+
searchInputElement.val('')
|
272
|
+
CmFilter.dropdown_search(searchInputElement)
|
273
|
+
|
274
|
+
unhideClearFilterBtn(filterValue)
|
275
|
+
getFilteredData(filterType, filterValue, filterColumn)
|
276
|
+
}
|
277
|
+
});
|
278
|
+
|
279
|
+
// Remove single applied filter.
|
280
|
+
$(document).on('click', '.filter-chip-remove', function(e) {
|
281
|
+
var url = window.location.pathname
|
282
|
+
var filterType = $(this).parent().data('filter-type')
|
283
|
+
var filterColumn = $(this).parent().data('db-column')
|
284
|
+
|
285
|
+
var searchParams = window.location.search
|
286
|
+
if (searchParams.length > 0) {
|
287
|
+
queryString = getParamsAsObject(searchParams)
|
288
|
+
if (queryString['filters'][filterType] != undefined) {
|
289
|
+
delete(queryString['filters'][filterType][filterColumn])
|
290
|
+
var queryParam = jQuery.param(queryString)
|
291
|
+
window.history.pushState("", "", url + '?' + queryParam);
|
292
|
+
window.location.reload()
|
293
|
+
}
|
294
|
+
}
|
32
295
|
});
|
296
|
+
|
297
|
+
$(document).on('click', '[data-behaviour="selected-chip"]', function(e) {
|
298
|
+
var filterType = $(this).parents(':nth(5)').find('.filter-chip').data('filter-type')
|
299
|
+
var filterColumn = $(this).parents(':nth(5)').find('.filter-chip').data('db-column')
|
300
|
+
var filterValue = $(this).siblings().text()
|
301
|
+
|
302
|
+
var selectElement = $('[data-behaviour="select-option"][data-filter-type=' + filterType + '][data-db-column=' + filterColumn + ']')
|
303
|
+
$(this).parent().remove()
|
304
|
+
|
305
|
+
for(var i = 0; i < selectElement.length; i++) {
|
306
|
+
if ($(selectElement[i]).data('value') == filterValue) {
|
307
|
+
var checkboxElement = $(selectElement[i]).find('.cm-checkbox')
|
308
|
+
checkboxElement.prop('checked', !checkboxElement.prop('checked'))
|
309
|
+
break
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
var checkedCount = $(selectElement).find('.cm-checkbox').filter(':checked').length
|
314
|
+
if (checkedCount < 1) {
|
315
|
+
$(selectElement).parent().siblings(':first').addClass('search-area').removeClass('search-with-chips')
|
316
|
+
$(selectElement).parent().siblings(':last').removeClass('active')
|
317
|
+
}
|
318
|
+
})
|
319
|
+
|
320
|
+
CmFilter = {
|
321
|
+
// Generate or remove elements of the dropdown based on the search value.
|
322
|
+
dropdown_search: function(element) {
|
323
|
+
var filter = element.val().toUpperCase();
|
324
|
+
var dropdownElements = element.parents(':nth(1)').find('.list-area').children();
|
325
|
+
for (var i = 0; i < dropdownElements.length; i++) {
|
326
|
+
txtValue = $(dropdownElements[i]).children().text();
|
327
|
+
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
328
|
+
$(dropdownElements[i]).css('display', 'flex');
|
329
|
+
} else {
|
330
|
+
$(dropdownElements[i]).css('display', 'none');
|
331
|
+
}
|
332
|
+
}
|
333
|
+
},
|
334
|
+
quick_input_search: function(element) {
|
335
|
+
var filter = element.val().toUpperCase();
|
336
|
+
var searchElements = element.parents(':nth(3)').find('.list-area').children();
|
337
|
+
searchElements.removeClass('visible').addClass('hidden')
|
338
|
+
console.log("Filter is ", filter)
|
339
|
+
console.log("Search elements are ", searchElements)
|
340
|
+
for (var i = 0; i < searchElements.length; i++) {
|
341
|
+
txtValue = $(searchElements[i]).children().text();
|
342
|
+
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
343
|
+
$(searchElements[i]).removeClass('hidden').addClass('visible');
|
344
|
+
}
|
345
|
+
}
|
346
|
+
}
|
347
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
$(document).on("keydown", function(e) {
|
2
|
+
if (e.keyCode == 75 && e.metaKey) {
|
3
|
+
$('#quickSearchModal').modal('show')
|
4
|
+
}
|
5
|
+
});
|
6
|
+
|
7
|
+
var liSelected;
|
8
|
+
$(document).on('keydown', function(e){
|
9
|
+
var sel_item = $('.search-results-container > a.visible');
|
10
|
+
if ($('#quickSearchModal').hasClass('show')) {
|
11
|
+
var selected;
|
12
|
+
if(e.which === 40){
|
13
|
+
if(liSelected){
|
14
|
+
liSelected.removeClass('active-item');
|
15
|
+
next = liSelected.next();
|
16
|
+
if(next.length > 0){
|
17
|
+
liSelected = next.addClass('active-item');
|
18
|
+
selected = next.text();
|
19
|
+
|
20
|
+
}else{
|
21
|
+
liSelected = sel_item.eq(0).addClass('active-item');
|
22
|
+
selected = sel_item.eq(0).text();
|
23
|
+
}
|
24
|
+
}else{
|
25
|
+
liSelected = sel_item.eq(0).addClass('active-item');
|
26
|
+
selected = sel_item.eq(0).text();
|
27
|
+
}
|
28
|
+
}else if(e.which === 38){
|
29
|
+
if(liSelected){
|
30
|
+
liSelected.removeClass('active-item');
|
31
|
+
next = liSelected.prev();
|
32
|
+
if(next.length > 0){
|
33
|
+
liSelected = next.addClass('active-item');
|
34
|
+
selected = next.text();
|
35
|
+
|
36
|
+
}else{
|
37
|
+
|
38
|
+
liSelected = sel_item.last().addClass('active-item');
|
39
|
+
selected = sel_item.last().text()
|
40
|
+
}
|
41
|
+
}else{
|
42
|
+
liSelected = sel_item.last().addClass('active-item');
|
43
|
+
selected = sel_item.last().text()
|
44
|
+
}
|
45
|
+
}
|
46
|
+
if(liSelected && e.which === 13) {
|
47
|
+
console.log("Selected item id ", liSelected)
|
48
|
+
href = liSelected.attr('href')
|
49
|
+
window.location = href
|
50
|
+
}
|
51
|
+
}
|
52
|
+
});
|
53
|
+
|
54
|
+
$(document).on('keyup', '[data-behaviour="quick-input-search"]', function(e) {
|
55
|
+
if ($(this).val().length > 0) {
|
56
|
+
$('.clear-search').removeClass('hidden')
|
57
|
+
} else {
|
58
|
+
$('.clear-search').addClass('hidden')
|
59
|
+
}
|
60
|
+
CmFilter.quick_input_search($(this))
|
61
|
+
});
|
62
|
+
|
63
|
+
$(document).on('click', '.clear-search', function(){
|
64
|
+
$('#quick-search-input').val('')
|
65
|
+
$('.clear-search').addClass('hidden')
|
66
|
+
CmFilter.quick_input_search($('#quick-search-input'))
|
67
|
+
});
|
@@ -1,3 +1,32 @@
|
|
1
|
+
$(document).ready(function(e) {
|
2
|
+
$('.select-2').select2();
|
3
|
+
flatpickr("[data-behaviour='date-only']", {})
|
4
|
+
flatpickr("[data-behaviour='date-time']", {
|
5
|
+
enableTime: true
|
6
|
+
})
|
7
|
+
flatpickr("[data-behaviour='filter'][data-filter-type='date']", {
|
8
|
+
mode: 'range'
|
9
|
+
})
|
10
|
+
Sortable.create($('.columns-list')[0],{
|
11
|
+
handle: '.dragger',
|
12
|
+
animation: 150
|
13
|
+
});
|
14
|
+
});
|
15
|
+
|
16
|
+
$(document).on("keypress keyup blur", "[data-behaviour='decimal-only'], [data-behaviour='filter'][data-filter-type='range']", function (e) {
|
17
|
+
var charCode = (e.which) ? e.which : e.keyCode
|
18
|
+
if (charCode > 31 && (charCode != 46 &&(charCode < 48 || charCode > 57)))
|
19
|
+
return false;
|
20
|
+
return true;
|
21
|
+
});
|
22
|
+
|
23
|
+
$(document).on("keypress keyup blur", "[data-behaviour='integer-only']", function (event) {
|
24
|
+
$(this).val($(this).val().replace(/[^\d].+/, ""));
|
25
|
+
if ((event.which < 48 || event.which > 57)) {
|
26
|
+
event.preventDefault();
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
1
30
|
$(document).on('click', '.row-action-cell', function(e) {
|
2
31
|
e.stopPropagation();
|
3
32
|
if ($(this).hasClass('opacity-1')) {
|
@@ -11,4 +40,4 @@ $(document).on('click', '.row-action-cell', function(e) {
|
|
11
40
|
} else {
|
12
41
|
return $(this).find('.table-export-popup').addClass('hidden');
|
13
42
|
}
|
14
|
-
});
|
43
|
+
});
|