File
Methods
transform
|
transform(label: string | undefined, ...args: [])
|
|
Parameters :
Name |
Type |
Optional |
label |
string | undefined
|
No
|
args |
[]
|
No
|
Returns : string | undefined
|
Private
_mapping
|
Type : object
|
Default value : {
board: get(this.resourceService, 'frmelmnts.lbl.boards'),
medium: get(this.resourceService, 'frmelmnts.lbl.medium'),
gradeLevel: get(this.resourceService, 'frmelmnts.lbl.class'),
publisher: get(this.resourceService, 'frmelmnts.lbl.publishedBy'),
subject: get(this.resourceService, 'frmelmnts.lbl.subject'),
audience: get(this.resourceService, 'frmelmnts.lbl.publishedUserType'),
class: get(this.resourceService, 'frmelmnts.lbl.class')
}
|
|
Private
mappingProxy
|
Default value : new Proxy(this._mapping, {
get: (target, key) => {
return get(this.resourceService, key) || (key in target ? target[key] : key);
}
})
|
|
import { get } from 'lodash-es';
import { Pipe, PipeTransform } from '@angular/core';
import { ResourceService } from '@sunbird/shared';
@Pipe({
name: 'frameworkCatLabelTranslate'
})
export class FrameworkCatLabelTranslatePipe implements PipeTransform {
private _mapping = {
board: get(this.resourceService, 'frmelmnts.lbl.boards'),
medium: get(this.resourceService, 'frmelmnts.lbl.medium'),
gradeLevel: get(this.resourceService, 'frmelmnts.lbl.class'),
publisher: get(this.resourceService, 'frmelmnts.lbl.publishedBy'),
subject: get(this.resourceService, 'frmelmnts.lbl.subject'),
audience: get(this.resourceService, 'frmelmnts.lbl.publishedUserType'),
class: get(this.resourceService, 'frmelmnts.lbl.class')
}
private mappingProxy = new Proxy(this._mapping, {
get: (target, key) => {
return get(this.resourceService, key) || (key in target ? target[key] : key);
}
})
constructor(private resourceService: ResourceService) { }
transform(label: string | undefined, ...args: unknown[]): string | undefined {
return this.mappingProxy[label && label.toLowerCase()];
}
}