Version temporaire script d'intégration pour la future version du site segal.bzh

This commit is contained in:
Fabrice PENHOËT 2022-05-02 11:01:54 +02:00
parent 15f60d3c12
commit c2de857157
1 changed files with 26 additions and 22 deletions

View File

@ -1,4 +1,4 @@
import { FreeDatas2HTML, Pagination, Selector } from "../../src/FreeDatas2HTML";
import { FreeDatas2HTML, Pagination, SearchEngine, Selector } from "../../src/FreeDatas2HTML";
import { MixedFieldsRender } from "../../src/extensions/MixedFieldsRender";
const initialise=async () =>
@ -13,43 +13,43 @@ const initialise=async () =>
// Chaînes à utiliser par le moteur de rendu :
const renderSettings=
{
allBegining: "",
allEnding: "",
datasLinesDisplaying: `<h3>##0##</h3><p>##8##.<br>Lieux d'activité : ##7##.##10## ##11####4####12##</p>`
allBegining: "<ul>",
allEnding: "</ul>",
datasLinesDisplaying: `<li><h3>##0##</h3><ul><li>##8##</li><li>Lieu(x) d'exercice : ##7##</li>##10####11####4####12##</ul></li>`
};
// Fonctions spécifiques pour créer les liens hypertextes :
const rendName2HTML=(values: {[index: string]:string} ) : string =>
{
if(values["Présentation"] !== undefined && values["Présentation"].trim() !== "")
return `<a href="${values['Présentation'].trim()}" title="Lire notre article de présentation de ce partenaire">${values["Nom commercial"].trim()}</a>`;
return `<a href="${values['Présentation'].trim()}" title="Présentation de ${values["Nom commercial"].trim()}">${values["Nom commercial"].trim()}</a>`;
else
return values["Nom commercial"].trim();
};
const rendSite2HTML=(values: {[index: string]:string} ) : string =>
{
if(values["Site"].trim() !== "")
return `<br><a href="${values['Site'].trim()}" target="_blank" title="Visiter le site de ${values['Nom commercial'].trim()}">Page internet</a>`;
return `<li><a href="${values['Site'].trim()}" target="_blank" title="Visiter le site de ${values['Nom commercial'].trim()}">Page internet</a></li>`;
else
return "";
};
const rendEmail2HTML=(values: {[index: string]:string} ) : string =>
{
if(values["E-mail"].trim() !== "")
return `<br><a href="mailto:${values['E-mail'].trim()}" title="Contactez ${values['Nom commercial'].trim()}">E-Mail</a>`;
return `<li><a href="mailto:${values['E-mail'].trim()}?subject=Le segal" title="Contactez ${values['Nom commercial'].trim()}">Courriel</a></li>`;
else
return "";
};
const rendTel2HTML=(values: {[index: string]:string} ) : string =>
{
if(values["Fixe"].trim() !== "")
return `<br><a href="tel:${values['Fixe'].trim()}" title="Appelez ${values['Nom commercial'].trim()}">${values['Fixe'].trim()}</a>`;
return `<li><a href="tel:${values['Fixe'].trim()}" title="Appelez ${values['Nom commercial'].trim()}">${values['Fixe'].trim()}</a></li>`;
else
return "";
};
const rendMobile2HTML=(values: {[index: string]:string} ) : string =>
{
if(values["Portable"].trim() !== "")
return `<br><a href="tel:${values['Portable'].trim()}" title="Appelez ${values['Portable'].trim()}">${values['Portable'].trim()}</a>`;
return `<li><a href="tel:${values['Portable'].trim()}" title="Appelez ${values['Portable'].trim()}">${values['Portable'].trim()}</a></li>`;
else
return "";
};
@ -58,23 +58,27 @@ const initialise=async () =>
myRender.fieldRenders=[{ name:"Nom commercial", rend2HTML: rendName2HTML}, { name:"E-mail", rend2HTML: rendEmail2HTML}, { name:"Site", rend2HTML: rendSite2HTML}, { name:"Fixe", rend2HTML: rendTel2HTML}, { name:"Portable", rend2HTML: rendMobile2HTML}];
converter.datasRender=myRender;
// Création de filtres :
// Création des filtres :
const filtre1=new Selector(converter, 8, { id:"filtreActivites"} );
let filtre2=new Selector(converter, 7, { id:"filtreLieux"}, "," );
//let filtre2=new Selector(converter, 7, { id:"filtreLieux"}, "," );
filtre1.filter2HTML("Domaine d'activité");
filtre2.filter2HTML("Lieux");
converter.datasFilters=[filtre1,filtre2];
//filtre2.filter2HTML("Lieux");
// Configuration de la pagination :
const pagination=new Pagination(converter, { id:"pages" }, "Page à afficher :");
pagination.options={ displayElement: { id:"pagination" }, values: [10,20,50,100] , name: "Choix de pagination :" };
pagination.selectedValue=10;
converter.pagination=pagination;
pagination.options2HTML();
// Dont un moteur de recherche :
const mySearch=new SearchEngine(converter, { id:"search" });
mySearch.label="";
mySearch.btnTxt="Chercher";
// La recherche se lance automatiquement, dès que 2 caractères sont saisis :
mySearch.automaticSearch=true;
mySearch.nbCharsForSearch=2;
mySearch.placeholder="Exemples de recherche : creperie port-louis, pain bio...";
mySearch.filter2HTML();
// Affichage initial avec l'id de l'élément HTML devant afficher le compteur :
converter.datasFilters=[filtre1,mySearch];
// Id de l'élément HTML devant afficher la liste de partenaires :
converter.datasViewElt={ id:"partenaires" };
converter.refreshView();
// Pas d'affichage initial, car il est généré en PHP côté backend.
}
catch(e)
{
@ -83,5 +87,5 @@ const initialise=async () =>
}
}
console.log("Hello, ami développeur :-)\nLe code source TypeScript utilisé pour faire fonctionner cette page est lisible ici : :\nhttps://forge.chapril.org/Fab_Blab/freeDatas2HTML/src/branch/master/integrations/src/segal.ts\nUn bug ? Une suggestion ? => fabrice@le-fab-lab.com");
console.log("**** Hello les devs :-)\nLe code source de ce script est libre et vous pouvez le trouver à cette adresse :\n https://forge.chapril.org/Fab_Blab/freeDatas2HTML/src/branch/master/integrations/src/segal.ts");
initialise();