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.
@@ -0,0 +1,190 @@
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">&times;</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 == '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
+ </div>
31
+ <div class="modal-footer">
32
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
33
+ <button type="button" class="btn btn-primary" id="applyAdvanceSearch">Apply Search</button>
34
+ <button type="button" class="btn btn-danger" id="clearAdvanceSearch">Clear Search</button>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+
40
+ <template id="search-field-template">
41
+ <div class="form-group row align-items-center search-field">
42
+ <label class="col-sm-4 col-form-label search-field-label"></label>
43
+ <div class="col-sm-3">
44
+ <select class="form-control search-field-filter">
45
+ <option value="eq">Equals</option>
46
+ <option value="neq">Not Equals</option>
47
+ <option value="gt">Greater Than</option>
48
+ <option value="gte">Greater Than Or Equal</option>
49
+ <option value="lt">Less Than</option>
50
+ <option value="lte">Less Than Or Equal</option>
51
+ <option value="like">Like</option>
52
+ </select>
53
+ </div>
54
+ <div class="col-sm-4">
55
+ <input type="text" class="form-control search-field-value">
56
+ </div>
57
+ <div class="col-sm-1">
58
+ <i class="glyphicon glyphicon-remove" id=remove-search-field></i>
59
+ </div>
60
+ </div>
61
+ </template>
62
+
63
+ <style>
64
+ .form-group.row.align-items-center {
65
+ display: flex;
66
+ align-items: center;
67
+ }
68
+
69
+ .form-group.row.align-items-center label {
70
+ margin-bottom: 0; /* Remove default margin */
71
+ }
72
+
73
+ .form-group.row.align-items-center .form-control {
74
+ margin-right: 10px; /* Add some space between elements */
75
+ }
76
+
77
+ .form-group.d-flex {
78
+ display: flex;
79
+ align-items: center;
80
+ }
81
+
82
+ .form-group.d-flex label {
83
+ margin-bottom: 0; /* Remove default margin */
84
+ }
85
+
86
+ .form-group.d-flex .form-control {
87
+ margin-right: 10px; /* Add some space between the select box and the button */
88
+ }
89
+
90
+ #search-labels-container .label {
91
+ margin-left: 5px; /* Add space between labels */
92
+ margin-bottom: 5px; /* Add space below labels if they wrap to the next line */
93
+ color: white;
94
+ }
95
+
96
+ .filter-bar-container {
97
+ display: flex;
98
+ justify-content: flex-start; /* Align items to the left */
99
+ align-items: center; /* Center items vertically */
100
+ }
101
+
102
+ .filter-bar {
103
+ display: flex;
104
+ align-items: center; /* Center items vertically */
105
+ }
106
+
107
+ .filter-bar label {
108
+ margin: 10px; /* Add some space between the label and the select box */
109
+ }
110
+ </style>
111
+
112
+ <%= javascript_tag do %>
113
+ $(document).ready(function() {
114
+ populateSearchLabelsFromUrl();
115
+
116
+ // Handle the "Add" button click to add new search fields
117
+ $('#addSearchField').on('click', function() {
118
+ var selectedField = $('#searchFieldSelect option:selected').text();
119
+ var template = document.getElementById('search-field-template').content.cloneNode(true);
120
+
121
+ // Set the label and input names based on the selected field
122
+ template.querySelector('.search-field-label').textContent = selectedField.replace(/([A-Z])/g, ' $1').trim();
123
+ template.querySelector('.search-field-filter').name = selectedField + 'Filter';
124
+
125
+ // Check if the field should use a date input
126
+ var dateFields = ['Invoice date', 'Target date'];
127
+ if (dateFields.includes(selectedField)) {
128
+ template.querySelector('.search-field-value').type = 'date';
129
+ } else {
130
+ template.querySelector('.search-field-value').type = 'text';
131
+ }
132
+ template.querySelector('.search-field-value').name = selectedField;
133
+
134
+ // Append the new search field to the container
135
+ document.getElementById('search-fields-container').appendChild(template);
136
+ });
137
+
138
+ // Handle the "Apply Search" button click inside the modal
139
+ $('#applyAdvanceSearch').on('click', function() {
140
+ var searchFields = $('.search-field');
141
+ var searchLabelsContainer = $('#search-labels-container');
142
+ searchLabelsContainer.empty();
143
+
144
+ var table = $('#payments-table').DataTable();
145
+ table.on('preXhr.dt', function(e, settings, data) {
146
+ data.search.value = searchQuery("<%= @search_query.to_s %>");
147
+ });
148
+
149
+ table.ajax.url("<%= payments_pagination_path(:ordering => @ordering, :format => :json) %>").load();
150
+
151
+ // Update the URL with the search parameters
152
+ var searchParams = searchQuery("<%= @search_query.to_s %>");
153
+ if (searchParams) {
154
+ searchParams = searchParams.replace(/account_id/g, 'ac_id');
155
+ var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + searchParams;
156
+ window.history.pushState({ path: newUrl }, '', newUrl);
157
+ }
158
+
159
+ searchFields.each(function() {
160
+ var filter = $(this).find('.search-field-filter option:selected').text();
161
+ var value = $(this).find('.search-field-value').val();
162
+ var columnName = $(this).find('.search-field-filter').attr('name').replace('Filter', '');
163
+
164
+ // Create and append the search label
165
+ if (value !== '') {
166
+ var label = $('<span>', {
167
+ class: 'label label-info',
168
+ text: columnName + ' [' + filter + '] ' + value
169
+ });
170
+ }
171
+ searchLabelsContainer.append(label);
172
+ });
173
+ $('#advanceSearchModal').modal('hide');
174
+ });
175
+
176
+ // Populate the modal with the current filters when it is shown
177
+ $('#advanceSearchModal').on('show.bs.modal', function() {
178
+ showAdvanceSearchModal();
179
+ });
180
+
181
+ $('#clearAdvanceSearch').on('click', function() {
182
+ clearAdvanceSearch();
183
+ });
184
+
185
+ // Handle the remove icon click event to remove search fields
186
+ $('#search-fields-container').on('click', '#remove-search-field', function() {
187
+ $(this).closest('.search-field').remove();
188
+ });
189
+ });
190
+ <% end %>
@@ -57,7 +57,7 @@ $(document).ready(function() {
57
57
  "pageLength": <%= @limit %>,
58
58
  "displayStart": <%= @offset %>,
59
59
  "ajax": {
60
- url: "<%= payments_pagination_path(:ordering => @ordering, :format => :json) %>",
60
+ url: "<%= payments_pagination_path(:ordering => @ordering, :format => :json, :advance_search_query => @advance_search_query) %>",
61
61
  dataSrc: function(json) {
62
62
  var colOrder = $('#payments-table').DataTable().colReorder.order();
63
63
  var reorderedData = json.data.map(function(row) {
@@ -75,7 +75,10 @@ $(document).ready(function() {
75
75
  "dom": "t",
76
76
  "paging": false,
77
77
  "ajax": {
78
- url: "<%= payments_pagination_path(:format => :json) %>",
78
+ url: "<%= payments_pagination_path(:format => :json, :advance_search_query => @advance_search_query) %>",
79
+ data: function(d) {
80
+ d.colum_order = $('#payments-table').DataTable().colReorder.order();
81
+ },
79
82
  dataSrc: function(json) {
80
83
  var colOrder = $('#payments-table').DataTable().colReorder.order();
81
84
  var reorderedData = json.data.map(function(row) {
@@ -100,14 +103,15 @@ $(document).ready(function() {
100
103
  });
101
104
 
102
105
  <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
103
- <% if @max_nb_records.nil? %>
104
- $('#payments-table').on('draw.dt', function() {
106
+ $('#payments-table').on('draw.dt', function() {
107
+ <% if @max_nb_records.nil? %>
105
108
  var noMoreData = table.column(0)
106
109
  .data()
107
110
  .length == 0;
108
111
  $(".next.paginate_button").toggleClass("disabled", noMoreData);
109
112
  $(".dataTables_info").toggle(!noMoreData);
110
- });
111
- <% end %>
113
+ <% end %>
114
+ populateSearchLabelsFromUrl();
115
+ });
112
116
  });
113
117
  <% end %>
data/lib/kaui/engine.rb CHANGED
@@ -14,7 +14,6 @@ require 'bootstrap-datepicker-rails'
14
14
  require 'json'
15
15
  require 'money-rails'
16
16
  require 'killbill_client'
17
- require 'kenui'
18
17
  require 'devise'
19
18
  require 'cancan'
20
19
  require 'country_select'
data/lib/kaui/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kaui
4
- VERSION = '3.0.5'
4
+ VERSION = '3.0.7'
5
5
  end
data/lib/kaui.rb CHANGED
@@ -142,8 +142,10 @@ module Kaui
142
142
  invoice&.send(attr.downcase)
143
143
  end
144
144
  end
145
- # Add additional values if needed
146
- [headers, values]
145
+
146
+ raw_data = fields.map { |attr| invoice&.send(attr.downcase) }
147
+
148
+ [headers, values, raw_data]
147
149
  end
148
150
 
149
151
  self.account_payments_columns = lambda do |account = nil, payment = nil, view_context = nil|
@@ -177,8 +179,17 @@ module Kaui
177
179
  end
178
180
  end
179
181
 
182
+ raw_data = fields.map do |attr|
183
+ case attr
184
+ when 'status'
185
+ payment.transactions.empty? ? nil : payment.transactions[-1].status
186
+ else
187
+ payment&.send(attr.downcase)
188
+ end
189
+ end
190
+
180
191
  # Add additional values if needed
181
- [headers, values]
192
+ [headers, values, raw_data]
182
193
  end
183
194
 
184
195
  self.account_audit_logs_columns = lambda do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaui
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-22 00:00:00.000000000 Z
11
+ date: 2025-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -150,20 +150,6 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: kenui
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :runtime
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: killbill-assets-ui
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -321,6 +307,7 @@ files:
321
307
  - app/assets/javascripts/application.js
322
308
  - app/assets/javascripts/kaui/kaui.js
323
309
  - app/assets/javascripts/kaui/kaui_override.js
310
+ - app/assets/javascripts/kaui/multi_functions_bar_utils.js
324
311
  - app/assets/stylesheets/application.css
325
312
  - app/assets/stylesheets/kaui/account.css
326
313
  - app/assets/stylesheets/kaui/audit.css
@@ -424,6 +411,7 @@ files:
424
411
  - app/models/kaui/transaction.rb
425
412
  - app/models/kaui/user.rb
426
413
  - app/models/kaui/user_role.rb
414
+ - app/services/dependencies/kenui.rb
427
415
  - app/views/kaui/account_children/index.html.erb
428
416
  - app/views/kaui/account_custom_fields/index.html.erb
429
417
  - app/views/kaui/account_emails/_account_emails_table.html.erb
@@ -435,6 +423,7 @@ files:
435
423
  - app/views/kaui/account_tags/index.html.erb
436
424
  - app/views/kaui/account_timelines/_multi_functions_bar.html.erb
437
425
  - app/views/kaui/account_timelines/show.html.erb
426
+ - app/views/kaui/accounts/_account_filterbar.html.erb
438
427
  - app/views/kaui/accounts/_account_info.html.erb
439
428
  - app/views/kaui/accounts/_billing_info.html.erb
440
429
  - app/views/kaui/accounts/_close_account_modal.html.erb
@@ -502,6 +491,7 @@ files:
502
491
  - app/views/kaui/invoice_tags/_form.html.erb
503
492
  - app/views/kaui/invoice_tags/_form_bar.html.erb
504
493
  - app/views/kaui/invoice_tags/edit.html.erb
494
+ - app/views/kaui/invoices/_invoice_filterbar.html.erb
505
495
  - app/views/kaui/invoices/_invoice_table.html.erb
506
496
  - app/views/kaui/invoices/_multi_functions_bar.html.erb
507
497
  - app/views/kaui/invoices/index.html.erb
@@ -520,6 +510,7 @@ files:
520
510
  - app/views/kaui/payment_methods/new.html.erb
521
511
  - app/views/kaui/payments/_form.html.erb
522
512
  - app/views/kaui/payments/_multi_functions_bar.html.erb
513
+ - app/views/kaui/payments/_payment_filterbar.html.erb
523
514
  - app/views/kaui/payments/_payment_table.html.erb
524
515
  - app/views/kaui/payments/index.html.erb
525
516
  - app/views/kaui/payments/new.html.erb