Newer
Older
/**
* 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 { Attribute, Option } from 'src/app/metamodel/models';
/**
* @class
* @classdesc Search criteria by family component.
*/
@Component({
selector: 'app-criteria-by-family',
templateUrl: 'criteria-by-family.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CriteriaByFamilyComponent {
@Input() attributeList: Attribute[];
@Input() criteriaList: Criterion[];
@Input() svomKeywords: SvomKeyword[];
@Output() selectSvomAcronym: EventEmitter<string> = new EventEmitter();
@Output() resetSvomKeywords: EventEmitter<{}> = new EventEmitter();
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@Output() addCriterion: EventEmitter<Criterion> = new EventEmitter();
@Output() deleteCriterion: EventEmitter<number> = new EventEmitter();
advancedForm = false;
/**
* Returns options for the given attribute ID.
*
* @param {number} idAttribute - The attribute ID.
*
* @return Option[]
*/
getOptions(idAttribute: number): Option[] {
return [...this.attributeList.find(attribute => attribute.id === idAttribute).options];
}
/**
* Returns criterion for the given criterion ID.
*
* @param {number} id - The criterion ID.
*
* @return Criterion
*/
getCriterion(id: number): Criterion {
return this.criteriaList.find(criterion => criterion.id === id);
}
/**
* 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 from the criteria list.
*
* @param {number} id - The criterion ID.
*
* @fires EventEmitter<number>
*/
emitDelete(id: number): void {
this.deleteCriterion.emit(id);
}
}