<commit_before><commit_msg>Began working on cardview external-href bug again in a new branch. Old fix/branch (cardview-external-hrefs) was fundamentally incompatible with recent changes to master<commit_after>import { Directive, ElementRef, Input, AfterViewInit, HostListener } from '@angular/core';
import { ListItem } from 'app/model/ListItem';
import { AnalyticsService } from 'app/services/analytics.service';
import { ActivatedRoute } from '@angular/router';

@Directive({
    selector: '[appSearchResultLink]'
})
export class SearchResultLinkDirective implements AfterViewInit {
    @Input() item: ListItem;

    constructor(private el: ElementRef, private analyticsService: AnalyticsService, private route: ActivatedRoute) {}

    @HostListener('click') click() {
       if (this.item.type === 'policy') {
           this.analyticsService.trackPolicy(this.item.title, this.item.url);
       }
   }

    ngAfterViewInit() {
        if (this.item.type === 'policy') {
            this.el.nativeElement.href = this.item.url;
            this.el.nativeElement.target = '_blank';
        } else {
            this.el.nativeElement.href = '#/' + this.item.type + '/' + this.item.id.toString();
        }
    }
}
{'fraction_non_alphanumeric': 0.12788778877887788, 'fraction_numerical': 0.0, 'mean_word_length': 3.5261194029850746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5445181', 'n_tokens_mistral': 346, 'n_tokens_neox': 336, 'n_words': 80}