kaui 3.0.5 → 3.0.7
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/app/assets/javascripts/kaui/kaui_override.js +1 -6
- data/app/assets/javascripts/kaui/multi_functions_bar_utils.js +132 -0
- data/app/controllers/kaui/account_timelines_controller.rb +1 -1
- data/app/controllers/kaui/accounts_controller.rb +24 -28
- data/app/controllers/kaui/admin_tenants_controller.rb +1 -1
- data/app/controllers/kaui/engine_controller_util.rb +27 -0
- data/app/controllers/kaui/invoices_controller.rb +11 -14
- data/app/controllers/kaui/payments_controller.rb +20 -17
- data/app/controllers/kaui/sessions_controller.rb +2 -0
- data/app/helpers/kaui/exception_helper.rb +3 -1
- data/app/models/kaui/account.rb +4 -1
- data/app/models/kaui/invoice.rb +2 -0
- data/app/models/kaui/payment.rb +2 -0
- data/app/services/dependencies/kenui.rb +40 -0
- data/app/views/kaui/accounts/_account_filterbar.html.erb +189 -0
- data/app/views/kaui/accounts/_multi_functions_bar.html.erb +41 -2
- data/app/views/kaui/accounts/index.html.erb +6 -11
- data/app/views/kaui/invoices/_invoice_filterbar.html.erb +204 -0
- data/app/views/kaui/invoices/_multi_functions_bar.html.erb +17 -2
- data/app/views/kaui/invoices/index.html.erb +15 -5
- data/app/views/kaui/payments/_multi_functions_bar.html.erb +17 -2
- data/app/views/kaui/payments/_payment_filterbar.html.erb +190 -0
- data/app/views/kaui/payments/index.html.erb +10 -6
- data/lib/kaui/engine.rb +0 -1
- data/lib/kaui/version.rb +1 -1
- data/lib/kaui.rb +14 -3
- metadata +7 -16
@@ -0,0 +1,189 @@
|
|
1
|
+
<div class="modal fade" id="advanceSearchModal" tabindex="-1" role="dialog" aria-labelledby="advanceSearchModalLabel" aria-hidden="true">
|
2
|
+
<div class="modal-dialog" role="document">
|
3
|
+
<div class="modal-content">
|
4
|
+
<div class="modal-header">
|
5
|
+
<h5 class="modal-title" id="advanceSearchModalLabel">Advance Search</h5>
|
6
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
7
|
+
<span aria-hidden="true">×</span>
|
8
|
+
</button>
|
9
|
+
</div>
|
10
|
+
<div class="modal-body">
|
11
|
+
<form id="advanceSearchForm">
|
12
|
+
<div class="form-group d-flex align-items-center">
|
13
|
+
<label for="searchFieldSelect" class="mr-2" style="width: 30%;">Search Fields:</label>
|
14
|
+
<select id="searchFieldSelect" class="form-control mr-2">
|
15
|
+
<% @search_fields.each do |value, title| %>
|
16
|
+
<option value="<%= value %>"><%= title %></option>
|
17
|
+
<% end %>
|
18
|
+
</select>
|
19
|
+
<button type="button" class="btn btn-secondary" id="addSearchField">Add</button>
|
20
|
+
</div>
|
21
|
+
<div id="search-fields-container">
|
22
|
+
</div>
|
23
|
+
</form>
|
24
|
+
</div>
|
25
|
+
<div class="modal-footer">
|
26
|
+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
27
|
+
<button type="button" class="btn btn-primary" id="applyAdvanceSearch">Apply Search</button>
|
28
|
+
<button type="button" class="btn btn-danger" id="clearAdvanceSearch">Clear Search</button>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<template id="search-field-template">
|
35
|
+
<div class="form-group row align-items-center search-field">
|
36
|
+
<label class="col-sm-4 col-form-label search-field-label"></label>
|
37
|
+
<div class="col-sm-3">
|
38
|
+
<select class="form-control search-field-filter">
|
39
|
+
<option value="eq">Equals</option>
|
40
|
+
<option value="neq">Not Equals</option>
|
41
|
+
<option value="gt">Greater Than</option>
|
42
|
+
<option value="gte">Greater Than Or Equal</option>
|
43
|
+
<option value="lt">Less Than</option>
|
44
|
+
<option value="lte">Less Than Or Equal</option>
|
45
|
+
<option value="like">Like</option>
|
46
|
+
</select>
|
47
|
+
</div>
|
48
|
+
<div class="col-sm-4">
|
49
|
+
<input type="text" class="form-control search-field-value">
|
50
|
+
</div>
|
51
|
+
<div class="col-sm-1">
|
52
|
+
<i class="glyphicon glyphicon-remove" id=remove-search-field></i>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
</template>
|
56
|
+
|
57
|
+
<style>
|
58
|
+
.form-group.row.align-items-center {
|
59
|
+
display: flex;
|
60
|
+
align-items: center;
|
61
|
+
}
|
62
|
+
|
63
|
+
.form-group.row.align-items-center label {
|
64
|
+
margin-bottom: 0; /* Remove default margin */
|
65
|
+
}
|
66
|
+
|
67
|
+
.form-group.row.align-items-center .form-control {
|
68
|
+
margin-right: 10px; /* Add some space between elements */
|
69
|
+
}
|
70
|
+
|
71
|
+
.form-group.d-flex {
|
72
|
+
display: flex;
|
73
|
+
align-items: center;
|
74
|
+
}
|
75
|
+
|
76
|
+
.form-group.d-flex label {
|
77
|
+
margin-bottom: 0; /* Remove default margin */
|
78
|
+
}
|
79
|
+
|
80
|
+
.form-group.d-flex .form-control {
|
81
|
+
margin-right: 10px; /* Add some space between the select box and the button */
|
82
|
+
}
|
83
|
+
|
84
|
+
#search-labels-container .label {
|
85
|
+
margin-left: 5px; /* Add space between labels */
|
86
|
+
margin-bottom: 5px; /* Add space below labels if they wrap to the next line */
|
87
|
+
color: white;
|
88
|
+
}
|
89
|
+
|
90
|
+
.filter-bar-container {
|
91
|
+
display: flex;
|
92
|
+
justify-content: flex-start; /* Align items to the left */
|
93
|
+
align-items: center; /* Center items vertically */
|
94
|
+
}
|
95
|
+
|
96
|
+
.filter-bar {
|
97
|
+
display: flex;
|
98
|
+
align-items: center; /* Center items vertically */
|
99
|
+
}
|
100
|
+
|
101
|
+
.filter-bar label {
|
102
|
+
margin: 10px; /* Add some space between the label and the select box */
|
103
|
+
}
|
104
|
+
</style>
|
105
|
+
|
106
|
+
<%= javascript_tag do %>
|
107
|
+
$(document).ready(function() {
|
108
|
+
populateSearchLabelsFromUrl();
|
109
|
+
var dateFields = ['Created date', 'Updated date', 'Reference time'];
|
110
|
+
// Handle the "Add" button click to add new search fields
|
111
|
+
$('#addSearchField').on('click', function() {
|
112
|
+
var selectedField = $('#searchFieldSelect option:selected').text();
|
113
|
+
var template = document.getElementById('search-field-template').content.cloneNode(true);
|
114
|
+
|
115
|
+
// Set the label and input names based on the selected field
|
116
|
+
template.querySelector('.search-field-label').textContent = selectedField.replace(/([A-Z])/g, ' $1').trim();
|
117
|
+
template.querySelector('.search-field-filter').name = selectedField + 'Filter';
|
118
|
+
|
119
|
+
// Check if the field should use a date input
|
120
|
+
if (dateFields.includes(selectedField)) {
|
121
|
+
template.querySelector('.search-field-value').type = 'date';
|
122
|
+
} else {
|
123
|
+
template.querySelector('.search-field-value').type = 'text';
|
124
|
+
}
|
125
|
+
template.querySelector('.search-field-value').name = selectedField;
|
126
|
+
|
127
|
+
// Append the new search field to the container
|
128
|
+
document.getElementById('search-fields-container').appendChild(template);
|
129
|
+
});
|
130
|
+
|
131
|
+
// Handle the "Apply Search" button click inside the modal
|
132
|
+
$('#applyAdvanceSearch').on('click', function() {
|
133
|
+
var searchFields = $('.search-field');
|
134
|
+
var searchLabelsContainer = $('#search-labels-container');
|
135
|
+
searchLabelsContainer.empty();
|
136
|
+
|
137
|
+
var table = $('#accounts-table').DataTable();
|
138
|
+
table.on('preXhr.dt', function(e, settings, data) {
|
139
|
+
data.search.value = searchQuery;
|
140
|
+
});
|
141
|
+
|
142
|
+
table.ajax.url("<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>").load();
|
143
|
+
|
144
|
+
// Update the URL with the search parameters
|
145
|
+
var searchParams = searchQuery('');
|
146
|
+
if (searchParams) {
|
147
|
+
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + searchParams;
|
148
|
+
window.history.pushState({ path: newUrl }, '', newUrl);
|
149
|
+
}
|
150
|
+
|
151
|
+
searchFields.each(function() {
|
152
|
+
var filter = $(this).find('.search-field-filter option:selected').text();
|
153
|
+
var value = $(this).find('.search-field-value').val();
|
154
|
+
var columnName = $(this).find('.search-field-filter').attr('name').replace('Filter', '');
|
155
|
+
|
156
|
+
// Create and append the search label
|
157
|
+
if (value !== '') {
|
158
|
+
var label = $('<span>', {
|
159
|
+
class: 'label label-info',
|
160
|
+
text: columnName + ' [' + filter + '] ' + value
|
161
|
+
});
|
162
|
+
}
|
163
|
+
searchLabelsContainer.append(label);
|
164
|
+
});
|
165
|
+
|
166
|
+
$('#advanceSearchModal').modal('hide');
|
167
|
+
});
|
168
|
+
|
169
|
+
// Populate the modal with the current filters when it is shown
|
170
|
+
$('#advanceSearchModal').on('show.bs.modal', function() {
|
171
|
+
showAdvanceSearchModal();
|
172
|
+
$('#search-fields-container .search-field').each(function() {
|
173
|
+
var input = $(this).find('.search-field-value');
|
174
|
+
if (dateFields.includes(input.attr('name'))) {
|
175
|
+
input.attr('type', 'date');
|
176
|
+
}
|
177
|
+
});
|
178
|
+
});
|
179
|
+
|
180
|
+
$('#clearAdvanceSearch').on('click', function() {
|
181
|
+
clearAdvanceSearch();
|
182
|
+
});
|
183
|
+
|
184
|
+
// Handle the remove icon click event to remove search fields
|
185
|
+
$('#search-fields-container').on('click', '#remove-search-field', function() {
|
186
|
+
$(this).closest('.search-field').remove();
|
187
|
+
});
|
188
|
+
});
|
189
|
+
<% end %>
|
@@ -1,3 +1,20 @@
|
|
1
|
+
|
2
|
+
<div class="filter-bar-container">
|
3
|
+
<div class="filter-bar">
|
4
|
+
<button class="btn btn-default download-button-right" data-toggle="modal" data-target="#advanceSearchModal">
|
5
|
+
<i class="glyphicon glyphicon-search"></i>
|
6
|
+
<strong>Advance Search</strong>
|
7
|
+
</button>
|
8
|
+
|
9
|
+
<div id="search-labels-container" class="ml-2">
|
10
|
+
<!-- Dynamic search labels will be added here -->
|
11
|
+
</div>
|
12
|
+
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<%= render :partial => 'account_filterbar' %>
|
17
|
+
|
1
18
|
<div class="dropdown-container">
|
2
19
|
<button class="btn btn-default download-button-right" type="button" id="modalDownloadButton">
|
3
20
|
<i class="glyphicon glyphicon-download-alt"></i>
|
@@ -231,12 +248,35 @@ $(document).ready(function() {
|
|
231
248
|
params.append('endDate', endDate);
|
232
249
|
}
|
233
250
|
params.append('allFieldsChecked', allFieldsChecked);
|
251
|
+
params.append('search', searchQuery());
|
234
252
|
url.search = params.toString();
|
235
|
-
console.log(url.toString());
|
236
253
|
window.open(url.toString(), '_blank');
|
237
254
|
});
|
238
255
|
}
|
239
256
|
|
257
|
+
function searchQuery(){
|
258
|
+
var searchFields = $('.search-field');
|
259
|
+
var searchLabelsContainer = $('#search-labels-container');
|
260
|
+
searchLabelsContainer.empty();
|
261
|
+
|
262
|
+
var searchLabels = searchFields.map(function() {
|
263
|
+
var filter = $(this).find('.search-field-filter').val();
|
264
|
+
var value = $(this).find('.search-field-value').val();
|
265
|
+
var columnName = $(this).find('.search-field-filter').attr('name').replace('Filter', '').toLowerCase().replace(/\s+/g, '_');
|
266
|
+
|
267
|
+
if (value !== '') {
|
268
|
+
if (filter === 'like') {
|
269
|
+
return columnName + encodeURIComponent('[' + filter + ']') + '=' + encodeURIComponent('%' + value + '%');
|
270
|
+
} else {
|
271
|
+
return columnName + encodeURIComponent('[' + filter + ']') + '=' + encodeURIComponent(value);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}).get().join('&');
|
275
|
+
|
276
|
+
var searchLabelString = searchLabels.length > 0 ? ('_q=1&' + searchLabels) : '';
|
277
|
+
return searchLabelString;
|
278
|
+
};
|
279
|
+
|
240
280
|
updateDropdownOrder();
|
241
281
|
|
242
282
|
function updateDropdownOrder() {
|
@@ -300,7 +340,6 @@ $(document).ready(function() {
|
|
300
340
|
function reorderTableColumns(order) {
|
301
341
|
var table = $('#accounts-table').DataTable();
|
302
342
|
var columnIndexes = order.map(Number);
|
303
|
-
console.log('New column order:', columnIndexes);
|
304
343
|
table.colReorder.order(columnIndexes);
|
305
344
|
resetDataColumn();
|
306
345
|
resetDataId();
|
@@ -1,12 +1,6 @@
|
|
1
1
|
<div class="search">
|
2
2
|
|
3
3
|
<div class="column-block">
|
4
|
-
|
5
|
-
<% if @search_query.present? %>
|
6
|
-
<h1>Showing search results for "<%= @search_query %>"</h1>
|
7
|
-
<% else %>
|
8
|
-
<h1>Showing all accounts</h1>
|
9
|
-
<% end %>
|
10
4
|
<%= render :partial => 'multi_functions_bar' %>
|
11
5
|
|
12
6
|
<table id="accounts-table" class="table table-condensed mobile-data" style="width:100%">
|
@@ -60,7 +54,7 @@ $(document).ready(function() {
|
|
60
54
|
"serverSide": true,
|
61
55
|
"search": {"search": "<%= @search_query %>"},
|
62
56
|
"ajax": {
|
63
|
-
url: "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>",
|
57
|
+
url: "<%= accounts_pagination_path(:ordering => @ordering, :format => :json, :advance_search_query => @advance_search_query) %>",
|
64
58
|
dataSrc: function(json) {
|
65
59
|
var colOrder = table.colReorder.order();
|
66
60
|
var reorderedData = json.data.map(function(row) {
|
@@ -77,14 +71,15 @@ $(document).ready(function() {
|
|
77
71
|
});
|
78
72
|
|
79
73
|
<!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
|
80
|
-
|
81
|
-
|
74
|
+
$('#accounts-table').on('draw.dt', function() {
|
75
|
+
<% if @max_nb_records.nil? %>
|
82
76
|
var noMoreData = table.column(0)
|
83
77
|
.data()
|
84
78
|
.length == 0;
|
85
79
|
$(".next.paginate_button").toggleClass("disabled", noMoreData);
|
86
80
|
$(".dataTables_info").toggle(!noMoreData);
|
87
|
-
|
88
|
-
|
81
|
+
<% end %>
|
82
|
+
populateSearchLabelsFromUrl();
|
83
|
+
});
|
89
84
|
});
|
90
85
|
<% end %>
|
@@ -0,0 +1,204 @@
|
|
1
|
+
<div class="modal fade" id="advanceSearchModal" tabindex="-1" role="dialog" aria-labelledby="advanceSearchModalLabel" aria-hidden="true">
|
2
|
+
<div class="modal-dialog" role="document">
|
3
|
+
<div class="modal-content">
|
4
|
+
<div class="modal-header">
|
5
|
+
<h5 class="modal-title" id="advanceSearchModalLabel">Advance Search</h5>
|
6
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
7
|
+
<span aria-hidden="true">×</span>
|
8
|
+
</button>
|
9
|
+
</div>
|
10
|
+
<div class="modal-body">
|
11
|
+
<form id="advanceSearchForm">
|
12
|
+
<div class="form-group d-flex align-items-center">
|
13
|
+
<label for="searchFieldSelect" class="mr-2" style="width: 30%;">Search Fields:</label>
|
14
|
+
<select id="searchFieldSelect" class="form-control mr-2">
|
15
|
+
<% if @account.account_id.present? %>
|
16
|
+
<% @search_fields.reject { |value, _| value == 'balance' || value == 'account_id' }.each do |value, title| %>
|
17
|
+
<option value="<%= value %>"><%= title %></option>
|
18
|
+
<% end %>
|
19
|
+
<% else %>
|
20
|
+
<% @search_fields.each do |value, title| %>
|
21
|
+
<option value="<%= value %>"><%= title %></option>
|
22
|
+
<% end %>
|
23
|
+
<% end %>
|
24
|
+
</select>
|
25
|
+
<button type="button" class="btn btn-secondary" id="addSearchField">Add</button>
|
26
|
+
</div>
|
27
|
+
<div id="search-fields-container">
|
28
|
+
</div>
|
29
|
+
</form>
|
30
|
+
<% unless @account.account_id.present? %>
|
31
|
+
<div class="alert alert-info" role="alert">
|
32
|
+
* The Balance option won't work alongside other filters. If you search using Balance, all other filters will be ignored.
|
33
|
+
</div>
|
34
|
+
<% end %>
|
35
|
+
</div>
|
36
|
+
<div class="modal-footer">
|
37
|
+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
38
|
+
<button type="button" class="btn btn-primary" id="applyAdvanceSearch">Apply Search</button>
|
39
|
+
<button type="button" class="btn btn-danger" id="clearAdvanceSearch">Clear Search</button>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<template id="search-field-template">
|
46
|
+
<div class="form-group row align-items-center search-field">
|
47
|
+
<label class="col-sm-4 col-form-label search-field-label"></label>
|
48
|
+
<div class="col-sm-3">
|
49
|
+
<select class="form-control search-field-filter">
|
50
|
+
<option value="eq">Equals</option>
|
51
|
+
<option value="neq">Not Equals</option>
|
52
|
+
<option value="gt">Greater Than</option>
|
53
|
+
<option value="gte">Greater Than Or Equal</option>
|
54
|
+
<option value="lt">Less Than</option>
|
55
|
+
<option value="lte">Less Than Or Equal</option>
|
56
|
+
<option value="like">Like</option>
|
57
|
+
</select>
|
58
|
+
</div>
|
59
|
+
<div class="col-sm-4">
|
60
|
+
<input type="text" class="form-control search-field-value">
|
61
|
+
</div>
|
62
|
+
<div class="col-sm-1">
|
63
|
+
<i class="glyphicon glyphicon-remove" id=remove-search-field></i>
|
64
|
+
</div>
|
65
|
+
</div>
|
66
|
+
</template>
|
67
|
+
|
68
|
+
<style>
|
69
|
+
.form-group.row.align-items-center {
|
70
|
+
display: flex;
|
71
|
+
align-items: center;
|
72
|
+
}
|
73
|
+
|
74
|
+
.form-group.row.align-items-center label {
|
75
|
+
margin-bottom: 0; /* Remove default margin */
|
76
|
+
}
|
77
|
+
|
78
|
+
.form-group.row.align-items-center .form-control {
|
79
|
+
margin-right: 10px; /* Add some space between elements */
|
80
|
+
}
|
81
|
+
|
82
|
+
.form-group.d-flex {
|
83
|
+
display: flex;
|
84
|
+
align-items: center;
|
85
|
+
}
|
86
|
+
|
87
|
+
.form-group.d-flex label {
|
88
|
+
margin-bottom: 0; /* Remove default margin */
|
89
|
+
}
|
90
|
+
|
91
|
+
.form-group.d-flex .form-control {
|
92
|
+
margin-right: 10px; /* Add some space between the select box and the button */
|
93
|
+
}
|
94
|
+
|
95
|
+
#search-labels-container .label {
|
96
|
+
margin-left: 5px; /* Add space between labels */
|
97
|
+
margin-bottom: 5px; /* Add space below labels if they wrap to the next line */
|
98
|
+
color: white;
|
99
|
+
}
|
100
|
+
|
101
|
+
.filter-bar-container {
|
102
|
+
display: flex;
|
103
|
+
justify-content: flex-start; /* Align items to the left */
|
104
|
+
align-items: center; /* Center items vertically */
|
105
|
+
}
|
106
|
+
|
107
|
+
.filter-bar {
|
108
|
+
display: flex;
|
109
|
+
align-items: center; /* Center items vertically */
|
110
|
+
}
|
111
|
+
|
112
|
+
.filter-bar label {
|
113
|
+
margin: 10px; /* Add some space between the label and the select box */
|
114
|
+
}
|
115
|
+
</style>
|
116
|
+
|
117
|
+
<%= javascript_tag do %>
|
118
|
+
$(document).ready(function() {
|
119
|
+
populateSearchLabelsFromUrl();
|
120
|
+
var dateFields = ['Invoice date', 'Target date'];
|
121
|
+
// Handle the "Add" button click to add new search fields
|
122
|
+
$('#addSearchField').on('click', function() {
|
123
|
+
var selectedField = $('#searchFieldSelect option:selected').text();
|
124
|
+
var template = document.getElementById('search-field-template').content.cloneNode(true);
|
125
|
+
|
126
|
+
// Set the label and input names based on the selected field
|
127
|
+
template.querySelector('.search-field-label').textContent = selectedField.replace(/([A-Z])/g, ' $1').trim();
|
128
|
+
template.querySelector('.search-field-filter').name = selectedField + 'Filter';
|
129
|
+
|
130
|
+
// Check if the field should use a date input
|
131
|
+
if (dateFields.includes(selectedField)) {
|
132
|
+
template.querySelector('.search-field-value').type = 'date';
|
133
|
+
} else if (selectedField === 'Balance') {
|
134
|
+
template.querySelector('.search-field-value').type = 'number';
|
135
|
+
} else {
|
136
|
+
template.querySelector('.search-field-value').type = 'text';
|
137
|
+
}
|
138
|
+
template.querySelector('.search-field-value').name = selectedField;
|
139
|
+
|
140
|
+
// Append the new search field to the container
|
141
|
+
document.getElementById('search-fields-container').appendChild(template);
|
142
|
+
});
|
143
|
+
|
144
|
+
// Handle the "Apply Search" button click inside the modal
|
145
|
+
$('#applyAdvanceSearch').on('click', function() {
|
146
|
+
var searchFields = $('.search-field');
|
147
|
+
var searchLabelsContainer = $('#search-labels-container');
|
148
|
+
searchLabelsContainer.empty();
|
149
|
+
|
150
|
+
var table = $('#invoices-table').DataTable();
|
151
|
+
table.on('preXhr.dt', function(e, settings, data) {
|
152
|
+
data.search.value = searchQuery("<%= @search_query.to_s %>");
|
153
|
+
});
|
154
|
+
|
155
|
+
table.ajax.url("<%= invoices_pagination_path(:ordering => @ordering, :format => :json) %>").load();
|
156
|
+
|
157
|
+
// Update the URL with the search parameters
|
158
|
+
var searchParams = searchQuery("<%= @search_query.to_s %>");
|
159
|
+
if (searchParams) {
|
160
|
+
searchParams = searchParams.replace(/account_id/g, 'ac_id');
|
161
|
+
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + searchParams;
|
162
|
+
window.history.pushState({ path: newUrl }, '', newUrl);
|
163
|
+
}
|
164
|
+
|
165
|
+
searchFields.each(function() {
|
166
|
+
var filter = $(this).find('.search-field-filter option:selected').text();
|
167
|
+
var value = $(this).find('.search-field-value').val();
|
168
|
+
var columnName = $(this).find('.search-field-filter').attr('name').replace('Filter', '');
|
169
|
+
|
170
|
+
// Create and append the search label
|
171
|
+
if (value !== '') {
|
172
|
+
var label = $('<span>', {
|
173
|
+
class: 'label label-info',
|
174
|
+
text: columnName + ' [' + filter + '] ' + value
|
175
|
+
});
|
176
|
+
}
|
177
|
+
searchLabelsContainer.append(label);
|
178
|
+
});
|
179
|
+
$('#advanceSearchModal').modal('hide');
|
180
|
+
});
|
181
|
+
|
182
|
+
// Populate the modal with the current filters when it is shown
|
183
|
+
$('#advanceSearchModal').on('show.bs.modal', function() {
|
184
|
+
showAdvanceSearchModal();
|
185
|
+
$('#search-fields-container .search-field').each(function() {
|
186
|
+
var input = $(this).find('.search-field-value');
|
187
|
+
if (dateFields.includes(input.attr('name'))) {
|
188
|
+
input.attr('type', 'date');
|
189
|
+
} else if (input.attr('name') === 'Balance') {
|
190
|
+
input.attr('type', 'number');
|
191
|
+
}
|
192
|
+
});
|
193
|
+
});
|
194
|
+
|
195
|
+
$('#clearAdvanceSearch').on('click', function() {
|
196
|
+
clearAdvanceSearch();
|
197
|
+
});
|
198
|
+
|
199
|
+
// Handle the remove icon click event to remove search fields
|
200
|
+
$('#search-fields-container').on('click', '#remove-search-field', function() {
|
201
|
+
$(this).closest('.search-field').remove();
|
202
|
+
});
|
203
|
+
});
|
204
|
+
<% end %>
|
@@ -1,3 +1,19 @@
|
|
1
|
+
<div class="filter-bar-container">
|
2
|
+
<div class="filter-bar">
|
3
|
+
<button class="btn btn-default download-button-right" data-toggle="modal" data-target="#advanceSearchModal">
|
4
|
+
<i class="glyphicon glyphicon-search"></i>
|
5
|
+
<strong>Advance Search</strong>
|
6
|
+
</button>
|
7
|
+
|
8
|
+
<div id="search-labels-container" class="ml-2">
|
9
|
+
<!-- Dynamic search labels will be added here -->
|
10
|
+
</div>
|
11
|
+
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<%= render :partial => 'invoice_filterbar' %>
|
16
|
+
|
1
17
|
<div class="dropdown-container">
|
2
18
|
<button class="btn btn-default download-button-right" type="button" id="modalDownloadButton">
|
3
19
|
<i class="glyphicon glyphicon-download-alt"></i>
|
@@ -232,8 +248,8 @@ $(document).ready(function() {
|
|
232
248
|
params.append('endDate', endDate);
|
233
249
|
}
|
234
250
|
params.append('allFieldsChecked', allFieldsChecked);
|
251
|
+
params.append('search', searchQuery());
|
235
252
|
url.search = params.toString();
|
236
|
-
console.log(url.toString());
|
237
253
|
window.open(url.toString(), '_blank');
|
238
254
|
});
|
239
255
|
}
|
@@ -293,7 +309,6 @@ $(document).ready(function() {
|
|
293
309
|
function reorderTableColumns(order) {
|
294
310
|
var table = $('#invoices-table').DataTable();
|
295
311
|
var columnIndexes = order.map(Number);
|
296
|
-
console.log('New column order:', columnIndexes);
|
297
312
|
table.colReorder.order(columnIndexes);
|
298
313
|
resetDataColumn();
|
299
314
|
resetDataId();
|
@@ -63,7 +63,10 @@ $(document).ready(function() {
|
|
63
63
|
"serverSide": true,
|
64
64
|
"search": {"search": "<%= @search_query %>"},
|
65
65
|
"ajax": {
|
66
|
-
url: "<%= invoices_pagination_path(:ordering => @ordering, :format => :json) %>",
|
66
|
+
url: "<%= invoices_pagination_path(:ordering => @ordering, :format => :json, :advance_search_query => @advance_search_query) %>",
|
67
|
+
data: function(d) {
|
68
|
+
d.colum_order = $('#invoices-table').DataTable().colReorder.order();
|
69
|
+
},
|
67
70
|
dataSrc: function(json) {
|
68
71
|
var colOrder = table.colReorder.order();
|
69
72
|
var reorderedData = json.data.map(function(row) {
|
@@ -78,15 +81,22 @@ $(document).ready(function() {
|
|
78
81
|
}
|
79
82
|
});
|
80
83
|
|
84
|
+
// Add an action whenever the page changes
|
85
|
+
table.on('page.dt', function() {
|
86
|
+
debugger;
|
87
|
+
populateSearchLabelsFromUrl();
|
88
|
+
});
|
89
|
+
|
81
90
|
<!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
|
82
|
-
|
83
|
-
|
91
|
+
$('#invoices-table').on('draw.dt', function() {
|
92
|
+
<% if @max_nb_records.nil? %>
|
84
93
|
var noMoreData = table.column(0)
|
85
94
|
.data()
|
86
95
|
.length == 0;
|
87
96
|
$(".next.paginate_button").toggleClass("disabled", noMoreData);
|
88
97
|
$(".dataTables_info").toggle(!noMoreData);
|
89
|
-
|
90
|
-
|
98
|
+
<% end %>
|
99
|
+
populateSearchLabelsFromUrl();
|
100
|
+
});
|
91
101
|
});
|
92
102
|
<% end %>
|
@@ -1,3 +1,19 @@
|
|
1
|
+
<div class="filter-bar-container">
|
2
|
+
<div class="filter-bar">
|
3
|
+
<button class="btn btn-default download-button-right" data-toggle="modal" data-target="#advanceSearchModal">
|
4
|
+
<i class="glyphicon glyphicon-search"></i>
|
5
|
+
<strong>Advance Search</strong>
|
6
|
+
</button>
|
7
|
+
|
8
|
+
<div id="search-labels-container" class="ml-2">
|
9
|
+
<!-- Dynamic search labels will be added here -->
|
10
|
+
</div>
|
11
|
+
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<%= render :partial => 'payment_filterbar' %>
|
16
|
+
|
1
17
|
<div class="dropdown-container">
|
2
18
|
<button class="btn btn-default download-button-right" type="button" id="modalDownloadButton">
|
3
19
|
<i class="glyphicon glyphicon-download-alt"></i>
|
@@ -233,8 +249,8 @@ $(document).ready(function() {
|
|
233
249
|
params.append('endDate', endDate);
|
234
250
|
}
|
235
251
|
params.append('allFieldsChecked', allFieldsChecked);
|
252
|
+
params.append('search', searchQuery());
|
236
253
|
url.search = params.toString();
|
237
|
-
console.log(url.toString());
|
238
254
|
window.open(url.toString(), '_blank');
|
239
255
|
});
|
240
256
|
}
|
@@ -294,7 +310,6 @@ $(document).ready(function() {
|
|
294
310
|
function reorderTableColumns(order) {
|
295
311
|
var table = $('#payments-table').DataTable();
|
296
312
|
var columnIndexes = order.map(Number);
|
297
|
-
console.log('New column order:', columnIndexes);
|
298
313
|
table.colReorder.order(columnIndexes);
|
299
314
|
resetDataColumn();
|
300
315
|
resetDataId();
|