diff --git a/src/bundle/DependencyInjection/EdgarEzUIAuditExtension.php b/src/bundle/DependencyInjection/EdgarEzUIAuditExtension.php index 1788a05..5f019ab 100644 --- a/src/bundle/DependencyInjection/EdgarEzUIAuditExtension.php +++ b/src/bundle/DependencyInjection/EdgarEzUIAuditExtension.php @@ -4,11 +4,12 @@ use Edgar\EzUIAudit\Audit\AuditInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -class EdgarEzUIAuditExtension extends Extension +class EdgarEzUIAuditExtension extends Extension implements PrependExtensionInterface { public function load(array $configs, ContainerBuilder $container) { @@ -23,4 +24,9 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('services.yml'); } + + public function prepend(ContainerBuilder $container) + { + $container->prependExtensionConfig('assetic', array('bundles' => array('EdgarEzUIAuditBundle'))); + } } diff --git a/src/bundle/Resources/public/js/edgarezuiaudit.js b/src/bundle/Resources/public/js/edgarezuiaudit.js new file mode 100644 index 0000000..aec895a --- /dev/null +++ b/src/bundle/Resources/public/js/edgarezuiaudit.js @@ -0,0 +1,29 @@ +(function () { + const iconsAuditExportUp = document.querySelectorAll('a.audit-export-up'); + const iconAuditExportDown = document.querySelectorAll('a.audit-export-down'); + + const exportUp = (event) => { + event.preventDefault(); + const svgUp = event.currentTarget.querySelector('.ez-icon-caret-up'); + const svgDown = event.currentTarget.querySelector('.ez-icon-caret-down'); + svgDown.style.display = "none"; + svgUp.style.display = "block"; + event.currentTarget.parentNode.parentNode.nextElementSibling.style.display = "table-row"; + event.currentTarget.removeEventListener('click', exportUp); + event.currentTarget.addEventListener('click', exportDown, false) + }; + + const exportDown = (event) => { + event.preventDefault(); + const svgUp = event.currentTarget.querySelector('.ez-icon-caret-up'); + const svgDown = event.currentTarget.querySelector('.ez-icon-caret-down'); + svgDown.style.display = "block"; + svgUp.style.display = "none"; + event.currentTarget.parentNode.parentNode.nextElementSibling.style.display = "none"; + event.currentTarget.removeEventListener('click', exportDown); + event.currentTarget.addEventListener('click', exportUp, false) + }; + + iconsAuditExportUp.forEach(icon => icon.addEventListener('click', exportUp, false)); + iconAuditExportDown.forEach(icon => icon.addEventListener('click', exportDown, false)); +})(); diff --git a/src/bundle/Resources/views/audit/export.html.twig b/src/bundle/Resources/views/audit/export.html.twig index b02ee23..bb48c96 100644 --- a/src/bundle/Resources/views/audit/export.html.twig +++ b/src/bundle/Resources/views/audit/export.html.twig @@ -39,12 +39,12 @@