2019-04-23 16:57:35 +02:00
|
|
|
import { Component, Input } from '@angular/core';
|
|
|
|
|
2019-07-26 11:46:59 +02:00
|
|
|
import { ListOfSpeakersRepositoryService } from 'app/core/repositories/agenda/list-of-speakers-repository.service';
|
2019-04-23 16:57:35 +02:00
|
|
|
import { ContentObject, isContentObject } from 'app/shared/models/base/content-object';
|
|
|
|
import { ViewListOfSpeakers } from 'app/site/agenda/models/view-list-of-speakers';
|
|
|
|
import {
|
|
|
|
BaseViewModelWithListOfSpeakers,
|
|
|
|
isBaseViewModelWithListOfSpeakers
|
|
|
|
} from 'app/site/base/base-view-model-with-list-of-speakers';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A generic button to go to the list of speakers. Give the content object with
|
|
|
|
* [object]=object, which can be a ContentObject or a ViewModelWithListOfSpeakers.
|
|
|
|
* - Usage as a mini-fab (like in the agenda) with [menuItem]=false (default)
|
|
|
|
* - Usage in a dropdown (=list) with [menuItem]=true
|
|
|
|
*/
|
|
|
|
@Component({
|
|
|
|
selector: 'os-speaker-button',
|
|
|
|
templateUrl: './speaker-button.component.html'
|
|
|
|
})
|
|
|
|
export class SpeakerButtonComponent {
|
|
|
|
@Input()
|
|
|
|
public set object(obj: BaseViewModelWithListOfSpeakers | ContentObject | null) {
|
|
|
|
if (isBaseViewModelWithListOfSpeakers(obj)) {
|
|
|
|
this.listOfSpeakers = obj.listOfSpeakers;
|
|
|
|
} else if (isContentObject(obj)) {
|
|
|
|
this.listOfSpeakers = this.listOfSpeakersRepo.findByContentObject(obj);
|
|
|
|
} else {
|
|
|
|
this.listOfSpeakers = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public listOfSpeakers: ViewListOfSpeakers | null;
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
public disabled: boolean;
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
public menuItem = false;
|
|
|
|
|
2019-06-14 11:18:54 +02:00
|
|
|
public get listOfSpeakersUrl(): string {
|
|
|
|
if (!this.disabled) {
|
|
|
|
return this.listOfSpeakers.listOfSpeakersUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 15:49:58 +02:00
|
|
|
public get icon(): string {
|
|
|
|
return this.listOfSpeakers.closed ? 'voice_over_off' : 'record_voice_over';
|
|
|
|
}
|
|
|
|
|
|
|
|
public get tooltip(): string {
|
2019-07-30 11:12:18 +02:00
|
|
|
return this.listOfSpeakers.closed ? 'The list of speakers is closed.' : 'List of speakers';
|
2019-08-01 15:49:58 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 16:57:35 +02:00
|
|
|
/**
|
|
|
|
* The constructor
|
|
|
|
*/
|
|
|
|
public constructor(private listOfSpeakersRepo: ListOfSpeakersRepositoryService) {}
|
|
|
|
}
|