rendition.component.ts 952 B

123456789101112131415161718192021222324252627282930313233
  1. import { Component, Input } from '@angular/core';
  2. import { TranslateService } from '@ngx-translate/core';
  3. import { of } from 'rxjs';
  4. import { map } from 'rxjs/operators';
  5. import { Rendition } from '../../models/evt-models';
  6. import { register } from '../../services/component-register.service';
  7. import { snakeToCamelCased } from '../../utils/js-utils';
  8. @Component({
  9. selector: 'evt-rendition',
  10. templateUrl: './rendition.component.html',
  11. styleUrls: ['./rendition.component.scss'],
  12. })
  13. @register(Rendition)
  14. export class RenditionComponent {
  15. @Input() data: Rendition;
  16. get scopeDescription$() {
  17. if (this.data.scope) {
  18. const descKey = snakeToCamelCased(`rendition-${this.data.scope}-desc`);
  19. return this.translateService.get(descKey).pipe(
  20. map(translation => translation === descKey ? '' : `(${translation})`),
  21. );
  22. }
  23. return of('');
  24. }
  25. constructor(
  26. private translateService: TranslateService,
  27. ) { }
  28. }