Skip to content

Commit

Permalink
refactor(app): added types for feature selection in list
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-litwiller committed Aug 23, 2023
1 parent 611169d commit 006fdd8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<app-portal class="app-portal" [ngClass]="hasHeader? 'portal-hasHeader': 'portal'" (workspaceSelected)="setSelectedWorkspace($event)"
(mapQueryEvent)="setClickedEntities($event)"
[features]="features"
[feature]="feature"
[additionalProperties]="additionalProperties"
[entitiesAll]="entitiesAll"
[entitiesList]="entitiesList"
Expand Down
5 changes: 2 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class AppComponent implements OnInit {

public terrAPIBaseURL: string = "https://geoegl.msp.gouv.qc.ca/apis/terrapi/"; // base URL of the terrAPI API
public terrAPITypes: Array<string>; // an array of strings containing the types available from terrAPI
public features: any = null; //object: {added: Feature[]}
public feature: Feature = null; // selected feature in the list
public clickedEntities: Feature[] = [];

public showSimpleFilters: boolean = false;
Expand Down Expand Up @@ -228,10 +228,9 @@ export class AppComponent implements OnInit {
}

onListSelection(event){
this.features = event;
this.feature = event;
}


/**
* @description retrieves all non-property types from the config file and adds them to additionalTypes if they are valid terrAPI types
* @returns additionalTypes array made up of valid TerrAPI types that are not contained in the entities properties
Expand Down
7 changes: 1 addition & 6 deletions src/app/pages/list/simple-feature-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ export class SimpleFeatureListComponent implements OnInit, OnChanges, OnDestroy
this.entitiesList$$.unsubscribe();
}

//TODO
private sortEntities(entities: Array<Feature>, sortBy: string) {
if(this.selectedEntitiesList) this.clickedEntitiesOverridden();
//types contained in terrapi
Expand Down Expand Up @@ -385,11 +384,7 @@ export class SimpleFeatureListComponent implements OnInit, OnChanges, OnDestroy
*/
selectEntity(entity: Feature) {
// update the store and emit the entity to parent
// this.entityStore.state.updateAll({selected: false});
// this.entityStore.state.update(entity, {selected: true}, true);
let entityCollection: {added: Array<Feature>} = {added: []};
entityCollection.added.push(entity);
this.listSelection.emit(entityCollection);
this.listSelection.emit(entity);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/app/pages/portal/portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ import { MapBrowserEvent } from 'ol';
})

export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnChanges {
@Input() features = {added: []};
@Input() feature: Feature;
@Output() workspaceSelected = new EventEmitter<Workspace>();
@Output() mapQueryEvent = new EventEmitter<Feature[]>();
@Input() additionalProperties: Map<string, Map<string, string>> = new Map();
Expand Down Expand Up @@ -616,9 +616,10 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
}

ngOnChanges(changes: SimpleChanges) {
if(changes.features && changes.features.currentValue !== null){
this.zoomToSelectedFeature(changes.features.currentValue);
this.entitySelectChange(changes.features.currentValue);
if(changes.feature && changes.feature.currentValue !== null){
let selectedFeature = changes.feature.currentValue;
this.zoomToSelectedFeature([selectedFeature]);
this.entitySelectChange({added: [selectedFeature]});
}
}

Expand Down Expand Up @@ -1256,8 +1257,7 @@ export class PortalComponent implements OnInit, AfterContentInit, OnDestroy, OnC
* @description zooms to the selected feature on the map
* @param features the feature to zoom to
*/
zoomToSelectedFeature(features: any) {
const featuresSelected: Array<Feature> = features["added"];
zoomToSelectedFeature(featuresSelected: Feature[]) {
let format = new olFormatGeoJSON();

const olFeaturesSelected = [];
Expand Down

0 comments on commit 006fdd8

Please sign in to comment.