{% import '_includes/forms' as forms %}
{% import 'verbb-base/_macros' as macros %}
{% if groupedIntegrations %}
{% for integrations in groupedIntegrations %}
{% for integration in integrations %}
{% set selectedItem = loop.first and loop.parent.loop.first ? true : false %}
{% set handle = integration.getHandle() %}
{{ integration.getName() }}
{{ integration.getDescription() | md }}
{% namespace 'settings[integrations][' ~ handle ~ ']' %}
{% set enabled = form.settings.integrations[handle].enabled ?? false %}
{{ forms.lightswitchField({
label: 'Enabled' | t('formie'),
instructions: 'Whether this integration should be enabled.' | t('formie'),
name: 'enabled',
on: enabled,
toggle: 'integration-enabled',
containerAttributes: {
'data-integration': handle,
},
}) }}
{{ integration.getFormSettingsHtml(form) | raw }}
{% endnamespace %}
{% endfor %}
{% endfor %}
{% else %}
{{ 'No integrations available.' | t('formie') }}
{% endif %}
{% js %}
$('[data-vui-tabs] a:first').addClass('sel');
$(document).on('click', '[data-vui-tabs] a', function(e) {
e.preventDefault();
var href = $(this).attr('href');
var $pane = $(href);
$(this).parents('[data-vui-tabs]').find('a').removeClass('sel');
$(this).addClass('sel');
if ($pane) {
$('.integration-pane').addClass('hidden');
$pane.removeClass('hidden');
}
});
$('[data-target="integration-enabled"]').each(function(index, element) {
$(element).on('click', function(e) {
var $lightswitch = $(e.currentTarget);
var lightswitch = $lightswitch.data('lightswitch');
if (lightswitch) {
var handle = $lightswitch.data('integration');
if (lightswitch.on) {
$('.tab[data-integration="' + handle + '"] .status').addClass('on').removeClass('disabled');
} else {
$('.tab[data-integration="' + handle + '"] .status').removeClass('on').addClass('disabled');
}
}
});
});
{% endjs %}