Skip to content

Commit 4a0ce03

Browse files
authored
Merge pull request #603 from killbill/kaui_4.22
Kaui 4.22
2 parents f122d6a + 360bb3a commit 4a0ce03

20 files changed

Lines changed: 137 additions & 51 deletions

app/assets/javascripts/kaui/multi_functions_bar_utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ function clearAdvanceSearch() {
141141
// Remove all search labels
142142
$('#search-labels-container').empty();
143143

144+
// Clear persisted search for this page
145+
localStorage.removeItem('kaui_adv_search_' + window.location.pathname);
146+
144147
// Reload the page with the original URL (no parameters)
145148
window.location.href = window.location.pathname;
146149

@@ -226,8 +229,10 @@ $(document).on('click', '.filter-close-icon', function() {
226229
var pushParams = (searchParams || '').replace(/account_id/g, 'ac_id');
227230
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + pushParams;
228231
window.history.pushState({ path: newUrl }, '', newUrl);
232+
localStorage.setItem('kaui_adv_search_' + window.location.pathname, searchParams);
229233
} else {
230234
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
231235
window.history.pushState({ path: newUrl }, '', newUrl);
236+
localStorage.removeItem('kaui_adv_search_' + window.location.pathname);
232237
}
233238
});

app/assets/stylesheets/kaui/common.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,6 @@ table thead th:last-child {
12931293
align-items: center;
12941294
gap: 0.625rem;
12951295
padding: 0.875rem 1.125rem;
1296-
margin: 0.625rem 0;
12971296
border-radius: 0.375rem;
12981297
font-size: 0.9375rem;
12991298
font-weight: 500;
@@ -1467,6 +1466,10 @@ table thead th:last-child {
14671466
width: 100%;
14681467
}
14691468

1469+
.field_with_errors {
1470+
display: contents;
1471+
}
1472+
14701473
/* Navbar color changes - Higher specificity to override existing rules */
14711474
header .header-icon {
14721475
color: #374151 !important;

app/assets/stylesheets/kaui/subscription.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ table tr.expired td {
691691
margin-bottom: 0.25rem;
692692
}
693693

694-
/* Advance Search modal – Subscription Bundles page */
694+
/* Advanced Search modal – Subscription Bundles page */
695695
.subscription-bundl-index .close-button {
696696
background: transparent;
697697
padding: 0;

app/controllers/kaui/admin_tenants_controller.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,17 @@ def modify_overdue_config
306306
options[:api_key] = current_tenant.api_key
307307
options[:api_secret] = current_tenant.api_secret
308308

309-
view_form_model = params.require(:kill_bill_client_model_overdue).permit!.to_h.compact_blank
309+
overdue_params = params[:kill_bill_client_model_overdue]&.permit!
310+
view_form_model = overdue_params&.to_h&.compact_blank || {}
310311
view_form_model['states'] = view_form_model['states'].values if view_form_model['states'].present?
311-
312-
overdue = Kaui::Overdue.from_overdue_form_model(view_form_model)
313-
Kaui::Overdue.upload_tenant_overdue_config_json(overdue.to_json, options[:username], nil, comment, options)
314-
redirect_to admin_tenant_path(current_tenant.id, active_tab: 'OverdueShow'), notice: I18n.t('flashes.notices.overdue_added_successfully')
312+
if view_form_model['states'].blank?
313+
Kaui::AdminTenant.delete_tenant_user_key_value('OVERDUE_CONFIG', options[:username], nil, comment, options)
314+
redirect_to admin_tenant_path(current_tenant.id, active_tab: 'OverdueShow'), notice: I18n.t('flashes.notices.overdue_updated_successfully')
315+
else
316+
overdue = Kaui::Overdue.from_overdue_form_model(view_form_model)
317+
Kaui::Overdue.upload_tenant_overdue_config_json(overdue.to_json, options[:username], nil, comment, options)
318+
redirect_to admin_tenant_path(current_tenant.id, active_tab: 'OverdueShow'), notice: I18n.t('flashes.notices.overdue_added_successfully')
319+
end
315320
end
316321

317322
def upload_overdue_config

app/views/kaui/accounts/_account_filterbar.html.erb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<span class="icon-container">
77
<%= image_tag("kaui/modal/search.svg", width: 20, height: 20) %>
88
</span>
9-
Advance Search
9+
Advanced Search
1010
</h5>
1111
<button type="button" class="close close-button custom-hover" data-bs-dismiss="modal" aria-label="Close">
1212
<span aria-hidden="true">
@@ -80,6 +80,15 @@
8080

8181
<%= javascript_tag do %>
8282
$(document).ready(function() {
83+
// Restore advanced search from localStorage if no search params in current URL
84+
if (!window.location.search.includes('_q=1')) {
85+
var savedSearch = localStorage.getItem('kaui_adv_search_' + window.location.pathname);
86+
if (savedSearch) {
87+
window.location.replace(window.location.pathname + '?' + savedSearch);
88+
return;
89+
}
90+
}
91+
8392
populateSearchLabelsFromUrl();
8493
var dateFields = ['Created date', 'Updated date', 'Reference time'];
8594
// Handle the "Add" button click to add new search fields
@@ -128,6 +137,7 @@ $(document).ready(function() {
128137
searchParams = searchParams.replace(/account_id/g, 'ac_id');
129138
var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + searchParams;
130139
window.history.pushState({ path: newUrl }, '', newUrl);
140+
localStorage.setItem('kaui_adv_search_' + window.location.pathname, searchParams);
131141
}
132142

133143
searchFields.each(function() {

app/views/kaui/accounts/_form_account.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<div class="form-group d-flex pb-3">
118118
<%= f.label :phone, 'Phone', :class => 'col-sm-3 control-label' %>
119119
<div class="col-sm-9">
120-
<%= f.number_field :phone, :class => 'form-control' %>
120+
<%= f.text_field :phone, :class => 'form-control' %>
121121
</div>
122122
</div>
123123
<div class="form-group d-flex pb-3 <%= 'border-bottom mb-3' if @account.persisted? %>">

app/views/kaui/accounts/edit.html.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<div class="register kaui-new-account">
22
<div class="">
33
<div class="mx-auto" style="max-width: 37.5rem;">
4+
<% if @account.errors.any? %>
5+
<div class="custom-alert custom-alert-danger mb-3">
6+
<ul class="mb-0">
7+
<% @account.errors.each do |error| %>
8+
<li><%= error.message %></li>
9+
<% end %>
10+
</ul>
11+
</div>
12+
<% end %>
413
<h5 class="add-account-title">
514
<span class="icon-container">
615
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">

app/views/kaui/accounts/index.html.erb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ $(document).ready(function() {
114114
}
115115
});
116116

117+
// If the page loaded with advanced search params in the URL (e.g. restored from
118+
// localStorage) but @advance_search_query was not set server-side, re-fire the
119+
// DataTable request with the correct filters.
120+
if (window.location.search.includes('_q=1') && '<%= j(@advance_search_query.to_s.strip) %>' === '') {
121+
var urlSearch = window.location.search.substring(1).replace(/ac_id/g, 'account_id');
122+
var ajaxUrl = "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>" + '?' + urlSearch;
123+
table.on('preXhr.dt.filter', function(e, settings, data) {
124+
data.search.value = urlSearch;
125+
});
126+
table.ajax.url(ajaxUrl).load();
127+
}
128+
117129
<!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
118130
$('#accounts-table').on('draw.dt', function() {
119131
<% if @max_nb_records.nil? %>

app/views/kaui/accounts/new.html.erb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
<div class="register kaui-new-account">
22
<div class="">
33
<div class="mx-auto" style="max-width: 37.5rem;">
4+
<% if @account.errors.any? %>
5+
<script>
6+
if (/\/accounts$/.test(window.location.pathname)) {
7+
window.history.replaceState({}, '', window.location.pathname + '/new');
8+
}
9+
</script>
10+
<div class="custom-alert custom-alert-danger mb-3">
11+
<ul class="mb-0">
12+
<% @account.errors.each do |error| %>
13+
<li><%= error.message %></li>
14+
<% end %>
15+
</ul>
16+
</div>
17+
<% end %>
418
<h5 class="add-account-title">
519
<span class="icon-container">
620
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">

app/views/kaui/bundles/_bundle_filterbar.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<span class="icon-container">
77
<%= image_tag("kaui/modal/search.svg", width: 20, height: 20) %>
88
</span>
9-
Advance Search
9+
Advanced Search
1010
</h5>
1111
<button type="button" class="close close-button custom-hover" data-bs-dismiss="modal" aria-label="Close">
1212
<span aria-hidden="true">

0 commit comments

Comments
 (0)