Skip to content

Commit

Permalink
fix(spatial-filter): fix spatial filter 1.4 (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeLafreniere18 authored and Marc-André Barbeau committed Sep 8, 2020
1 parent 5ab33b2 commit ba2d240
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="import-export-toggle mat-typography">
<mat-button-toggle-group
[value]="activeImportExport"
[value]="selectedMode"
(change)="onImportExportChange($event)">
<mat-button-toggle [value]="'import'">
{{'igo.geo.importExportForm.importTabTitle' | translate}}
Expand All @@ -11,7 +11,7 @@
</mat-button-toggle-group>
</div>

<form class="igo-form" *ngIf="activeImportExport === 'import'">
<form class="igo-form" *ngIf="selectedMode === 'import'">
<div class="igo-input-container">
<mat-form-field>
<input
Expand All @@ -36,7 +36,7 @@
(change)="importFiles($event.target.files)">
</div>
</form>
<section class="mat-typography" *ngIf="activeImportExport === 'import'">
<section class="mat-typography" *ngIf="selectedMode === 'import'">
<h4>{{'igo.geo.importExportForm.importClarifications' | translate}}</h4>
<ul>
<li>{{'igo.geo.importExportForm.importSizeMax' | translate: {size: fileSizeMb} }}</li>
Expand All @@ -45,11 +45,11 @@ <h4>{{'igo.geo.importExportForm.importClarifications' | translate}}</h4>
</ul>
</section>

<section class="mat-typography" *ngIf="(exportableLayers$ | async).length === 0 && activeImportExport === 'export'">
<section class="mat-typography" *ngIf="(exportableLayers$ | async).length === 0 && selectedMode === 'export'">
<h4>{{'igo.geo.importExportForm.exportNoLayersExportable' | translate}}</h4>
</section>

<form class="igo-form" [formGroup]="form" *ngIf="(exportableLayers$ | async).length > 0 && activeImportExport === 'export'">
<form class="igo-form" [formGroup]="form" *ngIf="(exportableLayers$ | async).length > 0 && selectedMode === 'export'">
<div class="igo-input-container">
<mat-form-field>
<mat-label>{{'igo.geo.importExportForm.exportLayerPlaceholder' | translate}}</mat-label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export class ImportExportComponent implements OnDestroy, OnInit {

private espgCodeRegex = new RegExp('^\\d{4,6}');
private clientSideFileSizeMax: number;
public activeImportExport: string = 'import';
public fileSizeMb: number;

private previousLayerSpecs$: BehaviorSubject<
Expand All @@ -74,9 +73,9 @@ export class ImportExportComponent implements OnDestroy, OnInit {

@Input() map: IgoMap;

@Input() selectedIndex: number = 0;
@Input() selectedMode = 'import';

@Output() selectedTabIndex = new EventEmitter<number>();
@Output() selectMode = new EventEmitter<string>();

@Input() exportOptions$: BehaviorSubject<ExportOptions> = new BehaviorSubject(
undefined
Expand All @@ -96,9 +95,6 @@ export class ImportExportComponent implements OnDestroy, OnInit {
) {
this.loadConfig();
this.buildForm();
console.log(this);
console.log(this.form);
console.log(this.form);
}

ngOnInit() {
Expand Down Expand Up @@ -473,15 +469,15 @@ export class ImportExportComponent implements OnDestroy, OnInit {
});
}

public tabChanged(tab: MatTabChangeEvent) {
this.selectedTabIndex.emit(tab.index);
public modeChanged(mode) {
this.selectMode.emit(mode);
}

private onFileExportSuccess() {
handleFileExportSuccess(this.messageService, this.languageService);
}

onImportExportChange(event) {
this.activeImportExport = event.value;
this.selectedMode = event.value;
}
}
8 changes: 7 additions & 1 deletion packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@
"culturel": "Cultural",
"education": "Education",
"sante": "Health",
"securite": "Security"
"securite": "Security",
"sepaq": "SEPAQ",
"transport": "Transportation"
}
},
"terrapi": {
Expand All @@ -435,6 +437,10 @@
"hydro": "Hydrography",
"routes": "Roads",
"bati": "Buildings",
"batiment": "Buildings",
"camping": "Camping",
"equipement": "Equipment",
"commun": "Public",
"geographie": "Natural sites",
"parc": "Parks",
"secteur": "Sector",
Expand Down
8 changes: 7 additions & 1 deletion packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@
"culturel": "Culturel",
"education": "Éducation",
"sante": "Santé",
"securite": "Sécurité"
"securite": "Sécurité",
"sepaq": "SÉPAQ",
"transport": "Transport"
}
},
"terrapi": {
Expand All @@ -436,6 +438,10 @@
"hydro": "Hydrographie",
"routes": "Routes",
"bati": "Bâtiments",
"batiment": "Bâtiments",
"camping": "Camping",
"equipement": "Équipements",
"commun": "Commun",
"geographie": "Lieux naturels",
"parc": "Parcs",
"secteur": "Secteurs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
SpatialFilterQueryType,
SpatialFilterThematic,
Layer,
createOverlayMarkerStyle
createOverlayMarkerStyle,
ExportOptions
} from '@igo2/geo';
import { EntityStore, ToolComponent } from '@igo2/common';
import olFormatGeoJSON from 'ol/format/GeoJSON';
Expand Down Expand Up @@ -102,7 +103,12 @@ export class SpatialFilterToolComponent {
}

