import { ChangeDetectionStrategy , Component , Input } from '@angular/core' ; import { ContributorService } from '@core/contributor.service' ; import { EventService } from '@core/event.service' ; import { Event } from '../../event' ; param sourceCode @ Component ( { changeDetection : ChangeDetectionStrategy . OnPush , selector : 'shared-attribution' , styleUrls : [ './attribution.component.scss' ] , templateUrl : './attribution.component.html' } ) export class AttributionComponent { @ Input ( ) sourceCode : string ; constructor ( readonly contributorService , readonly eventService ) { } param sourceCode param event param details sourceCodeToInfo ( sourceCode , event = null , details = [ ] ) { let id ; const eventSources = event && event . sources ? event . sources : [ ] ; if ( ! sourceCode ) { return '' ; } id = sourceCode . toLowerCase ( ) ; const detailInfo = details . find ( item => { return ( item . id === id || ( item . aliases && item . aliases . indexOf ( id ) !== - 1 ) ) ; } ) ; if ( detailInfo ) { id = detailInfo . id . toLowerCase ( ) ; } return { details : detailInfo , id : id . toUpperCase ( ) , index : eventSources . indexOf ( id ) + 1 } ; } }