// let listContainer = $("#dataList"); // let currentTypes = []; // let displayedTypes = []; let listManager; $(document).ready(function () { listManager = new ListManager($("#dataList"), json_dump, [ { name: 'icon', description: 'Icone', type: 'icon' }, { name: 'name', description: 'Nom', type: 'text' }, ]); }); // // function initValuesFromPHPDump() { // currentTypes = json_dump; // console.log(currentTypes); // // } // // $(document).ready(function () { // initValuesFromPHPDump(); // generateList(); // console.log(displayedTypes); // }); // // function generateList() { // for (let i = 0; i < currentTypes.length; i++) { // createNewListEntry(currentTypes[i]); // } // } // // function createNewListEntry(type) { // displayedTypes.push( // $("
  • " + // "
    " + // "" + // "" + type["name"] + "" + // "
    " + // "
  • ")); // listContainer.append(displayedTypes[displayedTypes.length - 1]); // } // // function deleteListEntry(id) { // $('#listItem_' + id).remove(); // } // // // function showEditPopup(index) { // let defaultValues = { // name: "", // icon: "" // }; // let title = "Créer une catégorie"; // if (index !== -1) { // defaultValues = currentTypes[index]; // title = "Modifier la catégorie"; // } // $.confirm({ // title: title, // content: // '
    ' + // '
    ' + // '' + // '' + // '' + // '' + // '
    ' + // '
    ', // buttons: { // formSubmit: { // text: 'Sauvegarder', // btnClass: 'btn-blue', // action: async function () { // let name = this.$content.find('#nameInput').val(); // let icon = this.$content.find('#iconInput').val(); // if (!name) { // $.alert('Merci de donner un nom'); // return false; // } else if (!icon) { // $.alert('Merci de donner une icone'); // return false; // } // let itemToSave; // if (index !== -1) { // currentTypes[index]['name'] = name; // currentTypes[index]['icon'] = icon; // itemToSave = currentTypes[index]; // displayedTypes[index].find(".category-title").text(name); // displayedTypes[index].find(".mdi")[0].className = "mdi mdi-" + icon; // } else { // itemToSave = { // name: name, // icon: icon, // display_order: 0, // }; // } // let id = await SaveManager.saveCategory(itemToSave, index === -1); // if (id >= 0 && index === -1) { // itemToSave = { // name: name, // icon: icon, // display_order: 0, // id: id // }; // currentTypes[displayedTypes.length] = itemToSave; // createNewListEntry(itemToSave); // } // } // }, // deleteButton: { // text: 'Supprimer', // btnClass: 'btn-red', // isHidden: index === -1, // action: function () { // let id = currentTypes[index]['id']; // SaveManager.deleteCategory(id); // deleteListEntry(id); // } // }, // cancelButton: { // text: 'Annuler', // }, // }, // onContentReady: function () { // // bind to events // let jc = this; // this.$content.find('form').on('submit', function (e) { // // if the user submits the form by pressing enter in the field. // e.preventDefault(); // jc.$$formSubmit.trigger('click'); // reference the button and click it // }); // } // }); // }