-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8afaf7
commit 56d0eaa
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
module Jubla::Wizards::RegisterNewUserWizard | ||
extend ActiveSupport::Concern | ||
PHONE_NUMBER_LABEL = "Privat" | ||
|
||
prepended do | ||
# attribute :address_care_of, :string | ||
# attribute :street, :string | ||
# attribute :housenumber, :string | ||
|
||
# attribute :postbox, :string | ||
# attribute :zip_code, :string | ||
# attribute :town, :string | ||
# attribute :country, :string | ||
|
||
# attribute :phone_number, :string | ||
# attribute :email, :string | ||
|
||
# validates :email, presence: true | ||
|
||
end | ||
|
||
delegate :person_attributes, to: :new_user_form | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
module Jubla::Wizards::Steps::NewUserForm | ||
extend ActiveSupport::Concern | ||
PHONE_NUMBER_LABEL = "Privat" | ||
|
||
prepended do | ||
attribute :address_care_of, :string | ||
attribute :street, :string | ||
attribute :housenumber, :string | ||
|
||
attribute :postbox, :string | ||
attribute :zip_code, :string | ||
attribute :town, :string | ||
attribute :country, :string | ||
|
||
attribute :phone_number, :string | ||
attribute :email, :string | ||
|
||
validates :email, presence: true | ||
|
||
end | ||
|
||
def initialize(...) | ||
super | ||
|
||
if current_user | ||
self.id = current_user.id | ||
self.gender ||= current_user.gender | ||
self.first_name ||= current_user.first_name | ||
self.last_name ||= current_user.last_name | ||
self.birthday ||= current_user.birthday | ||
self.email ||= current_user.email | ||
self.address_care_of ||= current_user.address_care_of | ||
self.street ||= current_user.street | ||
self.housenumber ||= current_user.housenumber | ||
self.postbox ||= current_user.postbox | ||
self.zip_code ||= current_user.zip_code | ||
self.town ||= current_user.town | ||
self.country ||= current_user.country | ||
self.phone_number ||= current_user.phone_numbers.find_by(label: PHONE_NUMBER_LABEL)&.number | ||
else | ||
self.country ||= Settings.addresses.imported_countries.to_a.first | ||
end | ||
end | ||
|
||
def person_attributes | ||
attributes.compact.symbolize_keys.except(:phone_number).then do |attrs| | ||
next attrs if phone_number.blank? | ||
|
||
attrs.merge(phone_numbers_attributes: [{label: PHONE_NUMBER_LABEL, number: phone_number, id: phone_number_id}.compact]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-# Copyright (c) 2025, Jungwacht Blauring Schweiz. This file is part of | ||
-# hitobito_sac_cas and licensed under the Aformero General Public License version 3 | ||
-# or later. See the COPYING file at the top-level directory or at | ||
-# https://github.com/hitobito/hitobito_sac_cas. | ||
= c.fields_for do |ff| | ||
= ff.labeled_input_fields :first_name, :last_name | ||
- if f.object.new_user_form.support_company? | ||
= ff.labeled_input_fields :company_name | ||
= ff.labeled_boolean_field :company | ||
= render 'contactable/address_fields', f: ff | ||
= ff.labeled_input_field :phone_number | ||
= ff.labeled_input_field :email, help_inline: t('people.email_field.used_as_login'), class: 'd-inline' | ||
|
||
- if f.object.steps.one? | ||
= render 'groups/self_registration/adult_consent_field', f: ff | ||
= field_set_tag(nil, class: 'privacy-policy-fields') do | ||
= render('people/privacy_policy_acceptance_field', f: ff, policy_finder: f.object.policy_finder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters