1 import { Component, forwardRef, Input } from '@angular/core'
2 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3 import { VideoChannel } from '@app/shared/shared-main'
5 export type SelectChannelItem = {
13 selector: 'my-select-channel',
14 styleUrls: [ './select-shared.component.scss' ],
15 templateUrl: './select-channel.component.html',
18 provide: NG_VALUE_ACCESSOR,
19 useExisting: forwardRef(() => SelectChannelComponent),
24 export class SelectChannelComponent implements ControlValueAccessor {
25 @Input() items: SelectChannelItem[] = []
36 return this.items.map(c => Object.assign(c, {
37 avatarPath: c.avatarPath ? c.avatarPath : VideoChannel.GET_DEFAULT_AVATAR_URL()
41 propagateChange = (_: any) => { /* empty */ }
43 writeValue (id: number) {
47 registerOnChange (fn: (_: any) => void) {
48 this.propagateChange = fn
51 registerOnTouched () {
56 this.propagateChange(this.selectedId)