src/Products/NotificationsBundle/Resources/views/portal/management/_prefs.html.twig line 1

Open in your IDE?
  1. {% set headers = _args.headers %}
  2. {% set contacts = _args.contacts %}
  3. {% set routes_enable = _args.routes_enable %}
  4. {% set routes_primary = _args.routes_primary %}
  5. {% set routes_secondary = _args.routes_secondary %}
  6. {% set routes_edit = _args.routes_edit|default(null) %}
  7. {% set routes_add_phone = _args.routes_add_phone|default(null) %}
  8. {% set routes_add_email = _args.routes_add_email|default(null) %}
  9. {% set permissions = (_args.permissions is defined) ? (_args.permissions is same as(true)) : true %}
  10. <table class="prefgrid" id="prefs">
  11.     <tbody>
  12.         <tr>
  13.             <th>Notifications</th>
  14.             {% for header in headers %}
  15.                 <th>
  16.                     <span class="d-flex align-items-center">
  17.                         {% if header.badge|default(null) %}
  18.                             <i class="{{ header.badge }}"></i>
  19.                         {% endif %}
  20.                         {{ header.title }}
  21.                         {% if header.tooltip|default(null) %}
  22.                             {% set tkn = token() %}
  23.                             <div
  24.                                 id="tooltip-{{ tkn }}"
  25.                                 data-toggle="popover"
  26.                                 data-container="#tooltip-{{ tkn }}"
  27.                                 data-placement="top"
  28.                                 data-delay="{&quot;show&quot;: 0, &quot;hide&quot;: 250}"
  29.                                 data-trigger="hover focus"
  30.                                 data-html="true"
  31.                                 data-content="{{- header.tooltip|e('html_attr') -}}"
  32.                             >
  33.                                 <span
  34.                                     class="badge badge--right badge--sphere text-extrabold"
  35.                                 >?</span>
  36.                             </div>
  37.                         {% endif %}
  38.                     </span>
  39.                 </th>
  40.             {% endfor %}
  41.         </tr>
  42.         {% for contact in contacts %}
  43.             <tr class="prefgrid__card{% if not contact.enabled %} prefgrid__card--disabled{% endif %}">
  44.                 <td>
  45.                     <span class="prefgrid__group">
  46.                         <span class="custom-control custom-checkbox">
  47.                             <input
  48.                                 type="checkbox"
  49.                                 class="custom-control-input"
  50.                                 id="enabled_{{ contact.id }}"
  51.                                 {% if permissions and not is_granted('app.notifications.contacts.admin') %}disabled{% endif %}
  52.                                 {% if contact.enabled %}checked{% endif %}
  53.                                 data-trigger="toggler"
  54.                                 data-toggler-url="{{ path(routes_enable, {
  55.                                     contact: contact.id,
  56.                                 }) }}"
  57.                             />
  58.                             <label class="custom-control-label" for="enabled_{{ contact.id }}"></label>
  59.                         </span>
  60.                         <span class="prefgrid__control">
  61.                             <i class="icon-{{ first_of({
  62.                                 'activity-voice': contact.isPhone,
  63.                                 'activity-mail': contact.isEmail,
  64.                                 'deviceapp': contact.isApp,
  65.                             }) }}"></i>
  66.                             <span>
  67.                                 {% set hasTooltip =
  68.                                     contact.recipient.discr is defined and
  69.                                     contact.recipient.discr == 'phone' and
  70.                                     contact.recipient.lookup['carrier']['name'] is defined and
  71.                                     contact.recipient.lookup['carrier']['name'] is not empty
  72.                                 %}
  73.                                 {% if hasTooltip %}
  74.                                     {% set tooltipId = token() %}
  75.                                     <div
  76.                                         id="tooltip-{{ tooltipId }}"
  77.                                         data-toggle="popover"
  78.                                         data-container="#tooltip-{{ tooltipId }}"
  79.                                         data-placement="top"
  80.                                         data-delay="{&quot;show&quot;: 0, &quot;hide&quot;: 250}"
  81.                                         data-trigger="hover focus"
  82.                                         data-html="true"
  83.                                         data-content="Carrier: {{ contact.recipient.lookup['carrier']['name']|capitalize }}"
  84.                                     >
  85.                                         <span class="weglot-skip">{{- contact.recipient|recipient_format }}</span>
  86.                                     </div>
  87.                                 {% else %}
  88.                                     <span class="weglot-skip">{{- contact.recipient|recipient_format }}</span>
  89.                                 {% endif %}
  90.                                 {% if routes_edit and not contact.isApp %}
  91.                                     <a href="{{- path(routes_edit, {
  92.                                         contact: contact.id,
  93.                                     }) -}}">(edit)</a>
  94.                                 {% endif %}
  95.                             </span>
  96.                         </span>
  97.                     </span>
  98.                 </td>
  99.                 <td>
  100.                     <span class="prefgrid__group">
  101.                         <span class="prefgrid__colLab">Urgent messages</span>
  102.                         {% if contact.isPhone %}
  103.                             <label data-subscribe="on" class="wide__switch wide__switch-sm">
  104.                                 <input
  105.                                     type="checkbox"
  106.                                     class="wide__switchcheckbox"
  107.                                     id="urgent_{{ contact.id }}"
  108.                                     {% if permissions and (not contact.enabled or not is_granted('app.notifications.contacts.admin')) %}disabled{% endif %}
  109.                                     {% if contact.hasPrimaryPreference(constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCES__SMS')) %}checked{% endif %}
  110.                                     data-trigger="toggler"
  111.                                     data-toggler-url="{{ path(routes_primary, {
  112.                                         contact: contact.id,
  113.                                     }) }}"
  114.                                     data-toggler-payload="{{- {
  115.                                         preference: constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCE__SMS'),
  116.                                     }|json_encode|e('html_attr') -}}"
  117.                                 />
  118.                                 <span class="wide__switchhiglight"></span>
  119.                                 <span class="wide__switchtab wide__switchone">Voice</span>
  120.                                 <span class="wide__switchtab wide__switchtwo">Text</span>
  121.                             </label>
  122.                         {% else %}
  123.                             <div class="custom-control custom-control--nolabel custom-switch">
  124.                                 <input
  125.                                     type="checkbox"
  126.                                     class="custom-control-input"
  127.                                     id="urgent_{{ contact.id }}"
  128.                                     {% if permissions and (not contact.enabled or not is_granted('app.notifications.contacts.admin')) %}disabled{% endif %}
  129.                                     {% if contact.hasPrimaryPreference(first_of({
  130.                                         (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCES__EMAIL')): contact.isEmail,
  131.                                         (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCES__APP')): contact.isApp,
  132.                                     })) %}checked{% endif %}
  133.                                     data-trigger="toggler"
  134.                                     data-toggler-url="{{ path(routes_primary, {
  135.                                         contact: contact.id,
  136.                                     }) }}"
  137.                                     data-toggler-payload="{{- {
  138.                                         preference: first_of({
  139.                                             (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCE__EMAIL')): contact.isEmail,
  140.                                             (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCE__APP')): contact.isApp,
  141.                                         }),
  142.                                     }|json_encode|e('html_attr') -}}"
  143.                                 />
  144.                                 <label class="custom-control-label" for="urgent_{{ contact.id }}"></label>
  145.                             </div>
  146.                         {% endif %}
  147.                     </span>
  148.                 </td>
  149.                 <td>
  150.                     <span class="prefgrid__group">
  151.                         <span class="prefgrid__colLab">General messages</span>
  152.                         <div class="custom-control custom-control--nolabel custom-switch">
  153.                             <input
  154.                                 type="checkbox"
  155.                                 class="custom-control-input"
  156.                                 id="general_{{ contact.id }}"
  157.                                 {% if permissions and (not contact.enabled  or not is_granted('app.notifications.contacts.admin')) %}disabled{% endif %}
  158.                                 {% if contact.hasSecondaryPreference(first_of({
  159.                                     (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCES__SMS')): contact.isPhone,
  160.                                     (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCES__EMAIL')): contact.isEmail,
  161.                                     (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCES__APP')): contact.isApp,
  162.                                 })) %}checked{% endif %}
  163.                                 data-trigger="toggler"
  164.                                 data-toggler-url="{{ path(routes_secondary, {
  165.                                     contact: contact.id,
  166.                                 }) }}"
  167.                                 data-toggler-payload="{{- {
  168.                                     preference: first_of({
  169.                                         (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCE__SMS')): contact.isPhone,
  170.                                         (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCE__EMAIL')): contact.isEmail,
  171.                                         (constant('Products\\NotificationsBundle\\Util\\Preferences::PREFERENCE__APP')): contact.isApp,
  172.                                     }),
  173.                                 }|json_encode|e('html_attr') -}}"
  174.                             />
  175.                             <label class="custom-control-label" for="general_{{ contact.id }}"></label>
  176.                         </div>
  177.                     </span>
  178.                 </td>
  179.             </tr>
  180.         {% endfor %}
  181.         {% if routes_add_email %}
  182.             <tr class="prefgrid__card prefgrid__card--disabled">
  183.                 <td colspan="4">
  184.                     <span class="prefgrid__group">
  185.                         <span class="custom-control custom-checkbox invisible">
  186.                             <input type="checkbox" class="custom-control-input" id="prefs__add">
  187.                             <label class="custom-control-label" for="prefs__add"></label>
  188.                         </span>
  189.                         <span class="prefgrid__control prefgrid__addphone">
  190.                             <i class="icon-activity-mail"></i>
  191.                             <span>
  192.                                 <a href="{{ path(routes_add_email) }}">+ Add additional email</a>
  193.                             </span>
  194.                         </span>
  195.                     </span>
  196.                 </td>
  197.             </tr>
  198.         {% endif %}
  199.         {% if routes_add_phone %}
  200.             <tr class="prefgrid__card prefgrid__card--disabled">
  201.                 <td colspan="4">
  202.                     <span class="prefgrid__group">
  203.                         <span class="custom-control custom-checkbox invisible">
  204.                             <input type="checkbox" class="custom-control-input" id="prefs__add">
  205.                             <label class="custom-control-label" for="prefs__add"></label>
  206.                         </span>
  207.                         <span class="prefgrid__control prefgrid__addphone">
  208.                             <i class="icon-activity-voice"></i>
  209.                             <span>
  210.                                 <a href="{{ path(routes_add_phone) }}">+ Add additional number</a>
  211.                             </span>
  212.                         </span>
  213.                     </span>
  214.                 </td>
  215.             </tr>
  216.         {% endif %}
  217.     </tbody>
  218. </table>
  219. <script type="text/javascript">
  220.     (function (window, document, $, undefined) {
  221.         $(function () {
  222.             $('#prefs')
  223.                 .on('always.toggler', '[id^="enabled_"]', function (e, data) {
  224.                     var $target = $(e.currentTarget);
  225.                     $target
  226.                         .closest('tr')
  227.                         .toggleClass('prefgrid__card--disabled', ( ! data.value))
  228.                         .find('input')
  229.                         .not($target)
  230.                         .attr('disabled', ( ! data.value))
  231.                     ;
  232.                 })
  233.             ;
  234.             $('[data-toggle="popover"]').popover();
  235.         });
  236.     })(window, document, jQuery);
  237. </script>