diff --git a/assets/app.js b/assets/app.js index 97a417a..446c5c0 100644 --- a/assets/app.js +++ b/assets/app.js @@ -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.'); + } }); } }); diff --git a/assets/js/table-sortable.js b/assets/js/table-sortable.js index 58ecd8f..b1e3251 100644 --- a/assets/js/table-sortable.js +++ b/assets/js/table-sortable.js @@ -5,4 +5,8 @@ * (c) Ravi Dhiman https://ravid.dev * For the full copyright and license information, please view the LICENSE */ +// Forcer la présence de jQuery globalement +if (typeof window.jQuery === 'undefined' && typeof window.$ !== 'undefined') { + window.jQuery = window.$; +} !function(t){var e={};function n(a){if(e[a])return e[a].exports;var i=e[a]={i:a,l:!1,exports:{}};return t[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(a,i,function(e){return t[e]}.bind(null,i));return a},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e){t.exports=jQuery},function(t,e,n){t.exports=n(3)},function(t,e,n){},function(t,e,n){"use strict";n.r(e);var a={};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n2?a-2:0),r=2;rparseFloat(e)?1:-1;if(g(t)){var n=new Date(t),a=new Date(e);return n.getTime()>a.getTime()?1:-1}return p(t)?t>e?1:-1:1}return 0},k=function(t,e){var n;return function(){var a=this,i=arguments;clearTimeout(n),n=window.setTimeout((function(){return t.apply(a,i)}),e)}},C=function(t){return p(t)?t.toLowerCase():String(t)},E=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(!e&&!h(e))return!1;var a=m(t);c(n)||(n=a);for(var i=0,r=a.length,o=!1,s=C(e);i-1&&u.indexOf(s)>-1){o=!0;break}if(!n.length&&u.indexOf(s)>-1){o=!0;break}i+=1}return o},w=function(t,e){return c(e)&&e[0]<=t&&e[1]>t},D=function(){function t(){i(this,t),this._name="dataset",this.dataset=null,this._cachedData=null,this._datasetLen=0,this._outLen=10,this.sortDirection={ASC:"asc",DESC:"desc"}}return o(t,[{key:"_formatError",value:function(t,e,n){for(var i=arguments.length,r=new Array(i>3?i-3:0),o=3;oe),"get",'"from" cannot be greater than "to"'),t=Math.max(t,0),e=Math.min(e,this._datasetLen),this.dataset.slice(t,e)}},{key:"sort",value:function(t,e){this._hasDataset(),this._formatError(p(t),"sort",'Requires "column" type of string'),this._formatError(p(e),"sort",'Requires "direction" type of string'),this._formatError("asc"===e||"desc"===e,"sort",'"%s" is invalid sort direction. Use "dataset.sortDirection.ASC" or "dataset.sortDirection.DESC".',e);var n=this.top(1)[0];return this._formatError("undefined"!==typeof n[t],"sort",'Column name "%s" does not exist in collection',t),this.sortDirection.ASC===e?this.dataset.sort((function(e,n){return P(e[t],n[t])})):this.dataset.sort((function(e,n){return P(n[t],e[t])})),this.top(this._datasetLen)}},{key:"pushData",value:function(t){c(t)&&Array.prototype.push.apply(this.dataset,t)}},{key:"lookUp",value:function(t,e){if(p(t)||h(t)){var n=JSON.parse(this._cachedData);this.dataset=""===t?n:v(n,(function(n){return E(n,t,e)})),this._datasetLen=this.dataset.length}}}]),t}(),x=function(t,e,n){return{node:t,attrs:e,children:n}},S=function(t){var e=t.node,n=t.attrs;t.children;return function(t,e){if(!e)return t;for(var n=Object.keys(e),a=0;a")),n)},U=function t(e,n,a){if(a||n.empty(),c(e)){for(var i=[],r=0;r\u25bc",desc:"\u25b2"},nextText:"Next",prevText:"Prev",tableWillMount:function(){},tableDidMount:function(){},tableWillUpdate:function(){},tableDidUpdate:function(){},tableWillUnmount:function(){},tableDidUnmount:function(){},onPaginationChange:null},this._styles=null,this._dataset=null,this._table=null,this._thead=null,this._tbody=null,this._isMounted=!1,this._isUpdating=!1,this._sorting={currentCol:"",dir:""},this._pagination={elm:null,currentPage:0,totalPages:1,visiblePageNumbers:5},this._cachedOption=null,this._cachedViewPort=-1,this.setData=function(t,e,a){n.logError(c(t),"setData","expect first argument as array of objects"),n.logError(d(e),"setData","expect second argument as objects"),n._isMounted&&t&&(a?n._dataset.pushData(t):n._dataset.fromCollection(t),e&&(n.options.columns=e),n.refresh())},this.getData=function(){return n._isMounted?n._dataset.top():[]},this.getCurrentPageData=function(){if(n._isMounted){var t=n.options.rowsPerPage,e=n._pagination.currentPage*t,a=e+t;return n._dataset.get(e,a)}return[]},this.refresh=function(t){t?(n.distroy(),n.create()):n._isMounted&&n.updateTable()},this.distroy=function(){n._isMounted&&(n.emitLifeCycles("tableWillUnmount"),n._table.remove(),n._styles&&n._styles.length&&(n._styles.remove(),n._styles=null),n._dataset=null,n._table=null,n._thead=null,n._tbody=null,n._pagination.elm&&n._pagination.elm.remove(),n._pagination={elm:null,currentPage:0,totalPages:0,visiblePageNumbers:5},n._isMounted=!1,n._isUpdating=!1,n._sorting={currentCol:"",dir:""},n._cachedViewPort=-1,n._cachedOption=null,n.emitLifeCycles("tableDidUnmount"))},this.create=function(){n._isMounted||n.init()},this.options=u.a.extend(this._defOptions,e),delete this._defOptions,this._rootElement=u()(this.options.element),this.engine=L(),this.optionDepreciation(),this.init(),this._debounceUpdateTable()}return o(t,[{key:"optionDepreciation",value:function(){var t=this.options;this.logWarn(t.columnsHtml,"columnsHtml","has been deprecated. Use formatHeader()"),this.logWarn(t.processHtml,"processHtml","has been deprecated. Use formatCell()"),this.logWarn(t.dateParsing,"dateParsing","has been deprecated. It is true by default."),this.logWarn(t.generateUniqueIds,"generateUniqueIds","has been deprecated. It is true by default."),this.logWarn(t.showPaginationLabel,"showPaginationLabel","has been deprecated. It is true by default."),this.logWarn(t.paginationLength,"paginationLength","has been deprecated. Use rowsPerPage")}},{key:"logError",value:function(t,e,n){for(var i=arguments.length,r=new Array(i>3?i-3:0),o=3;o1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:[],n=this.options.columns;this.logError(e&&c(e),"lookUp","second argument must be array of keys"),e.length||(e=n),this._pagination.currentPage=0,this._dataset.lookUp(t,m(e)),this.debounceUpdateTable()}},{key:"_bindSearchField",value:function(){var t=this,e=this.options.searchField;if(e){var n=u()(e);this.logError(n.length,"searchField",'"%s" is not a valid DOM element or string',n),n.on("input",(function(){var e=u()(this).val();t.lookUp(e)})),this.options.searchField=n}}},{key:"_validateRootElement",value:function(){this.logError(this._rootElement.length,"element",'"%s" is not a valid root element',this._rootElement)}},{key:"_createTable",value:function(){this._table=u()("
").addClass("table gs-table")}},{key:"_initDataset",value:function(){var t=this.options.data;this.logError(c(t),"data","table-sortable only supports collections. Like: [{ key: value }, { key: value }]");var e=new D;e.fromCollection(t),this._dataset=e}},{key:"_validateColumns",value:function(){var t=this.options.columns;this.logError(d(t),"columns","Invalid column type, see docs")}},{key:"sortData",value:function(t){var e=this._sorting,n=e.dir,a=e.currentCol;t!==a&&(n=""),n?n===this._dataset.sortDirection.ASC?n=this._dataset.sortDirection.DESC:n===this._dataset.sortDirection.DESC&&(n=this._dataset.sortDirection.ASC):n=this._dataset.sortDirection.ASC,a=t,this._sorting={dir:n,currentCol:a},this._dataset.sort(a,n),this.updateCellHeader()}},{key:"_addColSorting",value:function(t,e){var n=this,a=this.options.sorting,i=this;return a?(a&&!c(a)&&((t=u()(t)).attr("role","button"),t.addClass("gs-button"),e===this._sorting.currentCol&&this._sorting.dir&&t.append(this.options.sortingIcons[this._sorting.dir]),t.click((function(t){i.sortData(e)}))),c(a)&&b(a,(function(a){e===a&&((t=u()(t)).attr("role","button"),t.addClass("gs-button"),e===n._sorting.currentCol&&n._sorting.dir&&t.append(n.options.sortingIcons[n._sorting.dir]),t.click((function(t){i.sortData(e)})))})),t):t}},{key:"getCurrentPageIndex",value:function(){var t=this._dataset._datasetLen,e=this.options,n=e.pagination,a=e.rowsPerPage,i=this._pagination.currentPage;if(!n)return{from:0};var r=i*a,o=Math.min(r+a,t);return{from:r=Math.min(r,o),to:o}}},{key:"_renderHeader",value:function(t){var e=this;t||(t=u()(''));var n=this.options,a=n.columns,i=n.formatHeader,r=[],o=m(a);b(o,(function(t,n){var o=a[t];f(i)&&(o=i(a[t],t,n)),o=e._addColSorting(u()("").html(o),t);var s=e.engine.createElement("th",{html:o});r.push(s)}));var s=this.engine.createElement("tr",null,r);return this.engine.render(s,t)}},{key:"_renderBody",value:function(t){t||(t=u()(''));var e=this.engine,n=this.options,a=n.columns,i=n.formatCell,r=this.getCurrentPageIndex(),o=r.from,s=r.to,l=[];l=void 0===s?this._dataset.top():this._dataset.get(o,s);var c=[],h=m(a);return b(l,(function(t,n){var a=[];b(h,(function(n){var r;void 0!==t[n]&&(r=f(i)?e.createElement("td",{html:i(t,n)}):e.createElement("td",{html:t[n]}),a.push(r))})),c.push(e.createElement("tr",null,a))})),e.render(c,t)}},{key:"_createCells",value:function(){return{thead:this._renderHeader(),tbody:this._renderBody()}}},{key:"onPaginationBtnClick",value:function(t,e){var n=this,a=this._pagination,i=a.totalPages,r=a.currentPage,o=this.options.onPaginationChange;"up"===t?r=0&&(r-=1);if(f(o)){var s=isNaN(e)?r:e;o.apply(this,[s,function(t){return n.setPage(t)}])}else this._pagination.currentPage=void 0!==e?e:r,this.updateTable()}},{key:"renderPagination",value:function(t){var e=this,n=this.engine,a=this.options,i=a.pagination,r=a.paginationContainer,o=a.prevText,s=a.nextText,l=this._pagination,c=l.currentPage,h=l.totalPages,d=l.visiblePageNumbers,f=Math.min(h,d),p=0,g=Math.min(h,p+f);if(c>f/2&&ch-f/2&&(p=h-f,g=h),t||(t=u()('
'),u()(r).length?u()(r).append(t):this._table.after(t)),!i)return t;var _=[],m=n.createElement("button",{className:"btn btn-default",html:o,disabled:0===c,onClick:function(){return e.onPaginationBtnClick("down")}});_.push(m);var b=n.createElement("button",{className:"btn btn-default",disabled:!0,text:"..."});c>f/2&&_.push(b);for(var v=p;v=h-1,onClick:function(){return e.onPaginationBtnClick("up")}});_.push(P),t.append(_);var k=this.getCurrentPageIndex(),C=k.from,E=k.to,w=n.createElement("span",{text:"Showing ".concat(Math.min(E,C+1)," to ").concat(E," of ").concat(this._dataset._datasetLen," rows")}),D=n.createElement("div",{className:"col-md-6"},w),x=n.createElement("div",{className:"btn-group d-flex justify-content-end"},_),S=n.createElement("div",{className:"col-md-6"},x),U=n.createElement("div",{className:"row"},[D,S]);return n.render(U,t)}},{key:"createPagination",value:function(){var t=this.options,e=t.rowsPerPage,n=t.pagination,a=t.totalPages;if(!n)return!1;this.logError(e&&h(e),"rowsPerPage","should be a number greater than zero."),this.logError(h(a),"totalPages","should be a number greater than zero.");var i=a||Math.ceil(this._dataset._datasetLen/e);0>=i&&(i=1),this._pagination.totalPages=i,this._pagination.elm?this.renderPagination(this._pagination.elm):this._pagination.elm=this.renderPagination()}},{key:"_generateTable",value:function(t,e){this._table.html(""),this._table.append(t),this._table.append(e),this._thead=t,this._tbody=e}},{key:"_renderTable",value:function(){if(this._rootElement.is("table"))this._rootElement.html(this._table.html());else{var t=this.engine.createElement("div",{className:"gs-table-container",append:this._table});this._rootElement=this.engine.render(t,this._rootElement)}}},{key:"_initStyles",value:function(){if(!this.options.responsive){var t=u()("");t.attr("id","gs-table"),t.html(".gs-table-container .table{table-layout:fixed}@media(max-width:767px){.gs-table-container{overflow:auto;max-width:100%}}"),u()("head").append(t),this._styles=t}}},{key:"init",value:function(){this.emitLifeCycles("tableWillMount"),this._validateRootElement(),this._initDataset(),this._createTable(),this._validateColumns();var t=this._createCells(),e=t.thead,n=t.tbody;this._generateTable(e,n),this._renderTable(),this.createPagination(),this._bindSearchField(),this._initStyles(),this._isMounted=!0,this.emitLifeCycles("tableDidMount"),-1===this._cachedViewPort&&this.resizeSideEffect()}},{key:"_debounceUpdateTable",value:function(){this.debounceUpdateTable=k(this.updateTable,400)}},{key:"updateTable",value:function(){this._isUpdating||(this.emitLifeCycles("tableWillUpdate"),this._isUpdating=!0,this._renderHeader(this._thead),this._renderBody(this._tbody),this.createPagination(),this._isUpdating=!1,this.emitLifeCycles("tableDidUpdate"))}},{key:"updateCellHeader",value:function(){this._isUpdating||(this._isUpdating=!0,this.emitLifeCycles("tableWillUpdate"),this._renderHeader(this._thead),this._renderBody(this._tbody),this._isUpdating=!1,this.emitLifeCycles("tableDidUpdate"))}},{key:"resizeSideEffect",value:function(){var t=k(this.makeResponsive,500);window.addEventListener("resize",t.bind(this)),this.makeResponsive()}},{key:"makeResponsive",value:function(){var t,e=this.options.responsive,n=window.innerWidth,a=_(m(e),"desc");if(this.logError(d(e),"responsive",'Invalid type of responsive option provided: "%s"',e),b(a,(function(e){parseInt(e,10)>n&&(t=e)})),this._cachedViewPort!==t){this._cachedViewPort=t;var i=e[t];d(i)?(this._cachedOption||(this._cachedOption=u.a.extend({},this.options)),this.options=u.a.extend(this.options,i),this.refresh()):this._cachedOption&&(this.options=u.a.extend({},this._cachedOption),this._cachedOption=null,this._cachedViewPort=-1,this.refresh())}}}]),t}());window.Pret=L(),window.TableSortable=O,window.DataSet=D,(s=jQuery).fn.tableSortable=function(t){return t.element=s(this),new window.TableSortable(t)};e.default=O}]); \ No newline at end of file diff --git a/templates/admin/email_content.html.twig b/templates/admin/email_content.html.twig index 4179a36..b4e89c8 100644 --- a/templates/admin/email_content.html.twig +++ b/templates/admin/email_content.html.twig @@ -9,7 +9,7 @@ Ces informations sont utilisées dans des milliers de sites web et annuaires, pa

Vous pouvez le modifier en cliquant sur le bouton ci-dessous, c'est gratuit et sans engagement.

- + Compléter les informations de mon commerce diff --git a/templates/admin/fraicheur_histogramme.html.twig b/templates/admin/fraicheur_histogramme.html.twig index 11ad554..069b863 100644 --- a/templates/admin/fraicheur_histogramme.html.twig +++ b/templates/admin/fraicheur_histogramme.html.twig @@ -5,7 +5,7 @@ {% block body %}

Histogramme de fraîcheur des données OSM

-

+

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.

Par année

Par trimestre