From debce4ba4a7f44ac607303604bd36e8d32241c5a Mon Sep 17 00:00:00 2001 From: Alexandre Gain <270117159+alexandregain-xprl@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:48:40 +0100 Subject: [PATCH] fix(program): endless spinner on client-side buttons; program pages never ran their JS Two defects kept the task form's dependency/RACI rows appearing stuck, and left the program pages uninitialized: - Add btn-nospin to the 14 client-side Add/Remove buttons (task dependency and RACI add/remove, program form collections, item type rows, read-more toggle): core binds startIconSpinOnEvent to .btn:not(.btn-nospin) and only the ajax handlers restore the icon, so these non-ajax buttons spun forever - Add ProgramController::getJsLoadMethodPrefix() returning 'mt3sMpProgram': core dispatches Mautic[getJsLoadMethodPrefix() + 'OnLoad'](), and without the override it fell back to the model alias 'mt3smp.program', which nothing listens to, so collections/tabs/sortables were never initialized - Set the Program list/form/details mauticContent blocks to mt3sMpProgram so Mautic.mt3sMpProgramOnLoad() is dispatched on those pages - TaskController: pass mauticContent=mt3sMpProgram in the post-save redirect back to the program view so the program page's JS re-fires after saving a task from program context --- Assets/js/mt3s-mp-program.js | 2 +- Controller/ProgramController.php | 10 ++++++++++ Controller/TaskController.php | 4 +++- Resources/views/ItemTypes/form.html.twig | 4 ++-- .../views/Program/_description_read_more.html.twig | 2 +- Resources/views/Program/details.html.twig | 2 +- Resources/views/Program/form.html.twig | 14 +++++++------- Resources/views/Program/list.html.twig | 2 +- Resources/views/Task/form.html.twig | 8 ++++---- 9 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Assets/js/mt3s-mp-program.js b/Assets/js/mt3s-mp-program.js index 07f73d6..561e8f9 100644 --- a/Assets/js/mt3s-mp-program.js +++ b/Assets/js/mt3s-mp-program.js @@ -3,7 +3,7 @@ * * - Plan form: editable, sortable rows (objectives, description items, allocation items), the selected * item type's description, and tab error markers. Started by Mautic.mt3sMpProgramOnLoad(), which Mautic calls after - * it loads any page whose mauticContent is "program", including pages loaded through Ajax. + * it loads any page whose mauticContent is "mt3sMpProgram", including pages loaded through Ajax. * - Task form (mauticContent "mt3sMpProgramTask", started by Mautic.mt3sMpProgramTaskOnLoad()): the dependencies and * the RACI rows work like the program form's collections; the selected kind enslaves a milestone's * end date; the selected type's description and pictogram sit next to the type dropdown. diff --git a/Controller/ProgramController.php b/Controller/ProgramController.php index bb6e8ff..61d980e 100644 --- a/Controller/ProgramController.php +++ b/Controller/ProgramController.php @@ -44,6 +44,16 @@ class ProgramController extends AbstractStandardFormController return self::ROUTE_ACTION; } + /** + * The OnLoad JS prefix: core dispatches Mautic[getJsLoadMethodPrefix() + "OnLoad"]() + * (mt3sMpProgramOnLoad in Assets/js/mt3s-mp-program.js). Without this override, core + * falls back to the model name ("mt3smp.program"), which nothing listens to. + */ + protected function getJsLoadMethodPrefix(): string + { + return 'mt3sMpProgram'; + } + /** * @param int $page */ diff --git a/Controller/TaskController.php b/Controller/TaskController.php index 76a7dcf..652e246 100644 --- a/Controller/TaskController.php +++ b/Controller/TaskController.php @@ -178,7 +178,9 @@ class TaskController extends AbstractStandardFormController $args['returnUrl'] = $this->generateUrl(ProgramController::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $programId]); $args['contentTemplate'] = ProgramController::class.'::viewAction'; $args['viewParameters'] = ['objectId' => $programId]; - $args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'program']); + // Must match ProgramController::getJsLoadMethodPrefix() / the Program views' + // mauticContent block so Mautic.mt3sMpProgramOnLoad() re-fires on the program page. + $args['passthroughVars'] = array_merge($args['passthroughVars'] ?? [], ['mauticContent' => 'mt3sMpProgram']); } return parent::getPostActionRedirectArguments($args, $action); diff --git a/Resources/views/ItemTypes/form.html.twig b/Resources/views/ItemTypes/form.html.twig index 7ade449..2a6e856 100644 --- a/Resources/views/ItemTypes/form.html.twig +++ b/Resources/views/ItemTypes/form.html.twig @@ -56,7 +56,7 @@