/**
 * This file is part of Anis Client.
 *
 * @copyright Laboratoire d'Astrophysique de Marseille / CNRS
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';

import { Criterion, SvomKeyword } from '../../../store/models';
import { CriteriaFamily, Attribute } from 'src/app/metamodel/models';

/**
 * @class
 * @classdesc Search criteria tabs component.
 */
@Component({
    selector: 'app-criteria-tabs',
    templateUrl: 'criteria-tabs.component.html',
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class CriteriaTabsComponent {
    @Input() attributeList: Attribute[];
    @Input() criteriaFamilyList: CriteriaFamily[];
    @Input() criteriaList: Criterion[];
    @Input() svomKeywords: SvomKeyword[];
    @Output() selectSvomAcronym: EventEmitter<string> = new EventEmitter();
    @Output() resetSvomKeywords: EventEmitter<{}> = new EventEmitter();
    @Output() addCriterion: EventEmitter<Criterion> = new EventEmitter();
    @Output() deleteCriterion: EventEmitter<number> = new EventEmitter();

    /**
     * Emits event to add the given criterion to the criteria list.
     *
     * @param  {Criterion} criterion - The criterion.
     *
     * @fires EventEmitter<Criterion>
     */
    emitAdd(criterion: Criterion): void {
        this.addCriterion.emit(criterion);
    }

    /**
     * Emits event to remove the given criterion ID to the criteria list.
     *
     * @param  {number} id - The criterion ID.
     *
     * @fires EventEmitter<number>
     */
    emitDelete(id: number): void {
        this.deleteCriterion.emit(id);
    }
}