From 360329cc029c062bfb145c90f7bf1c007c39af81 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 9 May 2018 11:23:14 +0200 Subject: Account/channel descriptions are not required anymore --- .../my-account-profile/my-account-profile.component.ts | 2 +- .../my-account-video-channel-create.component.ts | 4 ++-- .../my-account-video-channel-update.component.ts | 4 ++-- client/src/app/shared/forms/form-validators/user.ts | 2 -- client/src/app/shared/misc/utils.ts | 2 +- client/src/app/shared/video/video.service.ts | 10 +++++----- 6 files changed, 11 insertions(+), 13 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts index 2b7ba353c..468be022c 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts @@ -47,7 +47,7 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit { updateMyProfile () { const displayName = this.form.value['display-name'] - const description = this.form.value['description'] + const description = this.form.value['description'] || null this.error = null diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts index 0f03548ad..fab9cacd8 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-create.component.ts @@ -64,8 +64,8 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE const body = this.form.value const videoChannelCreate: VideoChannelCreate = { displayName: body['display-name'], - description: body.description || undefined, - support: body.support || undefined + description: body.description || null, + support: body.support || null } this.videoChannelService.createVideoChannel(videoChannelCreate).subscribe( diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts index c0dc6a939..9adc38691 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts @@ -92,8 +92,8 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE const body = this.form.value const videoChannelUpdate: VideoChannelUpdate = { displayName: body['display-name'], - description: body.description || undefined, - support: body.support || undefined + description: body.description || null, + support: body.support || null } this.videoChannelService.updateVideoChannel(this.videoChannelToUpdate.uuid, videoChannelUpdate).subscribe( diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts index c6b65e0df..0973f1b00 100644 --- a/client/src/app/shared/forms/form-validators/user.ts +++ b/client/src/app/shared/forms/form-validators/user.ts @@ -60,12 +60,10 @@ export const USER_DISPLAY_NAME = { } export const USER_DESCRIPTION = { VALIDATORS: [ - Validators.required, Validators.minLength(3), Validators.maxLength(250) ], MESSAGES: { - 'required': 'Description is required.', 'minlength': 'Description must be at least 3 characters long.', 'maxlength': 'Description cannot be more than 250 characters long.' } diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts index 99f6b3cf0..b5bf99be2 100644 --- a/client/src/app/shared/misc/utils.ts +++ b/client/src/app/shared/misc/utils.ts @@ -66,7 +66,7 @@ function objectToFormData (obj: any, form?: FormData, namespace?: string) { if (obj[key] === undefined) continue - if (typeof obj[ key ] === 'object' && !(obj[ key ] instanceof File)) { + if (obj[key] !== null && typeof obj[ key ] === 'object' && !(obj[ key ] instanceof File)) { objectToFormData(obj[ key ], fd, key) } else { fd.append(formKey, obj[ key ]) diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 8870cbee4..b45777c55 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -54,11 +54,11 @@ export class VideoService { } updateVideo (video: VideoEdit) { - const language = video.language || undefined - const licence = video.licence || undefined - const category = video.category || undefined - const description = video.description || undefined - const support = video.support || undefined + const language = video.language || null + const licence = video.licence || null + const category = video.category || null + const description = video.description || null + const support = video.support || null const body: VideoUpdate = { name: video.name, -- cgit v1.2.3