mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
ability to edit organization in profile & ablity to link its params from an sso
This commit is contained in:
parent
2afd6ade8a
commit
33358c2fb5
@ -162,6 +162,40 @@
|
||||
<span class="help-block" ng-show="userForm['user[password_confirmation]'].$error.match" translate>{{ 'confirmation_mismatch_with_password' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-show="user.profile.organization" ng-class="{'has-error': userForm['user[profile_attributes][organization_attributes][name]'].$dirty && userForm['user[profile_attributes][organization_attributes][name]'].$invalid}">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-building-o"></i></span>
|
||||
<input type="hidden"
|
||||
name="user[profile_attributes][organization_attributes][id]"
|
||||
ng-value="user.profile.organization.id" />
|
||||
<input type="text"
|
||||
name="user[profile_attributes][organization_attributes][name]"
|
||||
ng-model="user.profile.organization.name"
|
||||
class="form-control"
|
||||
placeholder="{{ 'organization_name' | translate }}"
|
||||
ng-required="user.profile.organization"
|
||||
ng-disabled="preventField['profile.organization_name'] && user.profile.organization.name && !userForm['user[profile_attributes][organization_attributes][name]'].$dirty">
|
||||
</div>
|
||||
<span class="help-block" ng-show="userForm['user[profile_attributes][organization_attributes][name]'].$dirty && userForm['user[profile_attributes][organization_attributes][name]'].$error.required" translate>{{ 'organization_name_is_required' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-show="user.profile.organization" ng-class="{'has-error': userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$invalid}">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-map-marker"></i></span>
|
||||
<input type="hidden"
|
||||
name="user[profile_attributes][organization_attributes][address_attributes][id]"
|
||||
ng-value="user.profile.organization.address.id" />
|
||||
<input type="text"
|
||||
name="user[profile_attributes][organization_attributes][address_attributes][address]"
|
||||
ng-model="user.profile.organization.address.address"
|
||||
class="form-control"
|
||||
placeholder="{{ 'organization_address' | translate }}"
|
||||
ng-required="user.profile.organization"
|
||||
ng-disabled="preventField['profile.organization_address'] && user.profile.organization.address.address && !userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$dirty">
|
||||
</div>
|
||||
<span class="help-block" ng-show="userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[profile_attributes][organization_attributes][address_attributes][address]'].$error.required" translate>{{ 'organization_address_is_required' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-class="{'has-error': userForm['user[profile_attributes][birthday]'].$dirty && userForm['user[profile_attributes][birthday]'].$invalid}">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-calendar-o"></i> </span>
|
||||
|
@ -259,7 +259,7 @@ class API::MembersController < API::ApiController
|
||||
profile_attributes: [:id, :first_name, :last_name, :gender, :birthday, :phone, :interest, :software_mastered, :website, :job,
|
||||
:facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr,
|
||||
user_avatar_attributes: [:id, :attachment, :_destroy], address_attributes: [:id, :address],
|
||||
organization_attributes: [:name, address_attributes: [:id, :address]]])
|
||||
organization_attributes: [:id, :name, address_attributes: [:id, :address]]])
|
||||
|
||||
elsif current_user.is_admin?
|
||||
params.require(:user).permit(:username, :email, :password, :password_confirmation, :invoicing_disabled, :is_allow_contact, :is_allow_newsletter,
|
||||
@ -267,7 +267,7 @@ class API::MembersController < API::ApiController
|
||||
profile_attributes: [:id, :first_name, :last_name, :gender, :birthday, :phone, :interest, :software_mastered, :website, :job,
|
||||
:facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr,
|
||||
user_avatar_attributes: [:id, :attachment, :_destroy], address_attributes: [:id, :address],
|
||||
organization_attributes: [:name, address_attributes: [:id, :address]]])
|
||||
organization_attributes: [:id, :name, address_attributes: [:id, :address]]])
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -246,11 +246,22 @@ class User < ActiveRecord::Base
|
||||
if sso_mapping.to_s.start_with? 'user.'
|
||||
self[sso_mapping[5..-1].to_sym] = data unless data.nil?
|
||||
elsif sso_mapping.to_s.start_with? 'profile.'
|
||||
if sso_mapping.to_s == 'profile.avatar'
|
||||
self.profile.user_avatar ||= UserAvatar.new
|
||||
self.profile.user_avatar.remote_attachment_url = data
|
||||
else
|
||||
self.profile[sso_mapping[8..-1].to_sym] = data unless data.nil?
|
||||
case sso_mapping.to_s
|
||||
when 'profile.avatar'
|
||||
self.profile.user_avatar ||= UserAvatar.new
|
||||
self.profile.user_avatar.remote_attachment_url = data
|
||||
when 'profile.address'
|
||||
self.profile.address ||= Address.new
|
||||
self.profile.address.address = data
|
||||
when 'profile.organization_name'
|
||||
self.profile.organization ||= Organization.new
|
||||
self.profile.organization.name = data
|
||||
when 'profile.organization_address'
|
||||
self.profile.organization ||= Organization.new
|
||||
self.profile.organization.address ||= Address.new
|
||||
self.profile.organization.address.address = data
|
||||
else
|
||||
self.profile[sso_mapping[8..-1].to_sym] = data unless data.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,4 +6,4 @@ sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in
|
||||
confirmation_sent_at unconfirmed_email failed_attempts unlock_token locked_at created_at updated_at stp_customer_id slug
|
||||
provider auth_token merged_at)
|
||||
|
||||
json.profile Profile.column_names - %w(id user_id created_at updated_at) + %w(avatar)
|
||||
json.profile Profile.column_names - %w(id user_id created_at updated_at) + %w(avatar address organization_name organization_address)
|
@ -24,6 +24,15 @@ json.profile do
|
||||
json.website @member.profile.website
|
||||
json.job @member.profile.job
|
||||
json.extract! @member.profile, :facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr
|
||||
json.organization do
|
||||
json.id @member.profile.organization.id
|
||||
json.name @member.profile.organization.name
|
||||
json.address do
|
||||
json.id @member.profile.organization.address.id
|
||||
json.address @member.profile.organization.address.address
|
||||
end
|
||||
end if @member.profile.organization
|
||||
|
||||
end
|
||||
json.subscribed_plan do
|
||||
json.partial! 'api/shared/plan', plan: @member.subscribed_plan
|
||||
|
@ -116,6 +116,8 @@ en:
|
||||
confirmation_of_password_is_required: "Confirmation of password is required."
|
||||
confirmation_of_password_is_too_short_(minimum_8_characters): "Confirmation of password is too short (minimum 8 characters)."
|
||||
confirmation_mismatch_with_password: "Confirmation mismatch with password."
|
||||
organization_name: "Organization name"
|
||||
organization_address: "Organization address"
|
||||
date_of_birth: "Date of birth"
|
||||
date_of_birth_is_required: "Date of birth is required."
|
||||
website: "Website"
|
||||
|
@ -116,6 +116,8 @@ fr:
|
||||
confirmation_of_password_is_required: "La confirmation du mot de passe est requise."
|
||||
confirmation_of_password_is_too_short_(minimum_8_characters): "La confirmation du mot de passe est trop courte (au moins 8 caractères)."
|
||||
confirmation_mismatch_with_password: "La confirmation ne concorde pas avec le mot de passe."
|
||||
organization_name: "Nom de la structure"
|
||||
organization_address: "Adresse de la structure"
|
||||
date_of_birth: "Date de naissance"
|
||||
date_of_birth_is_required: "La date de naissance est requise."
|
||||
website: "Site web"
|
||||
|
Loading…
x
Reference in New Issue
Block a user