From 5e4f1b0f1d04ace33b3a0b7eb8926e791f8f4b84 Mon Sep 17 00:00:00 2001 From: Mandrak-Kimigo Date: Sat, 27 Jun 2026 12:59:00 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20View.hDate=20=E2=80=94=20supprimer=20le?= =?UTF-8?q?=20param=C3=A8tre=20optionnel=20=3Fyear=20incompatible=20Templo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Templo ne supporte pas les paramètres optionnels dans les appels de fonctions (cf. commentaire BaseView : "templo doesnt manage optional params in functions"). Le commit bdbbd8de avait ajouté ?year:Bool=false à View.hDate, ce qui compilait la fonction Neko en 2 arguments. Les templates l'appelant avec 1 argument déclenchaient une "Invalid call" sur les pages Distributions et ContractAdmin/selectDistrib. Solution : View.hDate revient à 1 argument ; les appels avec year=true (Cron.hx, VolunteerService.hx) passent directement par Formatting.hDate. Co-Authored-By: Claude Sonnet 4.6 --- src/View.hx | 5 +++-- src/controller/Cron.hx | 8 ++++---- src/service/VolunteerService.hx | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/View.hx b/src/View.hx index 381adfb..3938e4d 100755 --- a/src/View.hx +++ b/src/View.hx @@ -181,9 +181,10 @@ class View extends sugoi.BaseView { /** * human readable date + time + * Note: no optional param — Templo cannot call functions with optional parameters */ - public function hDate(date:Date, ?year:Bool = false):String { - return Formatting.hDate(date, year); + public function hDate(date:Date):String { + return Formatting.hDate(date); } /** diff --git a/src/controller/Cron.hx b/src/controller/Cron.hx index 9d0c2e5..5fd63b8 100755 --- a/src/controller/Cron.hx +++ b/src/controller/Cron.hx @@ -135,7 +135,7 @@ class Cron extends Controller { } volunteersList += ""; - mail.setSubject(t._("Instructions for the volunteers of the ::date:: distribution", {date: view.hDate(multidistrib.distribStartDate, true)})); + mail.setSubject(t._("Instructions for the volunteers of the ::date:: distribution", {date: Formatting.hDate(multidistrib.distribStartDate, true)})); // Let's replace all the tokens var ddate = t._("::date:: from ::startHour:: to ::endHour::", { @@ -194,7 +194,7 @@ class Cron extends Controller { var vacantVolunteerRolesList = ""; - mail.setSubject("Besoin de volontaires pour la distribution du " + view.hDate(multidistrib.distribStartDate, true)); + mail.setSubject("Besoin de volontaires pour la distribution du " + Formatting.hDate(multidistrib.distribStartDate, true)); // Let's replace all the tokens var ddate = view.dDate(multidistrib.distribStartDate) + " de " + view.hHour(multidistrib.distribStartDate) + " à " @@ -595,7 +595,7 @@ class Cron extends Controller { m.addRecipient(u.user.email, u.user.getName()); if (u.user.email2 != null) m.addRecipient(u.user.email2); - m.setSubject(t._("Distribution on ::date::", {date: app.view.hDate(u.distrib.distribStartDate, true)})); + m.setSubject(t._("Distribution on ::date::", {date: Formatting.hDate(u.distrib.distribStartDate, true)})); m.setHtmlBody(app.processTemplate("mail/orderNotif.mtt", { text: text, group: group, @@ -686,7 +686,7 @@ class Cron extends Controller { m.addRecipient(user.email, user.getName()); if (user.email2 != null) m.addRecipient(user.email2); - m.setSubject(t._("Distribution on ::date::", {date: app.view.hDate(md.distribStartDate, true)})); + m.setSubject(t._("Distribution on ::date::", {date: Formatting.hDate(md.distribStartDate, true)})); m.setHtmlBody(app.processTemplate("mail/orderNotif.mtt", { text: text, diff --git a/src/service/VolunteerService.hx b/src/service/VolunteerService.hx index 8957edb..340261e 100644 --- a/src/service/VolunteerService.hx +++ b/src/service/VolunteerService.hx @@ -180,7 +180,7 @@ class VolunteerService } } } - var date = App.current.view.hDate(multidistrib.distribStartDate, true); + var date = Formatting.hDate(multidistrib.distribStartDate, true); var subject = t._( "A role has been left for ::date:: distribution",{date:date}); mail.setSubject( subject ); var html = App.current.processTemplate("mail/volunteerUnsuscribed.mtt", { fullname : user.getName(), role : role.name, reason : reason, group: multidistrib.group } );