Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | import {PipeTransform, Pipe} from '@angular/core'; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 2 | import * as _ from 'lodash'; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 3 | |
| 4 | @Pipe({ name: 'serviceInfo'}) |
| 5 | export class ServiceInfoPipe implements PipeTransform { |
| 6 | transform(service: string, store : any , modelId : string, fieldName : string): string { |
| 7 | const serviceHierarchy = store.getState().service.serviceHierarchy; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 8 | if(!_.isNil(serviceHierarchy) && !_.isNil(serviceHierarchy[modelId])){ |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 9 | return serviceHierarchy[modelId].service[fieldName] || null; |
| 10 | } |
| 11 | return null; |
| 12 | } |
| 13 | } |