<commit_before>import {Component, Input, Output, EventEmitter, OnChanges} from '@angular/core';
import {IdaiType} from '../../core/configuration/model/idai-type';


@Component({
    selector: 'type-picker',
    moduleId: module.id,
    templateUrl: './type-picker.html'
})
/**
 * @author <NAME>
 */
export class TypePickerComponent implements OnChanges {

    @Input() typesTreeList: Array<IdaiType>;
    @Input() selectedTypes: string[];
    @Input() allTypesOptionVisible: boolean = false;
    @Input() allowPickingAbstractTypes: boolean = false;

    @Output() onTypePicked: EventEmitter<IdaiType> = new EventEmitter<IdaiType>();


    public types: Array<IdaiType> = [];


    ngOnChanges() {

        this.types = [];

        this.typesTreeList.forEach(type => {
            this.types.push(type);
            if (type.children) this.types = this.types.concat(type.children);
        });
    }


    public pickType(type: IdaiType) {

        if (type && type.isAbstract && !this.allowPickingAbstractTypes) return;

        this.onTypePicked.emit(type);
    }


    public getTypeId(type: IdaiType): string {

        return (this.isChildType(type) ? (type.parentType as IdaiType).name.toLowerCase() + '-' : '')
            + type.name.toLowerCase();
    }


    public isChildType(type: IdaiType): boolean {

        return type.parentType !== undefined
            && this.types.find(typeToCheck => typeToCheck === type.parentType) !== undefined;
    }


    public isParentSelected(type: IdaiType): boolean {

        if (!type.parentType || !this.selectedTypes) return false;

        const parentName: string = type.parentType.name;
        return this.selectedTypes.find(typeName => typeName === parentName) !== undefined;
    }
}<commit_msg>Fix type comparison in type-picker<commit_after>import {on, is} from 'tsfun';
import {Component, Input, Output, EventEmitter, OnChanges} from '@angular/core';
import {IdaiType} from '../../core/configuration/model/idai-type';


@Component({
    selector: 'type-picker',
    moduleId: module.id,
    templateUrl: './type-picker.html'
})
/**
 * @author <NAME>
 */
export class TypePickerComponent implements OnChanges {

    @Input() typesTreeList: Array<IdaiType>;
    @Input() selectedTypes: string[];
    @Input() allTypesOptionVisible: boolean = false;
    @Input() allowPickingAbstractTypes: boolean = false;

    @Output() onTypePicked: EventEmitter<IdaiType> = new EventEmitter<IdaiType>();


    public types: Array<IdaiType> = [];


    ngOnChanges() {

        this.types = [];

        this.typesTreeList.forEach(type => {
            this.types.push(type);
            if (type.children) this.types = this.types.concat(type.children);
        });
    }


    public pickType(type: IdaiType) {

        if (type && type.isAbstract && !this.allowPickingAbstractTypes) return;

        this.onTypePicked.emit(type);
    }


    public getTypeId(type: IdaiType): string {

        return (this.isChildType(type) ? (type.parentType as IdaiType).name.toLowerCase() + '-' : '')
            + type.name.toLowerCase();
    }


    public isChildType(type: IdaiType): boolean {

        return type.parentType !== undefined
            && this.types.find(on(IdaiType.NAME)(type.parentType)) !== undefined;
    }


    public isParentSelected(type: IdaiType): boolean {

        if (!type.parentType || !this.selectedTypes) return false;

        const parentName: string = type.parentType.name;
        return this.selectedTypes.find(typeName => typeName === parentName) !== undefined;
    }
}
{'fraction_non_alphanumeric': 0.14293769382576826, 'fraction_numerical': 0.0, 'mean_word_length': 3.1064814814814814, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, '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': '7581491', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1058, 'n_words': 215}