From ed56ad1193bb5bb0a81fb843a11eb90d3fed9861 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 26 Apr 2018 10:03:40 +0200 Subject: Add ability to update the user display name/description --- .../src/app/shared/forms/form-validators/user.ts | 24 ++++++++++++++++++++++ client/src/app/shared/users/user.service.ts | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts index d2a28a272..095b534c0 100644 --- a/client/src/app/shared/forms/form-validators/user.ts +++ b/client/src/app/shared/forms/form-validators/user.ts @@ -46,3 +46,27 @@ export const USER_ROLE = { 'required': 'User role is required.' } } +export const USER_DISPLAY_NAME = { + VALIDATORS: [ + Validators.required, + Validators.minLength(3), + Validators.maxLength(120) + ], + MESSAGES: { + 'required': 'Display name is required.', + 'minlength': 'Display name must be at least 3 characters long.', + 'maxlength': 'Display name cannot be more than 120 characters long.' + } +} +export const USER_DESCRIPTION = { + VALIDATORS: [ + Validators.required, + Validators.minLength(3), + Validators.maxLength(250) + ], + MESSAGES: { + 'required': 'Display name is required.', + 'minlength': 'Display name must be at least 3 characters long.', + 'maxlength': 'Display name cannot be more than 250 characters long.' + } +} diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index da7b583f4..adb840cec 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts @@ -26,10 +26,10 @@ export class UserService { .catch(res => this.restExtractor.handleError(res)) } - updateMyDetails (details: UserUpdateMe) { + updateMyProfile (profile: UserUpdateMe) { const url = UserService.BASE_USERS_URL + 'me' - return this.authHttp.put(url, details) + return this.authHttp.put(url, profile) .map(this.restExtractor.extractDataBool) .catch(res => this.restExtractor.handleError(res)) } -- cgit v1.2.3