1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-03-15 12:29:16 +01:00

edit organization custom field in member's dashboard profile

This commit is contained in:
Du Peng 2022-05-10 20:22:41 +02:00
parent 3e34b3c7a7
commit 798941c349
4 changed files with 28 additions and 2 deletions

View File

@ -268,7 +268,8 @@ class API::MembersController < API::ApiController
invoicing_profile_attributes: [
:id,
address_attributes: %i[id address],
organization_attributes: [:id, :name, address_attributes: %i[id address]]
organization_attributes: [:id, :name, address_attributes: %i[id address]],
user_profile_custom_fields_attributes: %i[id value]
],
statistic_profile_attributes: %i[id gender birthday])
@ -282,7 +283,8 @@ class API::MembersController < API::ApiController
invoicing_profile_attributes: [
:id,
address_attributes: %i[id address],
organization_attributes: [:id, :name, address_attributes: %i[id address]]
organization_attributes: [:id, :name, address_attributes: %i[id address]],
user_profile_custom_fields_attributes: %i[id value]
],
statistic_profile_attributes: [:id, :gender, :birthday, training_ids: []])

View File

@ -26,6 +26,8 @@ import { HtmlTranslate } from '../base/html-translate';
import TrainingAPI from '../../api/training';
import TagAPI from '../../api/tag';
import { FormMultiSelect } from '../form/form-multi-select';
import ProfileCustomFieldAPI from '../../api/profile-custom-field';
import { ProfileCustomField } from '../../models/profile-custom-field';
declare const Application: IApplication;
@ -67,6 +69,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
const [termsAndConditions, setTermsAndConditions] = useState<CustomAsset>(null);
const [trainings, setTrainings] = useState<selectOption[]>([]);
const [tags, setTags] = useState<selectOption[]>([]);
const [profileCustomFields, setProfileCustomFields] = useState<ProfileCustomField[]>([]);
useEffect(() => {
AuthProviderAPI.active().then(data => {
@ -90,6 +93,9 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
setTags(buildOptions(data));
}).catch(error => onError(error));
}
ProfileCustomFieldAPI.index().then(data => {
setProfileCustomFields(data.filter(f => f.actived));
}).catch(error => onError(error));
}, []);
/**
@ -252,6 +258,15 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
disabled={isDisabled}
formState={formState}
label={t('app.shared.user_profile_form.organization_address')} />
{profileCustomFields.map((f, i) => {
return (<FormInput key={`profileCustomField${i}`}
id={`invoicing_profile_attributes.user_profile_custom_fields_attributes[${i}].value`}
register={register}
rules={{ required: f.required ? t('app.shared.user_profile_form.profile_custom_field_is_required', { FEILD: f.label }) as string : false }}
disabled={isDisabled}
formState={formState}
label={f.label} />);
})}
</div>}
</div>
<div className="profile-data">

View File

@ -39,6 +39,14 @@ json.invoicing_profile_attributes do
end
end
end
json.user_profile_custom_fields_attributes member.invoicing_profile.user_profile_custom_fields
.joins(:profile_custom_field).where('profile_custom_fields.actived' => true).order('profile_custom_fields.id ASC') do |f|
json.id f.id
json.invoicing_profile_id f.invoicing_profile_id
json.profile_custom_field_id f.profile_custom_field_id
json.value f.value
end
end
json.statistic_profile_attributes do

View File

@ -59,6 +59,7 @@ en:
email_address: "Email address"
organization_name: "Organization name"
organization_address: "Organization address"
profile_custom_field_is_required: "{FEILD} is required"
date_of_birth: "Date of birth"
website: "Website"
website_invalid: "The website address is not a valid URL"