Skip to content

Commit

Permalink
feat: add select destination component
Browse files Browse the repository at this point in the history
Add destination component to filter imports on destination

Reviewed-by: andriac
  • Loading branch information
andriacap committed Jan 30, 2024
1 parent ea5fdf1 commit e4555cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ <h5 class="card-title mb-0">Liste des imports</h5>
</div>
<div class="card-body">
<div *ngIf="!empty">
<pnx-destinations label="{{ 'Import.Destinations' | translate }}" [parentFormControl]="selectDestinationForm">
</pnx-destinations>
<input
[formControl]="search"
id="search"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ImportProcessService } from '../import_process/import-process.service';
import { Import } from '../../models/import.model';
import { ConfigService } from '@geonature/services/config.service';
import { CsvExportService } from '../../services/csv-export.service';
import { DestCode } from '../../models/enums.model';

@Component({
styleUrls: ['import-list.component.scss'],
Expand All @@ -24,6 +25,7 @@ export class ImportListComponent implements OnInit {
public deleteOne: Import;
public interval: any;
public search = new FormControl();
public selectDestinationForm = new FormControl();
public total: number;
public offset: number;
public limit: number;
Expand Down Expand Up @@ -58,6 +60,14 @@ export class ImportListComponent implements OnInit {
}
}, 500);
});

this.selectDestinationForm.valueChanges.subscribe((desCode: DestCode) => {
setTimeout(() => {
if (desCode == this.selectDestinationForm.value) {
this.updateOnDest(desCode);
}
}, 500);
});
}

ngOnDestroy() {
Expand All @@ -72,8 +82,12 @@ export class ImportListComponent implements OnInit {
// listes des colonnes selon lesquelles filtrer
}

private onImportList(page, search) {
this._ds.getImportList({ page: page, search: search }).subscribe((res) => {
updateOnDest(destCode: DestCode) {
this.onImportList(1, '', destCode);
}

private onImportList(page, search, destination: DestCode = null) {
this._ds.getImportList({ page: page, search: search }, destination).subscribe((res) => {
this.history = res['imports'];
this.getImportsStatus();

Expand Down

0 comments on commit e4555cd

Please sign in to comment.