From ad77475251c3516dd5851a08655be79d7bf76245 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 Jul 2018 15:11:25 +0200 Subject: Sort video captions --- .../videos/+video-edit/shared/video-edit.component.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'client/src/app/videos/+video-edit') diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index b8aef99dd..b394a13e4 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts @@ -142,12 +142,13 @@ export class VideoEditComponent implements OnInit, OnDestroy { // Replace existing caption? if (existingCaption) { Object.assign(existingCaption, caption, { action: 'CREATE' as 'CREATE' }) - return + } else { + this.videoCaptions.push( + Object.assign(caption, { action: 'CREATE' as 'CREATE' }) + ) } - this.videoCaptions.push( - Object.assign(caption, { action: 'CREATE' as 'CREATE' }) - ) + this.sortVideoCaptions() } async deleteCaption (caption: VideoCaptionEdit) { @@ -170,6 +171,15 @@ export class VideoEditComponent implements OnInit, OnDestroy { this.videoCaptionAddModal.show() } + private sortVideoCaptions () { + this.videoCaptions.sort((v1, v2) => { + if (v1.language.label < v2.language.label) return -1 + if (v1.language.label === v2.language.label) return 0 + + return 1 + }) + } + private trackPrivacyChange () { // We will update the "support" field depending on the channel this.form.controls[ 'privacy' ] -- cgit v1.2.3