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
This commit is contained in:
Alexandre Gain committed 2026-11-15 17:48:40 +01:00
1 parent ea88b7a772
commit debce4ba4a
9 files changed
+30 -18

No files matched your search

+1 -1
View File
@@ -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.
+10
View File
@@ -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
*/
+3 -1
View File
@@ -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);
+2 -2
View File
@@ -56,7 +56,7 @@
</tbody>
</table>
<div class="text-right mt-xs">
<button type="button" class="btn btn-ghost btn-sm program-config-type-remove">
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-config-type-remove">
<i class="ri-delete-bin-line"></i> {{ 'mt3s.marketing_program.config.type.remove'|trans }}
</button>
</div>
@@ -78,7 +78,7 @@
{{ cfg.type_row(type) }}
{% endfor %}
</div>
<button type="button" class="btn btn-ghost program-config-type-add">
<button type="button" class="btn btn-ghost btn-nospin program-config-type-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.config.type.add'|trans }}
</button>
</div>
@@ -12,7 +12,7 @@
{% if text|trim is not empty %}
<div class="program-read-more" id="{{ id }}">
<div class="program-read-more-text" style="display: -webkit-box; -webkit-line-clamp: {{ lines }}; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap;">{{ text|mt3s_marketing_program_linkify }}</div>
<button type="button" class="btn btn-link btn-xs p-0 program-read-more-toggle"
<button type="button" class="btn btn-link btn-xs p-0 btn-nospin program-read-more-toggle"
data-target="{{ id }}"
data-more-text="{{ 'mt3s.marketing_program.read_more.more'|trans }}"
data-less-text="{{ 'mt3s.marketing_program.read_more.less'|trans }}"
+1 -1
View File
@@ -1,6 +1,6 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}program{% endblock %}
{% block mauticContent %}mt3sMpProgram{% endblock %}
{#
# No routeBase on the page_actions includes: core would turn it into mautic_mt3s_marketing_program_* route names.
+7 -7
View File
@@ -1,6 +1,6 @@
{% extends '@MauticCore/Default/content.html.twig' %}
{% block mauticContent %}program{% endblock %}
{% block mauticContent %}mt3sMpProgram{% endblock %}
{% block headerTitle %}
{% if entity.id %}
@@ -29,7 +29,7 @@
{% macro row_end(removeLabel) %}
</div>
<div class="col-xs-1 text-right">
<button type="button" class="btn btn-ghost btn-sm program-collection-remove" title="{{ removeLabel|trans }}">
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-remove" title="{{ removeLabel|trans }}">
<i class="ri-delete-bin-line"></i>
</button>
</div>
@@ -175,7 +175,7 @@
{% endfor %}
</ul>
{% if hasTypes %}
<button type="button" class="btn btn-ghost program-collection-add">
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.description_item.add'|trans }}
</button>
{% endif %}
@@ -202,7 +202,7 @@
{% endfor %}
</ul>
{% if hasObjectiveTypes %}
<button type="button" class="btn btn-ghost program-collection-add">
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.objective.add'|trans }}
</button>
{% endif %}
@@ -234,7 +234,7 @@
{% endfor %}
</ul>
{% if hasAllocationTypes %}
<button type="button" class="btn btn-ghost program-collection-add">
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.allocation_item.add'|trans }}
</button>
{% endif %}
@@ -256,7 +256,7 @@
{{ _self.stakeholder_row(link) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost program-collection-add">
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.stakeholder.add'|trans }}
</button>
</div>
@@ -278,7 +278,7 @@
{{ _self.audience_row(audience) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost program-collection-add">
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.audience.add'|trans }}
</button>
</div>
+1 -1
View File
@@ -2,7 +2,7 @@
{% set tmpl = 'list' %}
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
{% block mauticContent %}program{% endblock %}
{% block mauticContent %}mt3sMpProgram{% endblock %}
{% block headerTitle %}{{ 'mt3s.marketing_program.header.index'|trans }}{% endblock %}
+4 -4
View File
@@ -29,7 +29,7 @@
{{ form_widget(dependency.position) }}
</div>
<div class="col-xs-1 text-right">
<button type="button" class="btn btn-ghost btn-sm program-collection-remove" title="{{ 'mt3s.marketing_program.task.dependency.remove'|trans }}">
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-remove" title="{{ 'mt3s.marketing_program.task.dependency.remove'|trans }}">
<i class="ri-delete-bin-line"></i>
</button>
</div>
@@ -53,7 +53,7 @@
{{ form_widget(raci.position) }}
</div>
<div class="col-xs-1 text-right">
<button type="button" class="btn btn-ghost btn-sm program-collection-remove" title="{{ 'mt3s.marketing_program.task.raci.remove'|trans }}">
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-remove" title="{{ 'mt3s.marketing_program.task.raci.remove'|trans }}">
<i class="ri-delete-bin-line"></i>
</button>
</div>
@@ -114,7 +114,7 @@
{{ _self.dependency_row(dependency) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost program-collection-add">
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.task.dependency.add'|trans }}
</button>
</div>
@@ -134,7 +134,7 @@
{{ _self.raci_row(raci) }}
{% endfor %}
</ul>
<button type="button" class="btn btn-ghost program-collection-add">
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
<i class="ri-add-line"></i> {{ 'mt3s.marketing_program.task.raci.add'|trans }}
</button>
</div>