Skip to content
Snippets Groups Projects
Commit 26ae1061 authored by Angapay Divin's avatar Angapay Divin
Browse files

display add button for research by resolver

parent 9b249e13
No related branches found
No related tags found
1 merge request!55Draft: Resolve "Pas de bouton pour ajouter le critère de cone search quand on fait une recherche avec le résolveur"
This commit is part of merge request !55. Comments created here will be created in the context of that merge request.
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; import { IfStmt } from '@angular/compiler';
import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges, OnInit } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms'; import { FormGroup, FormControl, Validators } from '@angular/forms';
import { ConeSearch, Resolver } from 'src/app/instance/store/models'; import { ConeSearch, Resolver } from 'src/app/instance/store/models';
import { nanValidator, rangeValidator } from '../validators'; import { nanValidator, rangeValidator } from '../validators';
import { pairwise, startWith } from 'rxjs/operators';
/** /**
* @class * @class
...@@ -23,7 +25,8 @@ import { nanValidator, rangeValidator } from '../validators'; ...@@ -23,7 +25,8 @@ import { nanValidator, rangeValidator } from '../validators';
selector: 'app-cone-search', selector: 'app-cone-search',
templateUrl: 'cone-search.component.html' templateUrl: 'cone-search.component.html'
}) })
export class ConeSearchComponent implements OnChanges { export class ConeSearchComponent implements OnChanges, OnInit {
@Input() coneSearch: ConeSearch; @Input() coneSearch: ConeSearch;
@Input() resolver: Resolver; @Input() resolver: Resolver;
@Input() resolverIsLoading: boolean; @Input() resolverIsLoading: boolean;
...@@ -45,12 +48,21 @@ export class ConeSearchComponent implements OnChanges { ...@@ -45,12 +48,21 @@ export class ConeSearchComponent implements OnChanges {
}), }),
radius: new FormControl(2, [Validators.required, rangeValidator(0, 150, 'Radius')]) radius: new FormControl(2, [Validators.required, rangeValidator(0, 150, 'Radius')])
}); });
public formIsInValid: boolean = this.form.invalid;
public unit = 'degree'; public unit = 'degree';
ngOnInit(): void {
this.form.statusChanges.subscribe(
status =>{
this.formIsInValid = status === 'INVALID'? true: false;
}
)
}
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
if (changes.resolver && changes.resolver.currentValue) { if (changes.resolver && changes.resolver.currentValue) {
this.unit = 'degree'; this.unit = 'degree';
} }
if (changes.coneSearch && !changes.coneSearch.currentValue) { if (changes.coneSearch && !changes.coneSearch.currentValue) {
...@@ -68,8 +80,16 @@ export class ConeSearchComponent implements OnChanges { ...@@ -68,8 +80,16 @@ export class ConeSearchComponent implements OnChanges {
this.form.patchValue(this.coneSearch); this.form.patchValue(this.coneSearch);
this.form.disable(); this.form.disable();
} }
// update formIsValid when resolver is loaded
if (changes.resolverIsLoaded && changes.resolverIsLoaded.currentValue) {
this.formIsInValid = !changes.resolverIsLoaded.currentValue;
}
} }
/** /**
* Returns cone-search from form. * Returns cone-search from form.
* *
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</app-cone-search> </app-cone-search>
</div> </div>
<div class="col-2 text-center align-self-end"> <div class="col-2 text-center align-self-end">
<button class="btn btn-outline-success" *ngIf="!coneSearch" [hidden]="cs.form.invalid" (click)="addConeSearch.emit(cs.getConeSearch())"> <button class="btn btn-outline-success" *ngIf="!coneSearch" [hidden]="cs.formIsInValid" (click)="addConeSearch.emit(cs.getConeSearch())">
<span class="fas fa-plus fa-fw"></span> <span class="fas fa-plus fa-fw"></span>
</button> </button>
<button class="btn btn-outline-danger" *ngIf="coneSearch" (click)="deleteConeSearch.emit()"> <button class="btn btn-outline-danger" *ngIf="coneSearch" (click)="deleteConeSearch.emit()">
......
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