module Sfx { export class DetailListDetailsViewDirective implements ng . IDirective { public restrict = "E" ; public templateUrl = "partials/detail-list-details-view.html" ; public scope = { detailsListSettings : "=" } ; public require = "^sfxDetailList" ; public link ( $scope , element , attributes , ctrl ) { ctrl . $scope . showDetails = ( itemId ) => { let parentList = ctrl . $scope . list ; if ( parentList && parentList . getDetailsList ) { let parentListItems = parentList . collection || parentList ; let matchItems = parentListItems . filter ( ( item ) => ( item . uniqueId === itemId || item . id === itemId ) ) ; if ( matchItems . length === 1 ) { $scope . itemName = matchItems [ 0 ] . name || null ; $scope . detailsList = parentList . getDetailsList ( matchItems [ 0 ] ) ; $scope . detailsList . refresh ( ) ; } } } ; $scope . reset = ( ) => { $scope . itemName = null ; $scope . detailsList = null ; } ; $scope . goBack = ( ) => { $scope . reset ( ) ; } ; } } }