Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.10] new profile fields #446

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- New Attribute Type: _Richtext_ (A feature-rich alternative to _Textbox_ Attribute; based on Markdown)
- Separate form Save/Reset in Entity Attribute Tabs (when using _Attribute Group Separator_)
- Additional non-standard bibtex fields to _Bibliography_ (ISBN, ISSN, Language and Abstract)
- Additional fields in _User profile_ regarding institution
### Fixed
- Error in _Attribute List_ caused by _Entity (Multiple Choice)_ attribute
- Attribute form Save/Reset handling due to newly introduced _Attribute Group Separator_
Expand All @@ -30,6 +31,7 @@ All notable changes to this project will be documented in this file.
- Reset Password Workflow
- Allow adding options in _List_ attribute on `Enter` key
- Set timeout & disable login button while authenticating
- Better handling and validation of user input in _User profile_

## 0.9.14
### Added
Expand Down
13 changes: 7 additions & 6 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ public function patchUser(Request $request, $id) {
'name' => 'string|max:255',
'nickname' => 'alpha_dash|max:255|unique:users,nickname',
'phonenumber' => 'nullable|string|max:255',
'role' => 'nullable|string|max:255',
'field' => 'nullable|string|max:255',
'institution' => 'nullable|string|max:255',
'department' => 'nullable|string|max:255',
'orcid' => 'nullable|orcid',
]);

Expand Down Expand Up @@ -343,12 +347,9 @@ public function patchUser(Request $request, $id) {
$user->nickname = Str::lower($request->get('nickname'));
$user->save();
}
if($request->has('phonenumber')) {
$user->setMetadata(['phonenumber' => $request->get('phonenumber')]);
}
if($request->has('orcid')) {
$user->setMetadata(['orcid' => $request->get('orcid')]);
}
$user->setMetadata(
$request->only('phonenumber', 'orcid', 'role', 'field', 'institution', 'department')
);

// return user without roles relation
$user->unsetRelation('roles');
Expand Down
14 changes: 12 additions & 2 deletions resources/js/bootstrap/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import '@fontsource/source-code-pro/500.css';
// Font Awesome
import { library, dom, findIconDefinition } from '@fortawesome/fontawesome-svg-core';
import {
faFacebookSquare,
faFacebook,
faGithub,
faHtml5,
faLaravel,
Expand Down Expand Up @@ -66,6 +66,7 @@ import {
faCaretLeft,
faCaretRight,
faCaretUp,
faChalkboardUser,
faChartBar,
faChartPie,
faCheck,
Expand Down Expand Up @@ -126,6 +127,7 @@ import {
faHouse,
faI,
faIdBadge,
faIdCardClip,
faImage,
faIndent,
faInfo,
Expand Down Expand Up @@ -173,6 +175,7 @@ import {
faRulerCombined,
faS,
faSave,
faSchool,
faSearch,
faSearchPlus,
faShieldAlt,
Expand Down Expand Up @@ -214,6 +217,8 @@ import {
faUserCog,
faUserEdit,
faUsers,
faUsersBetweenLines,
faUserTag,
faUserTimes,
faVolumeMute,
faVolumeUp,
Expand All @@ -227,7 +232,7 @@ library.add(
fa4,
fa5,
fa6,
faFacebookSquare,
faFacebook,
faGithub,
faHtml5,
faLaravel,
Expand Down Expand Up @@ -260,6 +265,7 @@ library.add(
faCaretLeft,
faCaretRight,
faCaretUp,
faChalkboardUser,
faChartBar,
faChartPie,
faCheck,
Expand Down Expand Up @@ -321,6 +327,7 @@ library.add(
faHouse,
faI,
faIdBadge,
faIdCardClip,
faImage,
faIndent,
faInfo,
Expand Down Expand Up @@ -371,6 +378,7 @@ library.add(
faS,
faSadCry,
faSave,
faSchool,
faSearch,
faSearchPlus,
faShieldAlt,
Expand Down Expand Up @@ -414,6 +422,8 @@ library.add(
faUserCog,
faUserEdit,
faUsers,
faUsersBetweenLines,
faUserTag,
faUserTimes,
faVolumeMute,
faVolumeUp,
Expand Down
50 changes: 50 additions & 0 deletions resources/js/bootstrap/validation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import i18n from '@/bootstrap/i18n.js';
import {
addMethod,
string,
} from 'yup';

import {
isValidOrcid,
} from '@/helpers/validators.js';

const t = i18n.global.t;

Expand All @@ -11,4 +19,46 @@ export const bibtexExt = {
requiredIf: (o, ref) => {
return t('main.bibliography.types.validation.required_one_of', {col: o.path, ref: ref});
}
};

export const orcid = _ => {
addMethod(string, 'orcid', function() {
return this.test('test-orcid', t('global.user.invalid_orcid'), function(value) {
return isValidOrcid(value);
});
});

return simple().orcid();
};

export const simple = _ => {
return string().trim();
};

export const simple_max = (max = 255) => {
return simple().max(max);
};

export const simple_req = _ => {
return simple().required();
};

export const simple_req_max = (max = 255) => {
return simple_req().max(max);
};

export const name = _ => {
return simple_req_max();
};

export const nickname = _ => {
return name().matches(/^[0-9a-zA-Z-_]+$/);
};

export const email = _ => {
return simple_req_max().email();
};

export const phone = _ => {
return simple_max().matches(/^(\+[1-9]|0)[0-9 ]+$/);
};
Loading
Loading