feat(call-script): add the Call Script component (0.19.0)
A new Mautic component, listed under Components > Call Scripts (/s/call-scripts),
built like the other domains on AbstractStandardFormController/FormModel.
- CallScript (mt3s_call_scripts): name, description, category, owner, status,
the publish window shown as start/end date and time, the HTML script with
dynamic tokens kept as typed (html cleaning mask), the calling window
(weekdays, hours, sentinel in the contact's or a fixed timezone) and the retry
policy (max attempts, delay, backoff: none/linear/exponential)
- CallScriptOutcome (mt3s_call_script_outcomes, ON DELETE CASCADE): label,
data type (checkbox/radio/free text/dropdown), options JSON ({value,label})
and position; nested collections reuse the program-collection JS
- validators: ValidCallingWindow, ValidCallScriptOutcomeOptions, and an atPath
option on EndDateAfterStartDate so its violation lands on publishDown
- config: routes, the Components menu item (parent mautic.core.components),
call_script category type, model alias, call_scripts permissions, version 0.19.0
- migration Version_0_19_0 creates both tables and their FKs immediately
(users/categories SET NULL, outcomes CASCADE), idempotent
- translations en_US/fr_FR, unit tests, readme/AGENTS documentation
This commit is contained in:
1 parent
88256ca345
commit
4fb36eebfc
33 files changed
+2537
-6
No files matched your search
@@ -0,0 +1,129 @@
|
||||
{% extends '@MauticCore/Default/content.html.twig' %}
|
||||
|
||||
{% block mauticContent %}mt3sMpCallScript{% endblock %}
|
||||
|
||||
{% block headerTitle %}
|
||||
{% if form.vars.data.id %}
|
||||
{{ 'mt3s.call_script.header.edit'|trans({'%name%': form.vars.data.name}) }}
|
||||
{% else %}
|
||||
{{ 'mt3s.call_script.header.new'|trans }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{# One {value, label} option of an outcome's choices. #}
|
||||
{% macro option_row(option) %}
|
||||
<li class="program-collection-row list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-5">{{ form_row(option.value) }}</div>
|
||||
<div class="col-md-5">{{ form_row(option.label) }}</div>
|
||||
<div class="col-md-2 text-right">
|
||||
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-remove" title="{{ 'mt3s.call_script.outcome.options.remove'|trans }}">
|
||||
<i class="ri-delete-bin-line"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endmacro %}
|
||||
|
||||
{# One outcome: its label, the data type the agent records it with, and the options of the choice types.
|
||||
Adding, removing and reordering is handled by Assets/js/mt3s-mp-program.js through the
|
||||
program-collection-* classes (the options are a nested collection of the same kind). #}
|
||||
{% macro outcome_row(outcome) %}
|
||||
<li class="program-collection-row list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-xs-1 text-center">
|
||||
<span class="program-collection-handle text-muted" title="{{ 'mt3s.call_script.outcome.drag'|trans }}" style="cursor: move;">
|
||||
<i class="ri-draggable ri-lg"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-xs-10">
|
||||
<div class="row">
|
||||
<div class="col-md-6">{{ form_row(outcome.label) }}</div>
|
||||
<div class="col-md-6">{{ form_row(outcome.inputType) }}</div>
|
||||
</div>
|
||||
<div class="program-outcome-options">
|
||||
<h5>{{ 'mt3s.call_script.outcome.options'|trans }}</h5>
|
||||
<div class="program-collection program-outcome-option-collection"
|
||||
data-prototype="{{ _self.option_row(outcome.options.vars.prototype)|e('html_attr') }}"
|
||||
data-prototype-name="__option__">
|
||||
<p class="text-muted program-collection-empty{% if outcome.options|length > 0 %} hide{% endif %}">
|
||||
{{ 'mt3s.call_script.outcome.options.empty'|trans }}
|
||||
</p>
|
||||
<ul class="list-group program-collection-list">
|
||||
{% for option in outcome.options %}
|
||||
{{ _self.option_row(option) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-add">
|
||||
<i class="ri-add-line"></i> {{ 'mt3s.call_script.outcome.options.add'|trans }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{{ form_widget(outcome.position) }}
|
||||
</div>
|
||||
<div class="col-xs-1 text-right">
|
||||
<button type="button" class="btn btn-ghost btn-sm btn-nospin program-collection-remove" title="{{ 'mt3s.call_script.outcome.remove'|trans }}">
|
||||
<i class="ri-delete-bin-line"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endmacro %}
|
||||
|
||||
{% block content %}
|
||||
{{ form_start(form) }}
|
||||
<div class="box-layout">
|
||||
<div class="col-md-9 height-auto bdr-r">
|
||||
<div class="pa-md">
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.description) }}
|
||||
{{ form_row(form.script) }}
|
||||
</div>
|
||||
<div class="pa-md">
|
||||
<h4 class="mt-lg mb-sm">{{ 'mt3s.call_script.outcome.list'|trans }}</h4>
|
||||
<div class="program-collection program-call-script-outcomes"
|
||||
data-prototype="{{ _self.outcome_row(form.outcomes.vars.prototype)|e('html_attr') }}"
|
||||
data-prototype-name="__outcome__">
|
||||
{{ form_errors(form.outcomes) }}
|
||||
<p class="text-muted program-collection-empty{% if form.outcomes|length > 0 %} hide{% endif %}">
|
||||
{{ 'mt3s.call_script.outcome.empty'|trans }}
|
||||
</p>
|
||||
<ul class="list-group program-collection-list">
|
||||
{% for outcome in form.outcomes %}
|
||||
{{ _self.outcome_row(outcome) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<button type="button" class="btn btn-ghost btn-nospin program-collection-add">
|
||||
<i class="ri-add-line"></i> {{ 'mt3s.call_script.outcome.add'|trans }}
|
||||
</button>
|
||||
</div>
|
||||
{% do form.outcomes.setRendered %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 height-auto">
|
||||
<div class="pr-lg pl-lg pt-md pb-md">
|
||||
{{ form_row(form.owner) }}
|
||||
{{ form_row(form.category) }}
|
||||
{{ form_row(form.isPublished) }}
|
||||
{{ form_row(form.publishUp) }}
|
||||
{{ form_row(form.publishDown) }}
|
||||
|
||||
<h4>{{ 'mt3s.call_script.section.calling_window'|trans }}</h4>
|
||||
{{ form_row(form.callingDays) }}
|
||||
{{ form_row(form.callingFrom) }}
|
||||
{{ form_row(form.callingTo) }}
|
||||
{{ form_row(form.callingTimezoneMode) }}
|
||||
{{ form_row(form.callingTimezone) }}
|
||||
|
||||
<h4>{{ 'mt3s.call_script.section.retry_policy'|trans }}</h4>
|
||||
{{ form_row(form.retryMaxAttempts) }}
|
||||
{{ form_row(form.retryDelayMinutes) }}
|
||||
{{ form_row(form.retryBackoff) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ form_row(form.buttons) }}
|
||||
{# render_rest is false, so the hidden CSRF token must be rendered explicitly. #}
|
||||
{{ form_widget(form._token) }}
|
||||
{{ form_end(form, {'render_rest': false}) }}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,133 @@
|
||||
{% set isIndex = 'index' == tmpl|default('index') ? true : false %}
|
||||
{% set tmpl = 'list' %}
|
||||
{% extends isIndex ? '@MauticCore/Default/content.html.twig' : '@MauticCore/Default/raw_output.html.twig' %}
|
||||
|
||||
{% block mauticContent %}mt3sMpCallScript{% endblock %}
|
||||
|
||||
{% block headerTitle %}{{ 'mt3s.call_script.header.index'|trans }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="page-list-wrapper" class="{% if items|length > 0 or searchValue is not empty %}panel {% endif %}panel-default">
|
||||
{# The toolbar belongs to the full page only: ajax reloads (sort, filter, pagination)
|
||||
replace the contents of .page-list, so including it here again would duplicate it. #}
|
||||
{% if isIndex %}
|
||||
{{- include('@MauticCore/Helper/list_toolbar.html.twig', {
|
||||
'searchValue': searchValue,
|
||||
'action': currentRoute,
|
||||
'page_actions': {
|
||||
'templateButtons': {
|
||||
'new': permissions[permissionBase ~ ':create'],
|
||||
},
|
||||
'langVar': 'mt3smarketingprogram.call_scripts',
|
||||
'routeBase': 'call_scripts',
|
||||
},
|
||||
'bulk_actions': {
|
||||
'langVar': 'mt3smarketingprogram.call_scripts',
|
||||
'templateButtons': {
|
||||
'delete': permissions[permissionBase ~ ':deleteown'] or permissions[permissionBase ~ ':deleteother'],
|
||||
},
|
||||
},
|
||||
}) -}}
|
||||
{% endif %}
|
||||
<div class="page-list">
|
||||
{% if items is defined and items is not empty %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover" id="callScriptTable">
|
||||
<thead>
|
||||
<tr>
|
||||
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||
'checkall': 'true',
|
||||
'target': '#callScriptTable',
|
||||
}) }}
|
||||
{# Columns: Name, Category, Status, Owner, Modified. #}
|
||||
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||
'sessionVar': sessionVar,
|
||||
'orderBy': tablePrefix ~ '.name',
|
||||
'text': 'mt3s.call_script.field.name',
|
||||
'class': 'col-call-script-name',
|
||||
'default': true,
|
||||
}) }}
|
||||
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||
'sessionVar': sessionVar,
|
||||
'text': 'mt3s.call_script.list.category',
|
||||
'class': 'visible-md visible-lg col-call-script-category',
|
||||
}) }}
|
||||
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||
'sessionVar': sessionVar,
|
||||
'orderBy': tablePrefix ~ '.isPublished',
|
||||
'text': 'mt3s.call_script.list.status',
|
||||
'class': 'col-call-script-status',
|
||||
}) }}
|
||||
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||
'sessionVar': sessionVar,
|
||||
'text': 'mt3s.call_script.list.owner',
|
||||
'class': 'visible-md visible-lg col-call-script-owner',
|
||||
}) }}
|
||||
{{ include('@MauticCore/Helper/tableheader.html.twig', {
|
||||
'sessionVar': sessionVar,
|
||||
'orderBy': tablePrefix ~ '.dateModified',
|
||||
'text': 'mt3s.call_script.list.modified',
|
||||
'class': 'visible-md visible-lg col-call-script-date',
|
||||
}) }}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in items %}
|
||||
{% set canEdit = securityHasEntityAccess(permissions[permissionBase ~ ':editown'], permissions[permissionBase ~ ':editother'], item.createdBy) %}
|
||||
<tr>
|
||||
<td>
|
||||
{{- include('@MauticCore/Helper/list_actions.html.twig', {
|
||||
'item': item,
|
||||
'templateButtons': {
|
||||
'edit': canEdit,
|
||||
'delete': securityHasEntityAccess(permissions[permissionBase ~ ':deleteown'], permissions[permissionBase ~ ':deleteother'], item.createdBy),
|
||||
},
|
||||
'langVar': 'mt3smarketingprogram.call_scripts',
|
||||
'routeBase': 'call_scripts',
|
||||
}) -}}
|
||||
</td>
|
||||
<td>
|
||||
{% if canEdit %}
|
||||
<a href="{{ path(actionRoute, {'objectAction': 'edit', 'objectId': item.id}) }}" data-toggle="ajax">{{ item.name }}</a>
|
||||
{% else %}
|
||||
{{ item.name }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="visible-md visible-lg">{{ item.category.name|default('—') }}</td>
|
||||
<td>
|
||||
{% if item.isPublished %}
|
||||
<span class="label label-success"{% if item.publishUp or item.publishDown %} title="{{ item.publishUp ? item.publishUp|date('Y-m-d H:i') : '' }} → {{ item.publishDown ? item.publishDown|date('Y-m-d H:i') : '' }}"{% endif %}>{{ 'mt3s.call_script.list.published'|trans }}</span>
|
||||
{% else %}
|
||||
<span class="label label-default">{{ 'mt3s.call_script.list.unpublished'|trans }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="visible-md visible-lg">{{ item.owner.name|default('—') }}</td>
|
||||
<td class="visible-md visible-lg">{{ item.dateModified ? dateToFull(item.dateModified) : '—' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel-footer">
|
||||
{{- include('@MauticCore/Helper/pagination.html.twig', {
|
||||
'totalItems': totalItems,
|
||||
'page': page,
|
||||
'limit': limit,
|
||||
'baseUrl': path(indexRoute),
|
||||
'sessionVar': sessionVar,
|
||||
}) -}}
|
||||
</div>
|
||||
</div>
|
||||
{% elseif searchValue is not empty %}
|
||||
{{ include('@MauticCore/Helper/noresults.html.twig') }}
|
||||
{% else %}
|
||||
<div class="mt-80 col-md-offset-2 col-lg-offset-3 col-md-8 col-lg-5 height-auto">
|
||||
{{ include('@MauticCore/Components/content-block.html.twig', {
|
||||
'heading': 'mt3s.call_script.onboarding.heading',
|
||||
'subheading': 'mt3s.call_script.onboarding.subheading',
|
||||
'copy': 'mt3s.call_script.onboarding.copy',
|
||||
}) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user