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