Skip to content
Snippets Groups Projects
Commit 9ed4f591 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Refactoring cone search => DONE

parent 4463f41d
No related branches found
No related tags found
2 merge requests!147Develop,!137Resolve "[Module Multiple] : ajouter le nouveau module"
...@@ -11,7 +11,14 @@ ...@@ -11,7 +11,14 @@
<div class="row mt-2 px-3"> <div class="row mt-2 px-3">
<div class="col px-0 pr-xl-1"> <div class="col px-0 pr-xl-1">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" [formControl]="decH" (input)="decChange('hms')" (change)="setToDefaultValue()" autocomplete="off"> <input type="text"
class="form-control"
[formControl]="decH"
(input)="decChange('hms')"
(focusin)="changeFocus('dech', true)"
(focusout)="changeFocus('dech', false)"
(change)="setToDefaultValue()"
autocomplete="off">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text">°</span> <span class="input-group-text">°</span>
</div> </div>
...@@ -20,7 +27,14 @@ ...@@ -20,7 +27,14 @@
<div class="w-100 d-block d-xl-none"></div> <div class="w-100 d-block d-xl-none"></div>
<div class="col mt-1 mt-xl-auto px-0 pr-xl-1"> <div class="col mt-1 mt-xl-auto px-0 pr-xl-1">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" [formControl]="decM" (input)="decChange('hms')" (change)="setToDefaultValue()" autocomplete="off"> <input type="text"
class="form-control"
[formControl]="decM"
(input)="decChange('hms')"
(focusin)="changeFocus('decm', true)"
(focusout)="changeFocus('decm', false)"
(change)="setToDefaultValue()"
autocomplete="off">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text">'</span> <span class="input-group-text">'</span>
</div> </div>
...@@ -29,7 +43,14 @@ ...@@ -29,7 +43,14 @@
<div class="w-100 d-block d-xl-none"></div> <div class="w-100 d-block d-xl-none"></div>
<div class="col mt-1 mt-xl-auto px-0"> <div class="col mt-1 mt-xl-auto px-0">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" [formControl]="decS" (input)="decChange('hms')" (change)="setToDefaultValue()" autocomplete="off"> <input type="text"
class="form-control"
[formControl]="decS"
(input)="decChange('hms')"
(focusin)="changeFocus('decs', true)"
(focusout)="changeFocus('decs', false)"
(change)="setToDefaultValue()"
autocomplete="off">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text">''</span> <span class="input-group-text">''</span>
</div> </div>
...@@ -45,7 +66,7 @@ ...@@ -45,7 +66,7 @@
{{ decDegree.errors.range.value }} {{ decDegree.errors.range.value }}
</div> </div>
</div> </div>
<div *ngIf="decH.invalid && (decH.dirty || decH.touched)" class="row px-3 text-danger"> <div *ngIf="decH.invalid" class="row px-3 text-danger">
<div *ngIf="decH.errors.nan"> <div *ngIf="decH.errors.nan">
{{ decH.errors.nan.value }} {{ decH.errors.nan.value }}
</div> </div>
...@@ -53,7 +74,7 @@ ...@@ -53,7 +74,7 @@
{{ decH.errors.range.value }} {{ decH.errors.range.value }}
</div> </div>
</div> </div>
<div *ngIf="decM.invalid && (decM.dirty || decM.touched)" class="row px-3 text-danger"> <div *ngIf="decM.invalid" class="row px-3 text-danger">
<div *ngIf="decM.errors.nan"> <div *ngIf="decM.errors.nan">
{{ decM.errors.nan.value }} {{ decM.errors.nan.value }}
</div> </div>
...@@ -61,7 +82,7 @@ ...@@ -61,7 +82,7 @@
{{ decM.errors.range.value }} {{ decM.errors.range.value }}
</div> </div>
</div> </div>
<div *ngIf="decS.invalid && (decS.dirty || decS.touched)" class="row px-3 text-danger"> <div *ngIf="decS.invalid" class="row px-3 text-danger">
<div *ngIf="decS.errors.nan"> <div *ngIf="decS.errors.nan">
{{ decS.errors.nan.value }} {{ decS.errors.nan.value }}
</div> </div>
......
...@@ -22,7 +22,7 @@ export class DecComponent { ...@@ -22,7 +22,7 @@ export class DecComponent {
this.radius = coneSearch.radius; this.radius = coneSearch.radius;
if (coneSearch.dec) { if (coneSearch.dec) {
this.decDegree.setValue(coneSearch.dec); this.decDegree.setValue(coneSearch.dec);
if(this.decDegree.valid) { if(this.decDegree.valid && !this.decHFocused && !this.decMFocused && !this.decSFocused) {
this.decDegree2HMS(coneSearch.dec); this.decDegree2HMS(coneSearch.dec);
} }
} else { } else {
...@@ -56,6 +56,9 @@ export class DecComponent { ...@@ -56,6 +56,9 @@ export class DecComponent {
isDisabled = false; isDisabled = false;
isDegree = true; isDegree = true;
resolvedDec: number; resolvedDec: number;
decHFocused: boolean = false;
decMFocused: boolean = false;
decSFocused: boolean = false;
decDegree = new FormControl('', [Validators.required, nanValidator, rangeValidator(-90, 90, 'DEC')]); decDegree = new FormControl('', [Validators.required, nanValidator, rangeValidator(-90, 90, 'DEC')]);
decH = new FormControl('', [nanValidator, rangeValidator(-90, 90, 'Degree')]); decH = new FormControl('', [nanValidator, rangeValidator(-90, 90, 'Degree')]);
...@@ -104,17 +107,30 @@ export class DecComponent { ...@@ -104,17 +107,30 @@ export class DecComponent {
this.decDegree.setValue(+deg.toFixed(8)); this.decDegree.setValue(+deg.toFixed(8));
} }
changeFocus(field: string, isFocused: boolean) {
switch (field) {
case 'dech':
this.decHFocused = isFocused;
break;
case 'decm':
this.decMFocused = isFocused;
break
case 'decs':
this.decSFocused = isFocused;
break;
}
}
decChange(prop: string): void { decChange(prop: string): void {
if (prop === 'degree') { if (prop === 'degree') {
if (this.decDegree.valid) { if (this.decDegree.valid) {
this.decDegree2HMS(this.decDegree.value); this.decDegree2HMS(this.decDegree.value);
this.updateConeSearch.emit({ ra: this.ra, dec: this.decDegree.value, radius: this.radius } as ConeSearch);
} else { } else {
this.decH.reset(); this.decH.reset();
this.decM.reset(); this.decM.reset();
this.decS.reset(); this.decS.reset();
this.updateConeSearch.emit({ ra: this.ra, dec: this.decDegree.value, radius: this.radius } as ConeSearch);
} }
this.updateConeSearch.emit({ ra: this.ra, dec: this.decDegree.value, radius: this.radius } as ConeSearch);
} else { } else {
if (this.decH.valid && this.decM.valid && this.decS.valid) { if (this.decH.valid && this.decM.valid && this.decS.valid) {
this.setToDefaultValue(); this.setToDefaultValue();
...@@ -122,7 +138,6 @@ export class DecComponent { ...@@ -122,7 +138,6 @@ export class DecComponent {
this.updateConeSearch.emit({ ra: this.ra, dec: this.decDegree.value, radius: this.radius } as ConeSearch); this.updateConeSearch.emit({ ra: this.ra, dec: this.decDegree.value, radius: this.radius } as ConeSearch);
} else { } else {
this.decDegree.reset(); this.decDegree.reset();
this.updateConeSearch.emit({ ra: this.ra, dec: this.decDegree.value, radius: this.radius } as ConeSearch);
} }
} }
this.resetResolver(); this.resetResolver();
......
...@@ -11,7 +11,14 @@ ...@@ -11,7 +11,14 @@
<div class="row mt-2 px-3"> <div class="row mt-2 px-3">
<div class="col px-0 pr-xl-1"> <div class="col px-0 pr-xl-1">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" [formControl]="raH" (input)="raChange('hms')" (change)="setToDefaultValue()" autocomplete="off"> <input type="text"
class="form-control"
[formControl]="raH"
(input)="raChange('hms')"
(focusin)="changeFocus('rah', true)"
(focusout)="changeFocus('rah', false)"
(change)="setToDefaultValue()"
autocomplete="off">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text">H</span> <span class="input-group-text">H</span>
</div> </div>
...@@ -20,7 +27,14 @@ ...@@ -20,7 +27,14 @@
<div class="w-100 d-block d-xl-none"></div> <div class="w-100 d-block d-xl-none"></div>
<div class="col mt-1 mt-xl-auto px-0 pr-xl-1"> <div class="col mt-1 mt-xl-auto px-0 pr-xl-1">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" [formControl]="raM" (input)="raChange('hms')" (change)="setToDefaultValue()" autocomplete="off"> <input type="text"
class="form-control"
[formControl]="raM"
(input)="raChange('hms')"
(focusin)="changeFocus('ram', true)"
(focusout)="changeFocus('ram', false)"
(change)="setToDefaultValue()"
autocomplete="off">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text">'</span> <span class="input-group-text">'</span>
</div> </div>
...@@ -29,7 +43,14 @@ ...@@ -29,7 +43,14 @@
<div class="w-100 d-block d-xl-none"></div> <div class="w-100 d-block d-xl-none"></div>
<div class="col mt-1 mt-xl-auto px-0"> <div class="col mt-1 mt-xl-auto px-0">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" [formControl]="raS" (input)="raChange('hms')" (change)="setToDefaultValue()" autocomplete="off"> <input type="text"
class="form-control"
[formControl]="raS"
(input)="raChange('hms')"
(focusin)="changeFocus('ras', true)"
(focusout)="changeFocus('ras', false)"
(change)="setToDefaultValue()"
autocomplete="off">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text">''</span> <span class="input-group-text">''</span>
</div> </div>
...@@ -45,7 +66,7 @@ ...@@ -45,7 +66,7 @@
{{ raDegree.errors.range.value }} {{ raDegree.errors.range.value }}
</div> </div>
</div> </div>
<div *ngIf="raH.invalid && (raH.dirty || raH.touched)" class="row px-3 text-danger"> <div *ngIf="raH.invalid" class="row px-3 text-danger">
<div *ngIf="raH.errors.nan"> <div *ngIf="raH.errors.nan">
{{ raH.errors.nan.value }} {{ raH.errors.nan.value }}
</div> </div>
...@@ -53,7 +74,7 @@ ...@@ -53,7 +74,7 @@
{{ raH.errors.range.value }} {{ raH.errors.range.value }}
</div> </div>
</div> </div>
<div *ngIf="raM.invalid && (raM.dirty || raM.touched)" class="row px-3 text-danger"> <div *ngIf="raM.invalid" class="row px-3 text-danger">
<div *ngIf="raM.errors.nan"> <div *ngIf="raM.errors.nan">
{{ raM.errors.nan.value }} {{ raM.errors.nan.value }}
</div> </div>
...@@ -61,7 +82,7 @@ ...@@ -61,7 +82,7 @@
{{ raM.errors.range.value }} {{ raM.errors.range.value }}
</div> </div>
</div> </div>
<div *ngIf="raS.invalid && (raS.dirty || raS.touched)" class="row px-3 text-danger"> <div *ngIf="raS.invalid" class="row px-3 text-danger">
<div *ngIf="raS.errors.nan"> <div *ngIf="raS.errors.nan">
{{ raS.errors.nan.value }} {{ raS.errors.nan.value }}
</div> </div>
......
...@@ -22,7 +22,7 @@ export class RaComponent { ...@@ -22,7 +22,7 @@ export class RaComponent {
this.radius = coneSearch.radius; this.radius = coneSearch.radius;
if (coneSearch.ra) { if (coneSearch.ra) {
this.raDegree.setValue(coneSearch.ra); this.raDegree.setValue(coneSearch.ra);
if (this.raDegree.valid) { if (this.raDegree.valid && !this.raHFocused && !this.raMFocused && !this.raSFocused) {
this.raDegree2HMS(coneSearch.ra); this.raDegree2HMS(coneSearch.ra);
} }
} else { } else {
...@@ -56,6 +56,9 @@ export class RaComponent { ...@@ -56,6 +56,9 @@ export class RaComponent {
isDisabled = false; isDisabled = false;
isDegree = true; isDegree = true;
resolvedRa: number; resolvedRa: number;
raHFocused: boolean = false;
raMFocused: boolean = false;
raSFocused: boolean = false;
raDegree = new FormControl('', [Validators.required, nanValidator, rangeValidator(0, 360, 'RA')]); raDegree = new FormControl('', [Validators.required, nanValidator, rangeValidator(0, 360, 'RA')]);
raH = new FormControl('', [nanValidator, rangeValidator(0, 24, 'Hours')]); raH = new FormControl('', [nanValidator, rangeValidator(0, 24, 'Hours')]);
...@@ -101,6 +104,20 @@ export class RaComponent { ...@@ -101,6 +104,20 @@ export class RaComponent {
this.raDegree.setValue(deg); this.raDegree.setValue(deg);
} }
changeFocus(field: string, isFocused: boolean) {
switch (field) {
case 'rah':
this.raHFocused = isFocused;
break;
case 'ram':
this.raMFocused = isFocused;
break
case 'ras':
this.raSFocused = isFocused;
break;
}
}
raChange(prop: string): void { raChange(prop: string): void {
if (prop === 'degree') { if (prop === 'degree') {
if (this.raDegree.valid) { if (this.raDegree.valid) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment