From c0a2072cc2243a993e095194bf86623db93a3c46 Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Mon, 25 Mar 2019 13:34:10 +0100 Subject: [PATCH] Add manual sorting to Speaker list Also create CSS Theme file to prevent side effects from theming --- .../list-of-speakers.component.scss | 28 ------------------- ...list-of-speakers.component.scss-theme.scss | 27 ++++++++++++++++++ .../list-of-speakers.component.ts | 10 +++++++ client/src/styles.scss | 2 +- 4 files changed, 38 insertions(+), 29 deletions(-) create mode 100644 client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss-theme.scss diff --git a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss index e7f0b1c97..cc5751111 100644 --- a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss +++ b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss @@ -1,31 +1,3 @@ -@import '~@angular/material/theming'; - -@mixin os-list-of-speakers-style($theme) { - $primary: map-get($theme, primary); - $accent: map-get($theme, accent); - $warn: map-get($theme, warn); - $contrast: map-get($primary, contrast); - $foreground: map-get($theme, foreground); - - .current-speaker { - background-color: mat-color($accent) !important; - - > span { - color: mat-color($accent, default-contrast); - } - } - - .finished-speaker-grid { - > .number .name .controls { - color: mat-color($foreground, text); - } - - > .time { - color: mat-color($foreground, secondary-text); - } - } -} - .los-title { margin-left: 25px; } diff --git a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss-theme.scss b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss-theme.scss new file mode 100644 index 000000000..eeadf51b9 --- /dev/null +++ b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss-theme.scss @@ -0,0 +1,27 @@ +@import '~@angular/material/theming'; + +@mixin os-list-of-speakers-style($theme) { + $primary: map-get($theme, primary); + $accent: map-get($theme, accent); + $warn: map-get($theme, warn); + $contrast: map-get($primary, contrast); + $foreground: map-get($theme, foreground); + + .current-speaker { + background-color: mat-color($accent) !important; + + > span { + color: mat-color($accent, default-contrast); + } + } + + .finished-speaker-grid { + > .number .name .controls { + color: mat-color($foreground, text); + } + + > .time { + color: mat-color($foreground, secondary-text); + } + } +} diff --git a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts index ccf7e6313..0ac929433 100644 --- a/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts +++ b/client/src/app/site/agenda/components/list-of-speakers/list-of-speakers.component.ts @@ -241,7 +241,17 @@ export class ListOfSpeakersComponent extends BaseViewComponent implements OnInit this.viewItem = newAgendaItem; const allSpeakers = this.repo.createSpeakerList(newAgendaItem.item); this.speakers = allSpeakers.filter(speaker => speaker.state === SpeakerState.WAITING); + // Since the speaker repository is not a normal repository, sorting cannot be handled there + this.speakers.sort((a: ViewSpeaker, b: ViewSpeaker) => a.weight - b.weight); this.finishedSpeakers = allSpeakers.filter(speaker => speaker.state === SpeakerState.FINISHED); + + // convert begin time to date and sort + this.finishedSpeakers.sort((a: ViewSpeaker, b: ViewSpeaker) => { + const aTime = new Date(a.begin_time).getTime(); + const bTime = new Date(b.begin_time).getTime(); + return aTime - bTime; + }); + this.activeSpeaker = allSpeakers.find(speaker => speaker.state === SpeakerState.CURRENT); } }); diff --git a/client/src/styles.scss b/client/src/styles.scss index e6ae602fb..72fab746e 100644 --- a/client/src/styles.scss +++ b/client/src/styles.scss @@ -11,7 +11,7 @@ @import './app/site/site.component.scss-theme.scss'; @import './assets/styles/global-components-style.scss'; @import './app/shared/components/projector-button/projector-button.component.scss'; -@import './app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss'; +@import './app/site/agenda/components/list-of-speakers/list-of-speakers.component.scss-theme.scss'; /** fonts */ @import './assets/styles/fonts.scss';