activateExportTool() {
this.importExportState.setSelectedTab(1);
const ids = [];
for (const layer of this.layers) {
ids.push(layer.id);
}
this.importExportState.setMode('export');
this.importExportState.setsExportOptions({ layer: ids } as ExportOptions);
this.toolState.toolbox.activateTool('importExport');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<mat-tab-group>
<mat-tab [label]="'igo.integration.importExportTool.importExportData' | translate">
<igo-import-export [map]="map"
[selectedIndex]="importExportState.selectedTab$ | async"
(selectedTabIndex)="tabChanged($event)"
[selectedMode]="importExportState.selectedMode$ | async"
(selectMode)="modeChanged($event)"
[exportOptions$]="importExportState.exportOptions$"
(exportOptionsChange)="exportOptionsChange($event)">
</igo-import-export>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ export class ImportExportToolComponent implements OnInit {
) {}

ngOnInit(): void {
this.selectedTab();
this.selectMode();
}

private selectedTab() {
const userSelectedTab = this.importExportState.selectedTab$.value;
if (userSelectedTab !== undefined) {
this.importExportState.setSelectedTab(userSelectedTab);
private selectMode() {
const userSelectedMode = this.importExportState.selectedMode$.value;
if (userSelectedMode !== undefined) {
this.importExportState.setMode(userSelectedMode);
} else {
this.importExportState.setSelectedTab(0);
this.importExportState.setMode('import');

}
}

public tabChanged(tab: number) {
this.importExportState.setSelectedTab(tab);
public modeChanged(mode: string) {
this.importExportState.setMode(mode);
}

public exportOptionsChange(exportOptions: ExportOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { ExportOptions } from '@igo2/geo';
})
export class ImportExportState {

readonly selectedTab$: BehaviorSubject<number> = new BehaviorSubject(undefined);
readonly selectedMode$: BehaviorSubject<string> = new BehaviorSubject(undefined);
readonly exportOptions$: BehaviorSubject<ExportOptions> = new BehaviorSubject(undefined);

setSelectedTab(tab: number) {
this.selectedTab$.next(tab);
setMode(mode: string) {
this.selectedMode$.next(mode);
}

setsExportOptions(exportOptions: ExportOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class MapDetailsToolComponent implements OnInit {

activateExport(id: string) {
this.importExportState.setsExportOptions({ layer: [id] } as ExportOptions);
this.importExportState.setSelectedTab(1);
this.importExportState.setMode('export');
this.toolState.toolbox.activateTool('importExport');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class MapToolComponent {

activateExport(id: string) {
this.importExportState.setsExportOptions({ layer: [id] } as ExportOptions);
this.importExportState.setSelectedTab(1);
this.importExportState.setMode('export');
this.toolState.toolbox.activateTool('importExport');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class MapToolsComponent implements OnInit, OnDestroy {

activateExport(id: string) {
this.importExportState.setsExportOptions({ layer: [id] } as ExportOptions);
this.importExportState.setSelectedTab(1);
this.importExportState.setMode('export');
this.toolState.toolbox.activateTool('importExport');
}

Expand Down

0 comments on commit ba2d240

Please sign in to comment.