Skip to content

Commit

Permalink
Add new jsStyle page template for map element color and style
Browse files Browse the repository at this point in the history
  • Loading branch information
computate committed Dec 8, 2023
1 parent c18aaa9 commit 67da796
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/computate/frFR/java/ConfigCles.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public class ConfigCles {
public static final String var_initLoin = "var_initLoin";
public static final String var_InitLoin = "var_InitLoin";
public static final String var_Interne = "var_Interne";
public static final String var_jsStyle = "var_jsStyle";
public static final String var_jsInfobulle = "var_jsInfobulle";
public static final String var_JsInfobulle = "var_JsInfobulle";
public static final String var_jsWebsocket = "var_jsWebsocket";
Expand Down
47 changes: 13 additions & 34 deletions src/main/java/org/computate/frFR/java/EcrirePageClasse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,7 @@ else if("LocalDate".equals(entiteNomSimple)) {
l("{{#partial \"", langueConfig.getString(ConfigCles.var_jsWebsocket), "\"}}{{> ", langueConfig.getString(ConfigCles.var_jsWebsocket), classePageNomSimple, "}}{{/partial}}");
l("{{#partial \"", langueConfig.getString(ConfigCles.var_jsInfobulle), "\"}}{{> ", langueConfig.getString(ConfigCles.var_jsInfobulle), "", classePageNomSimple, "}}{{/partial}}");
l("{{#partial \"", langueConfig.getString(ConfigCles.var_htmInfobulle), "\"}}{{> ", langueConfig.getString(ConfigCles.var_htmInfobulle), "", classePageNomSimple, "}}{{/partial}}");
l("{{#partial \"", langueConfig.getString(ConfigCles.var_jsStyle), "\"}}{{> ", langueConfig.getString(ConfigCles.var_jsStyle), "", classePageNomSimple, "}}{{/partial}}");
l("{{#partial \"htmBodySidebar\"}}{{> htmBodySidebar", classePageNomSimple, "}}{{/partial}}");
l("{{#partial \"htmBody", langueConfig.getString(ConfigCles.var_Debut), "\"}}{{> htmBody", langueConfig.getString(ConfigCles.var_Debut), classePageNomSimple, "}}{{/partial}}");
l("{{#partial \"htmBody", langueConfig.getString(ConfigCles.var_Milieu), "\"}}{{> htmBody", langueConfig.getString(ConfigCles.var_Milieu), classePageNomSimple, "}}{{/partial}}");
Expand Down Expand Up @@ -3187,6 +3188,10 @@ else if(entiteAttribuer) {
tl(3, "function ", langueConfig.getString(ConfigCles.var_htmInfobulle), classeNomSimple, "(feature, layer) {");
tl(4, "return `{{#block \"", langueConfig.getString(ConfigCles.var_htmInfobulle), "\"}}{{/block}}`;");
tl(3, "}");
l();
tl(3, "function ", langueConfig.getString(ConfigCles.var_jsStyle), classeNomSimple, "(feature) {");
tl(0, "{{#block \"", langueConfig.getString(ConfigCles.var_jsStyle), "\"}}{{/block}}");
tl(3, "}");
tl(2, "</script>");
tl(0, "{{/inline}}");

Expand All @@ -3197,6 +3202,7 @@ else if(entiteAttribuer) {
tl(0, "{{#*inline \"", langueConfig.getString(ConfigCles.var_jsWebsocket), classePageNomSimple, "\"}}{{/inline}}");
tl(0, "{{#*inline \"", langueConfig.getString(ConfigCles.var_jsInfobulle), classePageNomSimple, "\"}}{{/inline}}");
tl(0, "{{#*inline \"", langueConfig.getString(ConfigCles.var_htmInfobulle), classePageNomSimple, "\"}}{{/inline}}");
tl(0, "{{#*inline \"", langueConfig.getString(ConfigCles.var_jsStyle), classePageNomSimple, "\"}}{{/inline}}");
}
t(0, "{{#*inline \"htmUrl", classeApiClasseNomSimple, "\"}}");
s("{{pageUri}}");
Expand Down Expand Up @@ -4765,55 +4771,28 @@ else if(langueConfig.getString(ConfigCles.var_PUTCopie).equals(classeApiMethode)
// auteurPageJs.tl(5, "});");
// auteurPageJs.tl(4, "} else {");
auteurPageJs.tl(4, "var shapes = [];");
auteurPageJs.tl(4, "var features = [];");
auteurPageJs.tl(4, "function onEachFeature(feature, layer) {");
auteurPageJs.tl(5, "let popupContent = ", langueConfig.getString(ConfigCles.var_htmInfobulle), classeNomSimple, "(feature, layer);");
auteurPageJs.tl(5, "layer.bindPopup(popupContent);");
auteurPageJs.tl(4, "};");
auteurPageJs.tl(4, "if(Array.isArray(", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacement, "))");
auteurPageJs.tl(5, "shapes = shapes.concat(", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacement, ");");
auteurPageJs.tl(4, "else");
auteurPageJs.tl(5, "shapes.push(", StringUtils.uncapitalize(classeNomSimple), ".", classeVarEmplacement, ");");
auteurPageJs.tl(4, "shapes.forEach(shape => {");
auteurPageJs.tl(5, "features.push({");
auteurPageJs.tl(5, "var features = [{");
auteurPageJs.tl(6, "\"type\": \"Feature\"");
auteurPageJs.tl(6, ", \"properties\": ", StringUtils.uncapitalize(classeNomSimple));
auteurPageJs.tl(6, ", \"geometry\": shape");
auteurPageJs.tl(5, "});");
// auteurPageJs.tl(5, "var parts = [];");
// auteurPageJs.tl(5, "if(shape.coordinates && shape.coordinates[0].length > 0 && Array.isArray(shape.coordinates[0][0]))");
// auteurPageJs.tl(6, "parts = parts.concat(shape.coordinates);");
// auteurPageJs.tl(5, "else");
// auteurPageJs.tl(6, "parts.push(shape.coordinates);");
// auteurPageJs.tl(5, "parts.forEach(part => {");
// auteurPageJs.tl(6, "var lat = part.map(elem => elem[0]);");
// auteurPageJs.tl(6, "var lon = part.map(elem => elem[1]);");
// auteurPageJs.tl(6, "if(shape.type == 'Polygon') {");
// auteurPageJs.tl(7, "lat.push(lat[0]);");
// auteurPageJs.tl(7, "lon.push(lon[0]);");
// auteurPageJs.tl(6, "}");
// auteurPageJs.tl(6, "data.push({");
// auteurPageJs.tl(7, "type: 'scattermapbox'");
// auteurPageJs.tl(7, ", name: ", StringUtils.uncapitalize(classeNomSimple), ".", classeVarTitre);
// auteurPageJs.tl(7, ", lat: lat");
// auteurPageJs.tl(7, ", lon: lon");
// auteurPageJs.tl(7, ", mode: 'lines+markers'");
// auteurPageJs.tl(7, ", line:{");
// auteurPageJs.tl(8, "width: 2,");
// auteurPageJs.tl(8, "color: 'red'");
// auteurPageJs.tl(7, "}");
// auteurPageJs.tl(6, "});");
// auteurPageJs.tl(5, "});");
auteurPageJs.tl(5, "}];");
auteurPageJs.tl(5, "L.geoJSON(features, {onEachFeature: onEachFeature, style: ", langueConfig.getString(ConfigCles.var_jsStyle), classeNomSimple, "}).addTo(map);");
auteurPageJs.tl(4, "});");
auteurPageJs.tl(4, "function onEachFeature(feature, layer) {");
auteurPageJs.tl(5, "let popupContent = ", langueConfig.getString(ConfigCles.var_htmInfobulle), classeNomSimple, "(feature, layer);");
auteurPageJs.tl(5, "layer.bindPopup(popupContent);");
auteurPageJs.tl(4, "}");
auteurPageJs.tl(4, "var geojsonLayer = L.geoJSON(features, {onEachFeature}).addTo(map);");
// auteurPageJs.tl(4, "}");
auteurPageJs.tl(3, "}");
auteurPageJs.tl(2, "});");
auteurPageJs.tl(2, "map.on('popupopen', function(e) {");
auteurPageJs.tl(3, "var feature = e.popup._source.feature;");
auteurPageJs.tl(3, langueConfig.getString(ConfigCles.var_jsInfobulle), classeNomSimple, "(e, feature);");
auteurPageJs.tl(2, "});");
// auteurPageJs.tl(2, "Plotly.react(, data, layout);");
}
auteurPageJs.tl(1, "}");
auteurPageJs.tl(0, "}");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/org/computate/i18n/i18n_enUS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ var_InheritClePrimaire: "InheritPrimaryKey"
var_initLoin: "initDeep"
var_InitLoin: "InitDeep"
var_Interne: "Internal"
var_jsStyle: "jsStyle"
var_jsInfobulle: "jsTooltip"
var_JsInfobulle: "JsTooltip"
var_jsWebsocket: "jsWebsocket"
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/org/computate/i18n/i18n_frFR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ var_InheritClePrimaire: "InheritClePrimaire"
var_initLoin: "initLoin"
var_InitLoin: "InitLoin"
var_Interne: "Interne"
var_jsStyle: "jsStyle"
var_jsInfobulle: "jsInfobulle"
var_JsInfobulle: "JsInfobulle"
var_jsWebsocket: "jsWebsocket"
Expand Down

0 comments on commit 67da796

Please sign in to comment.