V1.1.1 //
-> Patch du bug du logo de l'horaire pas affiché. Corrigé pour les Horaires TER à 6 numéros.
This commit is contained in:
1 parent
06cce59f82
commit
eb198cc727
9 files changed
+270
-186
No files matched your search
@@ -0,0 +1,48 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function patchFile(file) {
|
||||
let content = fs.readFileSync(file, 'utf8');
|
||||
|
||||
// Change destructuring to include isCar as isCarMeta, etc.
|
||||
content = content.replace(
|
||||
/const { logoSrc, typeLabel, numTrain } = getTrainLogoAndMeta\(horaire\);/g,
|
||||
"const { logoSrc, typeLabel, numTrain, isCar: metaIsCar, isSubstitution: metaIsSubstitution, brand: metaBrand } = getTrainLogoAndMeta(horaire);"
|
||||
);
|
||||
|
||||
// Patch the isCar definition
|
||||
content = content.replace(
|
||||
/const isCar = \([\s\S]*?\s*Boolean\(horaire\.is_substitution\) \|\|[\s\S]*?\s*isSubstitution\(horaire\)\n\t\);/,
|
||||
"const isCar = metaIsCar || Boolean(horaire.is_substitution) || isSubstitution(horaire);\n\tconst isSub = metaIsSubstitution || Boolean(horaire.is_substitution) || isSubstitution(horaire);"
|
||||
);
|
||||
|
||||
// If the type column is rendered, we can apply a class based on metaBrand
|
||||
// Example: <div className="aff-classiques-departs__type">
|
||||
// We can add a data-brand={metaBrand} or just use style/class. Let's just modify the typeLabel styling slightly if needed.
|
||||
// Actually, we also need to append "CAR DE REMPLACEMENT" to status if isSub is true.
|
||||
|
||||
// Let's replace `const status = horaire._status || computeStatusForHoraireAtStop(...)`
|
||||
// No, let's just append to `showStatus` or similar where the marquee displays the cause.
|
||||
|
||||
// Let's find `<div className="aff-classiques-departs__type">` or similar
|
||||
content = content.replace(
|
||||
/<div className="aff-classiques-departs__type">/g,
|
||||
`<div className={\`aff-classiques-departs__type \${metaBrand ? 'brand-' + metaBrand.toLowerCase().replace(/[^a-z]/g, '') : ''}\`}>`
|
||||
);
|
||||
|
||||
content = content.replace(
|
||||
/<div className="aff-classiques-arrivees__type">/g,
|
||||
`<div className={\`aff-classiques-arrivees__type \${metaBrand ? 'brand-' + metaBrand.toLowerCase().replace(/[^a-z]/g, '') : ''}\`}>`
|
||||
);
|
||||
|
||||
// To handle the marquee for "CAR DE REMPLACEMENT"
|
||||
// find: `let infoText = infoCause || cause;`
|
||||
content = content.replace(
|
||||
/let infoText = infoCause \|\| cause;/g,
|
||||
"let infoText = infoCause || cause;\n\t\tif (isSub) infoText = infoText ? 'CAR DE REMPLACEMENT - ' + infoText : 'CAR DE REMPLACEMENT';"
|
||||
);
|
||||
|
||||
fs.writeFileSync(file, content, 'utf8');
|
||||
}
|
||||
|
||||
patchFile('src/pages/afficheurs/classiques/ClassiquesDeparts.js');
|
||||
patchFile('src/pages/afficheurs/classiques/ClassiquesArrivees.js');
|
||||
Reference in new issue
Block a user