Skip to content

Commit 8cc7816

Browse files
authored
Add the sub provider field to UI (#1173)
* add the sub provider field to user forms * make the field only visble when needed * have the label be a set name * make the field required when it is shown * make labels default again * final fix
1 parent c24e5dd commit 8cc7816

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

app/controllers/users_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def update_with_sofia_account # rubocop:disable Metrics/AbcSize, Metrics/MethodL
140140
end
141141
authorize @sofia_account
142142

143-
if @user.update(params.require(:user).permit(%i[email] + (current_user.treasurer? ? %i[name deactivated] : []),
143+
if @user.update(params.require(:user).permit(%i[email sub_provider] + (current_user.treasurer? ? %i[name deactivated] : []),
144144
sofia_account_attributes: %i[id username]))
145145
flash[:success] = 'Gegevens gewijzigd'
146146
else
@@ -167,6 +167,6 @@ def find_or_create_user(user_json) # rubocop:disable Metrics/AbcSize, Metrics/Me
167167
end
168168

169169
def permitted_attributes
170-
params.require(:user).permit(%w[name email provider])
170+
params.require(:user).permit(%w[name email provider sub_provider])
171171
end
172172
end

app/views/users/_edit_sofia_account_modal.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<%= f.input :name, label: 'Naam', placeholder: 'Naam', required: true %>
2222
<% end %>
2323
<%= f.input :email, label: 'E-mailadres', placeholder: 'E-mailadres', required: true %>
24+
<% if Rails.application.config.x.subprovider_label.present? %>
25+
<%= f.input :sub_provider, label: 'SubProvider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
26+
<% end %>
2427
<% if current_user.treasurer? %>
2528
<div class="row">
2629
<div class="col-lg-3">

app/views/users/_modal.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<div class="modal-body" id="activities_modal">
1414
<%= f.input :name, label: 'Naam', placeholder: 'Naam', required: true %>
1515
<%= f.input :email, label: 'E-mailadres', placeholder: 'E-mailadres' %>
16+
<% if Rails.application.config.x.subprovider_label.present? %>
17+
<%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
18+
<% end %>
1619
<% if @new_user.persisted? %>
1720
<div class="row">
1821
<div class="col-lg-3">

config/application.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class Application < Rails::Application
7575
config.x.site_short_name = ENV.fetch('SITE_SHORT_NAME', 'SOFIA')
7676
config.x.site_long_name = ENV.fetch('SITE_LONG_NAME', 'Streepsysteem voor de Ordentelijke Festiviteiten van Inleggend Alpha')
7777
config.x.site_association = ENV.fetch('SITE_ASSOCIATION', 'C.S.V. Alpha')
78+
79+
config.x.subprovider_label = ENV.fetch('SUBPROVIDER_LABEL', nil)
7880
config.x.deposit_button_enabled = ENV.fetch('DEPOSIT_BUTTON_ENABLED', 'true') == 'true'
7981

8082
config.x.min_payment_amount = [ENV.fetch('MIN_PAYMENT_AMOUNT', '21.8').to_f, 0.01].max

0 commit comments

Comments
 (0)