Federated video streaming platform using ActivityPub and P2P in the web browser with Angular. https://joinpeertube.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.1 KiB

  1. import { Component, forwardRef, Input } from '@angular/core'
  2. import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
  3. export type SelectOptionsItem = {
  4. id: string | number
  5. label: string
  6. description?: string
  7. group?: string
  8. groupLabel?: string
  9. }
  10. @Component({
  11. selector: 'my-select-options',
  12. styleUrls: [ './select-shared.component.scss' ],
  13. templateUrl: './select-options.component.html',
  14. providers: [
  15. {
  16. provide: NG_VALUE_ACCESSOR,
  17. useExisting: forwardRef(() => SelectOptionsComponent),
  18. multi: true
  19. }
  20. ]
  21. })
  22. export class SelectOptionsComponent implements ControlValueAccessor {
  23. @Input() items: SelectOptionsItem[] = []
  24. @Input() clearable = false
  25. @Input() searchable = false
  26. @Input() groupBy: string
  27. @Input() labelForId: string
  28. selectedId: number | string
  29. propagateChange = (_: any) => { /* empty */ }
  30. writeValue (id: number | string) {
  31. this.selectedId = id
  32. }
  33. registerOnChange (fn: (_: any) => void) {
  34. this.propagateChange = fn
  35. }
  36. registerOnTouched () {
  37. // Unused
  38. }
  39. onModelChange () {
  40. this.propagateChange(this.selectedId)
  41. }
  42. }