fix labourage form stats

This commit is contained in:
Tykayn 2025-06-25 00:32:46 +02:00 committed by tykayn
parent 1ad909cb86
commit d2d2ebe0f0
4 changed files with 55 additions and 26 deletions

View file

@ -7,6 +7,9 @@
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.css';
import jQuery from 'jquery';
window.$ = jQuery;
window.jQuery = jQuery;
import 'tablesort/tablesort.css';
// start the Stimulus application
@ -33,13 +36,11 @@ import {
toggleCompletionInfo,
updateMapHeightForLargeScreens
} from './utils.js';
import Tablesort from 'tablesort';
import TableSort from 'table-sort-js/table-sort.js';
import $ from 'jquery';
window.$ = $;
window.jQuery = $;
// import Tablesort from 'tablesort';
// import TableSort from 'table-sort-js/table-sort.js';
// Charger table-sortable (version non minifiée locale)
import '../assets/js/table-sortable.js';
// import '../assets/js/table-sortable.js';
window.Chart = Chart;
window.genererCouleurPastel = genererCouleurPastel;
@ -50,7 +51,7 @@ window.ChartDataLabels = ChartDataLabels;
window.maplibregl = maplibregl;
window.toggleCompletionInfo = toggleCompletionInfo;
window.updateMapHeightForLargeScreens = updateMapHeightForLargeScreens;
window.Tablesort = Tablesort;
// window.Tablesort = Tablesort;
Chart.register(ChartDataLabels);
@ -198,25 +199,49 @@ document.addEventListener('DOMContentLoaded', () => {
adjustListGroupFontSize('.list-group-item');
// Activer le tri naturel sur tous les tableaux avec la classe table-sort
document.querySelectorAll('table.table-sort').forEach(table => {
new TableSort(table);
});
// document.querySelectorAll('table.table-sort').forEach(table => {
// new TableSort(table);
// });
// Initialisation du tri et filtrage sur les tableaux du dashboard et de la page stats
if (document.querySelector('#dashboard-table')) {
$('#dashboard-table').tableSortable({
pagination: false,
showPaginationLabel: true,
searchField: '#dashboard-table-search',
responsive: false
});
}
if (document.querySelector('#stats-table')) {
$('#stats-table').tableSortable({
pagination: false,
showPaginationLabel: true,
searchField: '#stats-table-search',
responsive: false
// if (document.querySelector('#dashboard-table')) {
// $('#dashboard-table').tableSortable({
// pagination: false,
// showPaginationLabel: true,
// searchField: '#dashboard-table-search',
// responsive: false
// });
// }
// if (document.querySelector('#stats-table')) {
// $('#stats-table').tableSortable({
// pagination: false,
// showPaginationLabel: true,
// searchField: '#stats-table-search',
// responsive: false
// });
// }
// Correction pour le formulaire de labourage
const labourerForm = document.getElementById('labourerForm');
if (labourerForm) {
labourerForm.addEventListener('submit', async function(e) {
e.preventDefault();
const zipInput = document.getElementById('selectedZipCode');
const cityInput = document.getElementById('citySearch');
let insee = zipInput.value;
if (!insee && cityInput && cityInput.value.trim().length > 0) {
// Recherche du code INSEE via l'API
const response = await fetch(`https://geo.api.gouv.fr/communes?nom=${encodeURIComponent(cityInput.value.trim())}&fields=nom,code&limit=1`);
const data = await response.json();
if (data.length > 0) {
insee = data[0].code;
}
}
if (insee) {
window.location.href = `/admin/labourer/${insee}`;
} else {
alert('Veuillez sélectionner une ville valide.');
}
});
}
});

File diff suppressed because one or more lines are too long

View file

@ -9,7 +9,7 @@ Ces informations sont utilisées dans des milliers de sites web et annuaires, pa
<p> Vous pouvez le modifier en cliquant sur le bouton ci-dessous, c'est gratuit et sans engagement.</p>
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name != '' ? place.name : '?', 'uuid': place.uuidForUrl}) }}" class="btn btn-primary">
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name != '' ? place.name|replace({'/':'-'})|url_encode : '?', 'uuid': place.uuidForUrl}) }}" class="btn btn-primary">
<i class="bi bi-pencil-square"></i>
Compléter les informations de mon commerce
</a>

View file

@ -5,7 +5,7 @@
{% block body %}
<div class="container mt-4">
<h1>Histogramme de fraîcheur des données OSM</h1>
<p></p>
<p>La fraîcheur des données agrère les informations de dernière modification de chaque lieu. Cette page montre les liens entre budget des villes, nombre d'habitants et budget par habitant et par lieu.</p>
<h2>Par année</h2>
<canvas id="fraicheurHistogrammeAnnee" width="800" height="400" style="max-width:100%; margin: 20px 0;"></canvas>
<h2>Par trimestre</h2>