import {Controller} from '@hotwired/stimulus' // Important: include a build with Ajax + pagination (TabulatorFull is simplest) import {TabulatorFull as Tabulator} from 'tabulator-tables'; export default class extends Controller { static values = {aws: String}; connect() { this.table(); } table(){ const table = new Tabulator("#tabulator-org", { // Register locales here langs: { fr: { ajax: { loading: "Chargement...", error: "Erreur", }, pagination: { page_size: "Taille de page", page_title: "Afficher la page", first: "Premier", first_title: "Première page", last: "Dernier", last_title: "Dernière page", prev: "Précédent", prev_title: "Page précédente", next: "Suivant", next_title: "Page suivante", all: "Tout", counter: { showing: "Affiche", of: "de", rows: "lignes", pages: "pages", }, }, headerFilters: { default: "Filtrer la colonne...", columns: {}, }, data: { loading: "Chargement des données...", error: "Erreur de chargement des données", }, groups: { item: "élément", items: "éléments" }, }, }, locale: "fr", //'en' for English, 'fr' for French (en is default, no need to include it) ajaxURL: "/organization/data", ajaxConfig: "GET", pagination: true, paginationMode: "remote", paginationSize: 10, //paginationSizeSelector: [5, 10, 20, 50], // Désactivé pour l'instant car jpp faire de jolie style ajaxResponse: (url, params, response) => response, paginationDataSent: { page: "page", size: "size" }, paginationDataReceived: { last_page: "last_page" }, ajaxSorting: true, ajaxFiltering: true, rowHeight: 60, layout: "fitColumns", // activate French columns: [ { title: "Logo", field: "logoUrl", formatter: "image", formatterParams: { height: "50px", width: "50px", urlPrefix: this.awsValue, urlSuffix: "", }, width: 100, }, // TODO: regarder quel style est mieux entre les "hozAlign" // TODO: regarder quel style est mieux avec/sans headerFilter {title: "Nom", field: "name", headerFilter: "input", widthGrow: 2, vertAlign: "middle", headerHozAlign: "left"}, {title: "Email", field: "email", headerFilter: "input", widthGrow: 2, vertAlign: "middle", hozAlign: "center"}, { title: "Actions", field: "showUrl", hozAlign: "center", width: 100, vertAlign: "middle", headerSort: false, formatter: (cell) => { const url = cell.getValue(); if (url) { return ` `; } return ''; } }], }); } }