import {Controller} from '@hotwired/stimulus' import {TabulatorFull as Tabulator} from "tabulator-tables"; export default class extends Controller { static values = {data: String, aws: String}; connect() { this.table = new Tabulator("#tabulator-org", { data: JSON.parse(this.dataValue), layout: "fitColumns", columns: [ { title: "Logo", field: "logoUrl", formatter: "image", width: 100, formatterParams: {height: "50px", width: "50px", urlPrefix: this.awsValue, urlSuffix: ""}, }, {title: "Nom", field: "name", headerFilter: "input"}, {title: "Email", field: "email", headerFilter: "input"}, { title: "Actions", field: "showUrl", hozAlign: "center", width: 80, headerSort: false, formatter: (cell) => { const url = cell.getValue(); if (url) { return ` `; } return ''; } }] }); } disconnect() { if (this.table) { this.table.destroy(); } } }