1
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
2
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
3
|
import { formErrorRequiredFields } from '../../../domain/shared-messages';
|
4
|
|
5
|
@Component ({
|
6
|
selector: 'compatibility-validate-step3',
|
7
|
templateUrl: 'compatibility-validate-step3.component.html'
|
8
|
})
|
9
|
|
10
|
export class CompatibilityValidateStep3Component implements OnInit {
|
11
|
errorMessage: string;
|
12
|
|
13
|
@Input() valSets: string[];
|
14
|
@Output() emitObject: EventEmitter<any> = new EventEmitter();
|
15
|
|
16
|
group: FormGroup;
|
17
|
|
18
|
constructor (private fb: FormBuilder) {}
|
19
|
|
20
|
ngOnInit () {
|
21
|
this.group = this.fb.group({
|
22
|
noOfRecordsInput : '',
|
23
|
selectValSet : [''],
|
24
|
xpathInput : ''
|
25
|
});
|
26
|
this.group.get('noOfRecordsInput').setValue(10);
|
27
|
this.group.get('noOfRecordsInput').disable();
|
28
|
this.group.get('xpathInput').disable();
|
29
|
}
|
30
|
|
31
|
chooseAll(all: boolean) {
|
32
|
if (all) {
|
33
|
this.group.get('noOfRecordsInput').disable();
|
34
|
} else {
|
35
|
this.group.get('noOfRecordsInput').enable();
|
36
|
}
|
37
|
}
|
38
|
|
39
|
addXpath(xpath: boolean) {
|
40
|
if (xpath) {
|
41
|
this.group.get('xpathInput').enable();
|
42
|
} else {
|
43
|
this.group.get('xpathInput').disable();
|
44
|
}
|
45
|
}
|
46
|
|
47
|
submitChanges() {
|
48
|
if (this.group.valid) {
|
49
|
this.errorMessage = '';
|
50
|
const emitted: string [] = [];
|
51
|
|
52
|
if ( this.group.get('selectValSet').value) {
|
53
|
emitted.push(this.group.get('selectValSet').value);
|
54
|
} else {
|
55
|
emitted.push('none');
|
56
|
}
|
57
|
|
58
|
if ( this.group.get('noOfRecordsInput').enabled ) {
|
59
|
emitted.push(this.group.get('noOfRecordsInput').value);
|
60
|
} else {
|
61
|
emitted.push('-1');
|
62
|
}
|
63
|
|
64
|
if ( this.group.get('xpathInput').enabled ) {
|
65
|
emitted.push(this.group.get('xpathInput').value);
|
66
|
} else {
|
67
|
emitted.push('');
|
68
|
}
|
69
|
this.emitObject.emit(emitted);
|
70
|
|
71
|
} else {
|
72
|
this.errorMessage = formErrorRequiredFields;
|
73
|
}
|
74
|
}
|
75
|
}
|