kaui 4.0.11 → 4.0.13
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 +21 -0
- data/app/assets/stylesheets/kaui/subscription.css +75 -0
- data/app/assets/stylesheets/kaui/tags.css +6 -3
- data/app/controllers/kaui/account_timelines_controller.rb +3 -3
- data/app/controllers/kaui/accounts_controller.rb +52 -52
- data/app/controllers/kaui/admin_allowed_users_controller.rb +29 -29
- data/app/controllers/kaui/admin_controller.rb +2 -2
- data/app/controllers/kaui/admin_tenants_controller.rb +89 -81
- data/app/controllers/kaui/audit_logs_controller.rb +1 -1
- data/app/controllers/kaui/bundles_controller.rb +53 -5
- data/app/controllers/kaui/chargebacks_controller.rb +1 -1
- data/app/controllers/kaui/charges_controller.rb +5 -2
- data/app/controllers/kaui/credits_controller.rb +1 -1
- data/app/controllers/kaui/custom_fields_controller.rb +11 -11
- data/app/controllers/kaui/engine_controller_util.rb +5 -5
- data/app/controllers/kaui/home_controller.rb +6 -2
- data/app/controllers/kaui/invoices_controller.rb +6 -4
- data/app/controllers/kaui/payment_methods_controller.rb +5 -5
- data/app/controllers/kaui/payments_controller.rb +19 -19
- data/app/controllers/kaui/queues_controller.rb +6 -6
- data/app/controllers/kaui/registrations_controller.rb +1 -1
- data/app/controllers/kaui/role_definitions_controller.rb +2 -2
- data/app/controllers/kaui/sessions_controller.rb +1 -1
- data/app/controllers/kaui/subscriptions_controller.rb +15 -14
- data/app/controllers/kaui/tag_definitions_controller.rb +1 -1
- data/app/controllers/kaui/tenants_controller.rb +2 -2
- data/app/controllers/kaui/transactions_controller.rb +6 -6
- data/app/helpers/kaui/account_helper.rb +9 -7
- data/app/helpers/kaui/exception_helper.rb +7 -5
- data/app/helpers/kaui/payment_helper.rb +2 -9
- data/app/helpers/kaui/plugin_helper.rb +3 -5
- data/app/helpers/kaui/subscription_helper.rb +46 -30
- data/app/helpers/kaui/uuid_helper.rb +1 -1
- data/app/models/kaui/account.rb +4 -3
- data/app/models/kaui/admin_tenant.rb +2 -2
- data/app/models/kaui/allowed_user.rb +3 -1
- data/app/models/kaui/allowed_user_tenant.rb +2 -2
- data/app/models/kaui/audit_log.rb +1 -1
- data/app/models/kaui/bundle.rb +11 -5
- data/app/models/kaui/invoice.rb +1 -1
- data/app/models/kaui/invoice_payment.rb +2 -2
- data/app/models/kaui/killbill_authenticatable.rb +2 -39
- data/app/models/kaui/killbill_registerable.rb +3 -11
- data/app/models/kaui/overdue.rb +5 -2
- data/app/models/kaui/payment.rb +1 -1
- data/app/models/kaui/payment_state.rb +3 -1
- data/app/models/kaui/rails_methods.rb +2 -2
- data/app/models/kaui/tag_definition.rb +2 -2
- data/app/models/kaui/tenant.rb +2 -1
- data/app/models/kaui/transaction.rb +1 -1
- data/app/services/dependencies/kenui.rb +1 -1
- data/app/views/kaui/accounts/_account_details.html.erb +1 -1
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +25 -1
- data/app/views/kaui/bundles/_bundle_filterbar.html.erb +119 -0
- data/app/views/kaui/bundles/index.html.erb +28 -3
- data/app/views/kaui/components/search_input/_search_input.html.erb +39 -1
- data/app/views/kaui/invoices/index.html.erb +15 -11
- data/app/views/kaui/refunds/_form.html.erb +3 -11
- data/app/views/kaui/subscriptions/_form.html.erb +7 -1
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +12 -1
- data/config/routes.rb +79 -79
- data/lib/devise/models/killbill_authenticatable.rb +38 -0
- data/lib/devise/models/killbill_registerable.rb +9 -0
- data/lib/generators/kaui/install/install_generator.rb +1 -4
- data/lib/kaui/version.rb +1 -1
- data/lib/kaui.rb +7 -7
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62d467e5b936f1738863675c8f5747e9ea4187ac28670556e09d857b1921d588
|
|
4
|
+
data.tar.gz: c79e0a54c96cb563b1eaf7129f147240fd8da04e784a284f7390c39a7b5ac587
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6ff3a1e16012a78cfed10bfaf51ce9733f22d9ebf624d539cdf03cf3a8d7f8dcbda547022dc9258334ae9411c32a0261a7a81b40b19000218a0142950297198
|
|
7
|
+
data.tar.gz: fa4d96b4ccb3afea63726fa9d6a2c2e0f5c853ce8ce5e5acf518c839ab0487fd9c5952ccf33d0b21307b3703ac48b917c15e486061628fb8462091280fb8d21c
|
|
@@ -302,6 +302,27 @@ jQuery(document).ready(function ($) {
|
|
|
302
302
|
|
|
303
303
|
setObjectIdPopover();
|
|
304
304
|
setObjectIdTooltip();
|
|
305
|
+
|
|
306
|
+
/*
|
|
307
|
+
* Tag dropdown overflow prevention
|
|
308
|
+
* Flips each .tag-select-box to open leftward when it would overflow the right edge of the viewport.
|
|
309
|
+
*/
|
|
310
|
+
function repositionTagDropdowns() {
|
|
311
|
+
$('.tag-select').each(function() {
|
|
312
|
+
var $box = $(this).find('.tag-select-box');
|
|
313
|
+
var triggerRight = $(this).offset().left + $(this).outerWidth();
|
|
314
|
+
var boxWidth = Math.max($box[0].scrollWidth, 240);
|
|
315
|
+
var viewportWidth = $(window).width();
|
|
316
|
+
if (triggerRight + boxWidth > viewportWidth) {
|
|
317
|
+
$box.css({ left: 'auto', right: '0' });
|
|
318
|
+
} else {
|
|
319
|
+
$box.css({ left: '0', right: 'auto' });
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
repositionTagDropdowns();
|
|
325
|
+
$(window).on('resize', repositionTagDropdowns);
|
|
305
326
|
});
|
|
306
327
|
|
|
307
328
|
|
|
@@ -689,4 +689,79 @@ table tr.expired td {
|
|
|
689
689
|
line-height: 1.25rem;
|
|
690
690
|
color: #414651;
|
|
691
691
|
margin-bottom: 0.25rem;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/* Advance Search modal – Subscription Bundles page */
|
|
695
|
+
.subscription-bundl-index .close-button {
|
|
696
|
+
background: transparent;
|
|
697
|
+
padding: 0;
|
|
698
|
+
margin-top: -1.25rem;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.subscription-bundl-index .close-button:hover {
|
|
702
|
+
background: transparent;
|
|
703
|
+
padding: 0;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.subscription-bundl-index .border-button {
|
|
707
|
+
background: transparent;
|
|
708
|
+
display: inline-flex;
|
|
709
|
+
justify-content: center;
|
|
710
|
+
align-items: center;
|
|
711
|
+
border: 0.0625rem solid #D5D7DA;
|
|
712
|
+
border-radius: 0.375rem;
|
|
713
|
+
width: 2.5rem;
|
|
714
|
+
height: 2.5rem;
|
|
715
|
+
padding: 0.625rem;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.subscription-bundl-index .border-button:hover {
|
|
719
|
+
background: transparent;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
.subscription-bundl-index .button {
|
|
723
|
+
background: transparent;
|
|
724
|
+
display: inline-flex;
|
|
725
|
+
justify-content: center;
|
|
726
|
+
align-items: center;
|
|
727
|
+
width: 2.5rem;
|
|
728
|
+
height: 2.5rem;
|
|
729
|
+
padding: 0.625rem;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.subscription-bundl-index .button:hover {
|
|
733
|
+
background: transparent;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.subscription-bundl-index .field-label {
|
|
737
|
+
font-weight: 500;
|
|
738
|
+
font-size: 0.875rem;
|
|
739
|
+
line-height: 1.25rem;
|
|
740
|
+
color: #414651;
|
|
741
|
+
margin-top: -1.25rem;
|
|
742
|
+
min-width: 9.59375rem;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
.subscription-bundl-index .search-field-label {
|
|
746
|
+
margin-top: -1.25rem;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
.subscription-bundl-index .form-group.row.align-items-center {
|
|
750
|
+
display: flex;
|
|
751
|
+
align-items: center;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
.subscription-bundl-index .form-group.row.align-items-center label {
|
|
755
|
+
margin-bottom: 0;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
.subscription-bundl-index .form-group.row.align-items-center .form-control {
|
|
759
|
+
margin-right: 0.25rem;
|
|
760
|
+
height: 2.5rem;
|
|
761
|
+
border-radius: 0.375rem;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
.subscription-bundl-index .form-group.row.align-items-center.search-field div {
|
|
765
|
+
padding: 0;
|
|
766
|
+
margin-right: 0.25rem;
|
|
692
767
|
}
|
|
@@ -58,15 +58,18 @@
|
|
|
58
58
|
.tag-bar .tag-select .tag-select-box {
|
|
59
59
|
position: absolute;
|
|
60
60
|
top: 100%;
|
|
61
|
-
left:
|
|
61
|
+
left: 0;
|
|
62
|
+
right: auto;
|
|
62
63
|
max-height: 0;
|
|
63
64
|
background-color: #fff;
|
|
64
65
|
z-index: 100;
|
|
65
66
|
padding: 0 0.9375rem;
|
|
66
67
|
font-size: 0.75rem;
|
|
67
68
|
color: #999999;
|
|
68
|
-
overflow:
|
|
69
|
-
width:
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
min-width: 15rem;
|
|
71
|
+
width: max-content;
|
|
72
|
+
max-width: min(25rem, 95vw);
|
|
70
73
|
border-bottom: 0;
|
|
71
74
|
display: inline-block;
|
|
72
75
|
}
|
|
@@ -76,7 +76,7 @@ module Kaui
|
|
|
76
76
|
if %w[INVOICE ALL].include?(event_type)
|
|
77
77
|
@invoices.each do |invoice_stub|
|
|
78
78
|
invoice = invoice_stub.invoice_id.present? && @invoices_by_id.key?(invoice_stub.invoice_id) ? @invoices_by_id[invoice_stub.invoice_id] : invoice_stub
|
|
79
|
-
target_date = invoice.target_date.
|
|
79
|
+
target_date = invoice.target_date.presence || '[unknown]'
|
|
80
80
|
bundle_keys = invoice_stub.bundle_keys.present? ? invoice_stub.bundle_keys.split(',').map { |bundle_key| @bundle_names[bundle_key] }.join(', ') : ''
|
|
81
81
|
invoice_details = []
|
|
82
82
|
invoice_details << "Amount: #{invoice.amount_to_money} (#{@account.currency})"
|
|
@@ -133,7 +133,7 @@ module Kaui
|
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
-
send_data csv_string, filename: "account-timelines-#{
|
|
136
|
+
send_data csv_string, filename: "account-timelines-#{Time.zone.today}.csv", type: 'text/csv'
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
private
|
|
@@ -154,7 +154,7 @@ module Kaui
|
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
def extract_invoices_by_id(all_invoices)
|
|
157
|
-
return {} if all_invoices.
|
|
157
|
+
return {} if all_invoices.blank?
|
|
158
158
|
|
|
159
159
|
# Convert into Kaui::Invoice to benefit from additional methods xxx_to_money
|
|
160
160
|
@invoices_by_id = all_invoices.to_h do |invoice|
|
|
@@ -5,7 +5,7 @@ module Kaui
|
|
|
5
5
|
class AccountsController < Kaui::EngineController
|
|
6
6
|
def index
|
|
7
7
|
@search_query = params[:q]
|
|
8
|
-
@advance_search_query = @search_query ||
|
|
8
|
+
@advance_search_query = @search_query.presence || params[:advance_search_query].presence
|
|
9
9
|
if @search_query.present?
|
|
10
10
|
account = Kaui::Account.list_or_search(@search_query, -1, 1, options_for_klient).first
|
|
11
11
|
if account.nil?
|
|
@@ -57,7 +57,7 @@ module Kaui
|
|
|
57
57
|
query_string = params[:search]
|
|
58
58
|
|
|
59
59
|
if all_fields_checked
|
|
60
|
-
columns = KillBillClient::Model::AccountAttributes.instance_variable_get(
|
|
60
|
+
columns = KillBillClient::Model::AccountAttributes.instance_variable_get(:@json_attributes)
|
|
61
61
|
csv_headers = columns.dup
|
|
62
62
|
Kaui::Account::REMAPPING_FIELDS.each do |k, v|
|
|
63
63
|
index = csv_headers.index(k)
|
|
@@ -97,36 +97,7 @@ module Kaui
|
|
|
97
97
|
csv << data
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
|
-
send_data csv_string, filename: "accounts-#{
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def new
|
|
104
|
-
@account = Kaui::Account.new
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def create
|
|
108
|
-
@account = Kaui::Account.new(params.require(:account).delete_if { |_key, value| value.blank? })
|
|
109
|
-
|
|
110
|
-
@account.errors.add(:phone, :invalid_phone) if !@account.phone.nil? && !@account.check_account_details_phone?
|
|
111
|
-
|
|
112
|
-
@account.errors.add(:check_account_details_bill_cycle_day_local, :invalid_bill_cycle_day_local) if !@account.bill_cycle_day_local.nil? && !@account.check_account_details_bill_cycle_day_local?
|
|
113
|
-
|
|
114
|
-
unless @account.errors.empty?
|
|
115
|
-
flash.now[:errors] = @account.errors.messages.values.flatten
|
|
116
|
-
render action: :new and return
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# Transform "1" into boolean
|
|
120
|
-
@account.is_migrated = @account.is_migrated == '1'
|
|
121
|
-
|
|
122
|
-
begin
|
|
123
|
-
@account = @account.create(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
|
124
|
-
|
|
125
|
-
redirect_to account_path(@account.account_id), notice: 'Account was successfully created'
|
|
126
|
-
rescue StandardError => e
|
|
127
|
-
flash.now[:error] = "Error while creating account: #{as_string(e)}"
|
|
128
|
-
render action: :new
|
|
129
|
-
end
|
|
100
|
+
send_data csv_string, filename: "accounts-#{Time.zone.today}.csv", type: 'text/csv'
|
|
130
101
|
end
|
|
131
102
|
|
|
132
103
|
# rubocop:disable Style/MultilineBlockChain
|
|
@@ -140,7 +111,7 @@ module Kaui
|
|
|
140
111
|
fetch_children = promise { @account.children(false, false, 'NONE', cached_options_for_klient) }
|
|
141
112
|
fetch_parent = @account.parent_account_id.nil? ? nil : promise { Kaui::Account.find_by_id(@account.parent_account_id, false, false, cached_options_for_klient) }
|
|
142
113
|
fetch_overdue_state = promise { @account.overdue(cached_options_for_klient) }
|
|
143
|
-
fetch_account_tags = promise { @account.tags(false, 'NONE', cached_options_for_klient).sort
|
|
114
|
+
fetch_account_tags = promise { @account.tags(false, 'NONE', cached_options_for_klient).sort }
|
|
144
115
|
fetch_account_fields = promise { @account.custom_fields('NONE', cached_options_for_klient).sort { |cf_a, cf_b| cf_a.name.downcase <=> cf_b.name.downcase } }
|
|
145
116
|
fetch_account_emails = promise { Kaui::AccountEmail.find_all_sorted_by_account_id(@account.account_id, 'NONE', cached_options_for_klient) }
|
|
146
117
|
fetch_payments = promise { @account.payments(cached_options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_payment(payment) } }
|
|
@@ -180,7 +151,7 @@ module Kaui
|
|
|
180
151
|
@custom_fields = wait(fetch_account_fields)
|
|
181
152
|
@account_emails = wait(fetch_account_emails)
|
|
182
153
|
wait(fetch_payment_methods)
|
|
183
|
-
@payment_methods = wait(fetch_payment_methods_with_details).
|
|
154
|
+
@payment_methods = wait(fetch_payment_methods_with_details).filter_map { |pm_f| wait(pm_f) }
|
|
184
155
|
@available_tags = wait(fetch_available_tags)
|
|
185
156
|
@children = wait(fetch_children)
|
|
186
157
|
@account_parent = @account.parent_account_id.nil? ? nil : wait(fetch_parent)
|
|
@@ -198,6 +169,52 @@ module Kaui
|
|
|
198
169
|
|
|
199
170
|
params.permit!
|
|
200
171
|
end
|
|
172
|
+
|
|
173
|
+
def new
|
|
174
|
+
@account = Kaui::Account.new
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def edit; end
|
|
178
|
+
|
|
179
|
+
def create
|
|
180
|
+
@account = Kaui::Account.new(params.require(:account).permit!.to_h.compact_blank)
|
|
181
|
+
|
|
182
|
+
@account.errors.add(:phone, :invalid_phone) if !@account.phone.nil? && !@account.check_account_details_phone?
|
|
183
|
+
|
|
184
|
+
@account.errors.add(:check_account_details_bill_cycle_day_local, :invalid_bill_cycle_day_local) if !@account.bill_cycle_day_local.nil? && !@account.check_account_details_bill_cycle_day_local?
|
|
185
|
+
|
|
186
|
+
unless @account.errors.empty?
|
|
187
|
+
flash.now[:errors] = @account.errors.messages.values.flatten
|
|
188
|
+
render action: :new and return
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Transform "1" into boolean
|
|
192
|
+
@account.is_migrated = @account.is_migrated == '1'
|
|
193
|
+
|
|
194
|
+
begin
|
|
195
|
+
@account = @account.create(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
|
196
|
+
|
|
197
|
+
redirect_to account_path(@account.account_id), notice: 'Account was successfully created'
|
|
198
|
+
rescue StandardError => e
|
|
199
|
+
flash.now[:error] = "Error while creating account: #{as_string(e)}"
|
|
200
|
+
render action: :new
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def update
|
|
205
|
+
@account = Kaui::Account.new(params.require(:account).permit!.to_h.compact_blank)
|
|
206
|
+
@account.account_id = params.require(:account_id)
|
|
207
|
+
|
|
208
|
+
# Transform "1" into boolean
|
|
209
|
+
@account.is_migrated = @account.is_migrated == '1'
|
|
210
|
+
|
|
211
|
+
@account.update(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
|
212
|
+
|
|
213
|
+
redirect_to account_path(@account.account_id), notice: 'Account successfully updated'
|
|
214
|
+
rescue StandardError => e
|
|
215
|
+
flash.now[:error] = "Error while updating account: #{as_string(e)}"
|
|
216
|
+
render action: :edit
|
|
217
|
+
end
|
|
201
218
|
# rubocop:enable Style/MultilineBlockChain
|
|
202
219
|
|
|
203
220
|
def destroy
|
|
@@ -261,23 +278,6 @@ module Kaui
|
|
|
261
278
|
end
|
|
262
279
|
end
|
|
263
280
|
|
|
264
|
-
def edit; end
|
|
265
|
-
|
|
266
|
-
def update
|
|
267
|
-
@account = Kaui::Account.new(params.require(:account).delete_if { |_key, value| value.blank? })
|
|
268
|
-
@account.account_id = params.require(:account_id)
|
|
269
|
-
|
|
270
|
-
# Transform "1" into boolean
|
|
271
|
-
@account.is_migrated = @account.is_migrated == '1'
|
|
272
|
-
|
|
273
|
-
@account.update(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
|
274
|
-
|
|
275
|
-
redirect_to account_path(@account.account_id), notice: 'Account successfully updated'
|
|
276
|
-
rescue StandardError => e
|
|
277
|
-
flash.now[:error] = "Error while updating account: #{as_string(e)}"
|
|
278
|
-
render action: :edit
|
|
279
|
-
end
|
|
280
|
-
|
|
281
281
|
def set_default_payment_method
|
|
282
282
|
account_id = params.require(:account_id)
|
|
283
283
|
payment_method_id = params.require(:payment_method_id)
|
|
@@ -309,7 +309,7 @@ module Kaui
|
|
|
309
309
|
end
|
|
310
310
|
|
|
311
311
|
def link_to_parent
|
|
312
|
-
@account = Kaui::Account.new(params.require(:account).
|
|
312
|
+
@account = Kaui::Account.new(params.require(:account).permit!.to_h.compact_blank)
|
|
313
313
|
@account.account_id = params.require(:account_id)
|
|
314
314
|
@account.is_payment_delegated_to_parent = @account.is_payment_delegated_to_parent == '1'
|
|
315
315
|
|
|
@@ -12,26 +12,50 @@ module Kaui
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def show
|
|
16
|
+
@allowed_user = Kaui::AllowedUser.find(params.require(:id))
|
|
17
|
+
raise ActiveRecord::RecordNotFound, "Could not find user #{@allowed_user.id}" unless current_user.root? || @allowed_user.kb_username == current_user.kb_username
|
|
18
|
+
|
|
19
|
+
@roles = roles_for_user(@allowed_user)
|
|
20
|
+
|
|
21
|
+
tenants_for_current_user = retrieve_tenants_for_current_user
|
|
22
|
+
@tenants = Kaui::Tenant.all.select { |tenant| tenants_for_current_user.include?(tenant.kb_tenant_id) }
|
|
23
|
+
end
|
|
24
|
+
|
|
15
25
|
def new
|
|
16
26
|
@allowed_user = Kaui::AllowedUser.new
|
|
17
27
|
@is_killbill_managed = true
|
|
18
28
|
@roles = []
|
|
19
29
|
|
|
20
30
|
# Restore form state if returning from role creation
|
|
21
|
-
return
|
|
31
|
+
return if params[:user_context].blank?
|
|
22
32
|
|
|
23
33
|
context = params[:user_context]
|
|
24
34
|
@allowed_user.kb_username = context[:kb_username]
|
|
25
35
|
@allowed_user.description = context[:description]
|
|
26
|
-
@roles = context[:roles].to_s.split(',').
|
|
36
|
+
@roles = context[:roles].to_s.split(',').compact_blank
|
|
27
37
|
@external_checked = context[:external] == '1'
|
|
28
38
|
end
|
|
29
39
|
|
|
40
|
+
def edit
|
|
41
|
+
@allowed_user = Kaui::AllowedUser.find(params.require(:id))
|
|
42
|
+
@is_killbill_managed = killbill_managed?(@allowed_user, options_for_klient)
|
|
43
|
+
|
|
44
|
+
# Use roles from context if returning from role creation, otherwise fetch from KB
|
|
45
|
+
if params[:user_context].present?
|
|
46
|
+
context = params[:user_context]
|
|
47
|
+
@roles = context[:roles].to_s.split(',').compact_blank
|
|
48
|
+
@allowed_user.description = context[:description] if context[:description].present?
|
|
49
|
+
else
|
|
50
|
+
@roles = roles_for_user(@allowed_user)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
30
54
|
def create
|
|
31
55
|
@is_killbill_managed = nil
|
|
32
56
|
@allowed_user = Kaui::AllowedUser.new(allowed_user_params)
|
|
33
57
|
|
|
34
|
-
existing_user = Kaui::AllowedUser.
|
|
58
|
+
existing_user = Kaui::AllowedUser.find_by(kb_username: @allowed_user.kb_username)
|
|
35
59
|
if existing_user.blank?
|
|
36
60
|
if params[:external] == '1'
|
|
37
61
|
# Create locally only
|
|
@@ -53,37 +77,13 @@ module Kaui
|
|
|
53
77
|
end
|
|
54
78
|
end
|
|
55
79
|
|
|
56
|
-
def show
|
|
57
|
-
@allowed_user = Kaui::AllowedUser.find(params.require(:id))
|
|
58
|
-
raise ActiveRecord::RecordNotFound, "Could not find user #{@allowed_user.id}" unless current_user.root? || @allowed_user.kb_username == current_user.kb_username
|
|
59
|
-
|
|
60
|
-
@roles = roles_for_user(@allowed_user)
|
|
61
|
-
|
|
62
|
-
tenants_for_current_user = retrieve_tenants_for_current_user
|
|
63
|
-
@tenants = Kaui::Tenant.all.select { |tenant| tenants_for_current_user.include?(tenant.kb_tenant_id) }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def edit
|
|
67
|
-
@allowed_user = Kaui::AllowedUser.find(params.require(:id))
|
|
68
|
-
@is_killbill_managed = killbill_managed?(@allowed_user, options_for_klient)
|
|
69
|
-
|
|
70
|
-
# Use roles from context if returning from role creation, otherwise fetch from KB
|
|
71
|
-
if params[:user_context].present?
|
|
72
|
-
context = params[:user_context]
|
|
73
|
-
@roles = context[:roles].to_s.split(',').reject(&:blank?)
|
|
74
|
-
@allowed_user.description = context[:description] if context[:description].present?
|
|
75
|
-
else
|
|
76
|
-
@roles = roles_for_user(@allowed_user)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
80
|
def update
|
|
81
81
|
@allowed_user = Kaui::AllowedUser.find(params.require(:id))
|
|
82
82
|
|
|
83
83
|
@allowed_user.description = params[:allowed_user][:description].presence
|
|
84
84
|
|
|
85
85
|
@allowed_user.update_in_kb!(params[:password].presence,
|
|
86
|
-
params[:roles].
|
|
86
|
+
params[:roles].presence&.split(','),
|
|
87
87
|
current_user.kb_username,
|
|
88
88
|
params[:reason],
|
|
89
89
|
params[:comment],
|
|
@@ -149,7 +149,7 @@ module Kaui
|
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
def roles_for_user(allowed_user)
|
|
152
|
-
Kaui::UserRole.find_roles_by_username(allowed_user.kb_username, options_for_klient).
|
|
152
|
+
Kaui::UserRole.find_roles_by_username(allowed_user.kb_username, options_for_klient).filter_map(&:presence)
|
|
153
153
|
rescue StandardError
|
|
154
154
|
[]
|
|
155
155
|
end
|
|
@@ -23,10 +23,10 @@ module Kaui
|
|
|
23
23
|
def set_clock
|
|
24
24
|
if params[:commit] == 'Submit'
|
|
25
25
|
date = Date.parse(params[:new_date]).strftime('%Y-%m-%d')
|
|
26
|
-
msg = I18n.
|
|
26
|
+
msg = I18n.t('flashes.notices.clock_updated_successfully', new_date: date)
|
|
27
27
|
else
|
|
28
28
|
date = nil
|
|
29
|
-
msg = I18n.
|
|
29
|
+
msg = I18n.t('flashes.notices.clock_reset_successfully')
|
|
30
30
|
end
|
|
31
31
|
begin
|
|
32
32
|
Kaui::Admin.set_clock(date, nil, options_for_klient)
|