File

src/pipes/alias-board-name/alias-board-name.ts

Metadata

Methods

transform
transform(val: string)
Parameters :
Name Type Optional
val string No
Returns : string

Properties

Private Static cachedAliases
Type : literal type[]
import {Pipe, PipeTransform} from '@angular/core';
import {FormAndFrameworkUtilService} from '@app/services';

@Pipe({
    name: 'aliased',
    pure: true
})
export class AliasBoardName implements PipeTransform {
    private static cachedAliases: { name: string, code: string, alias: string }[];
    constructor(
        private formAndFrameworkUtilService: FormAndFrameworkUtilService
    ) {
        if (AliasBoardName.cachedAliases) {
            return;
        }
        this.formAndFrameworkUtilService.getBoardAliasName().then((fields) => {
            AliasBoardName.cachedAliases = fields;
        });
    }
    transform(val: string): string {
        if (!AliasBoardName.cachedAliases) {
            return val;
        }
        const alias = AliasBoardName.cachedAliases.find(a => a.name === val);
        if (alias) {
            return alias.alias;
        }
        return val;
    }
}

results matching ""

    No results matching ""