Skip to content

Commit

Permalink
#7 L18n warn message on pluginConfig + link cursor pointer style
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine37120 committed Apr 25, 2024
1 parent 25af263 commit e7f19b0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/sparnatural-yasr-map-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ interface PluginConfig {
zoom?: number,
options?: L.ZoomPanOptions
}
parsingFunction: (literalValue:string)=> Geometry
parsingFunction: (literalValue:string)=> Geometry,
L18n: {
warnfindNoCoordinate: string, // use "<count>" patern to replace with count of results with no geo coordinates
warnfindNoCoordinateBtn: string // Link label for plugin table display on warnig message
}

}

// represents a yasr result cell with a geo literal
Expand Down Expand Up @@ -154,7 +159,11 @@ export class MapPlugin implements SparnaturalPlugin<PluginConfig>{
zoom: 11,
options: undefined
},
parsingFunction: wktToGeoJson
parsingFunction: wktToGeoJson,
L18n: {
warnfindNoCoordinate: 'Attention, des résultats (<count>) n\'ont pas de coordonnées pour être représentés sur la carte.',
warnfindNoCoordinateBtn: 'Afficher la table des résultats'
}

}

Expand Down Expand Up @@ -438,18 +447,21 @@ export class MapPlugin implements SparnaturalPlugin<PluginConfig>{
this.warnEL = document.createElement('div')
this.warnEL.setAttribute('id','yasrmap-warnEL')
this.warnEL.setAttribute('class','alert alert-warning')
this.warnEL.innerText ='Attention, des résultats ('+this.haveResultWithoutGeo+') n\'ont pas de coordonnées pour être représentés sur la carte.' ;
let text = this.config.L18n.warnfindNoCoordinate.replace("<count>", this.haveResultWithoutGeo.toString())
this.warnEL.innerText = text;

parentEl.appendChild(this.warnEL) ;
let linkToTable = document.createElement('a');
linkToTable.classList.add('link', 'ms-2');
linkToTable.innerText = 'Afficher la table des résultats' ;
linkToTable.setAttribute('style', "cursor: pointer;");
linkToTable.innerText = this.config.L18n.warnfindNoCoordinateBtn ;
this.warnEL.appendChild(linkToTable) ;
linkToTable.addEventListener("click", ()=>{
(this.yasr as any).selectPlugin("table") ;
return false;
});
}



// Create the map HTMLElement
Expand Down

0 comments on commit e7f19b0

Please sign in to comment.