Untitled
unknown
plain_text
2 years ago
1.1 kB
5
Indexable
@Pipe({ name: 'legacy' }) export class LegacyPipe implements PipeTransform { legacies = []; constructor(private legacyICDService: LegacyIcdService) { this.loadLegados(); } loadLegados() { const legacies = []; legacies.push(...CONSTS.LEGADOS); this.legacyICDService.query({ page: 0, size: 2000, sort: 'descripcion' }).subscribe({ next: (data:any) =>{ data.content.forEach(cycle => { legacies.push( {value: cycle.legadoOrigen, viewValue: cycle.descripcion, haveInput: false}); }); this.legacies = legacies.filter(f => f.value === 'todos'); this.legacies.push(...legacies.filter(f => f.value !== 'todos').sort((a, b) => a.viewValue.localeCompare(b.viewValue))); },error: (error: HttpErrorResponse) =>{ console.log(error) } }) } transform(value: any, args?: any): any { if (value) { for (const legado of this.legacies) { if (legado.value === value) { return legado.viewValue; } } } return value; } }
Editor is loading...