From 4a2ea7b378e3f369d9a4e238ecc473ca97ea3ab0 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 6 Jun 2017 12:35:28 +0200 Subject: [PATCH] Save last selected inventory tab to session --- app/Resources/assets/js/style.js | 31 +++++++++++++++++-- app/Resources/views/base.html.twig | 24 -------------- app/Resources/views/html.html.twig | 12 +++++-- app/Resources/views/model/detail.html.twig | 3 ++ app/Resources/views/search/index.html.twig | 4 +-- .../views/set/tabs/inventory.html.twig | 8 ++--- src/AppBundle/Controller/AjaxController.php | 25 +++++++++++++++ 7 files changed, 72 insertions(+), 35 deletions(-) create mode 100644 src/AppBundle/Controller/AjaxController.php diff --git a/app/Resources/assets/js/style.js b/app/Resources/assets/js/style.js index 862f51f..3555371 100644 --- a/app/Resources/assets/js/style.js +++ b/app/Resources/assets/js/style.js @@ -23,7 +23,7 @@ $(document).ready(function(){ onVisible: function() { $('.image img').visibility('refresh'); }, - history: true, + // history: true, historyType: 'hash' }); @@ -31,7 +31,7 @@ $(document).ready(function(){ onVisible: function() { $('.image img').visibility('refresh'); }, - history: true, + // history: true, historyType: 'hash' }); @@ -52,4 +52,31 @@ $(document).ready(function(){ $('.ui.sidebar') .sidebar('attach events', '.toc.item') ; + + // save last selected inventory tab to session + $('.setTab').click(function() { + $tab = $(this).attr('data-tab'); + + $.ajax({ + type: 'POST', + url: routes.set_tab.replace("PLACEHOLDER", $tab), + async: true, + }); + }); + + $('.ui.search') + .search({ + type: 'category', + apiSettings: { + action: 'search', + url: routes.search_autocomplete+'?query={query}', + }, + minCharacters: 3, + fields: { + title: 'name', + description: 'id', + url: 'url', + image: 'img' + } + }); }); \ No newline at end of file diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index bb839fa..bd0230c 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -106,28 +106,4 @@ {% include 'footer.html.twig' %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% endblock %} \ No newline at end of file diff --git a/app/Resources/views/html.html.twig b/app/Resources/views/html.html.twig index b5d7204..d309944 100644 --- a/app/Resources/views/html.html.twig +++ b/app/Resources/views/html.html.twig @@ -23,10 +23,16 @@ {% block body %} {% endblock %} + + + {% block javascripts %} - - - + {% endblock %} diff --git a/app/Resources/views/model/detail.html.twig b/app/Resources/views/model/detail.html.twig index 5042db3..06464a8 100644 --- a/app/Resources/views/model/detail.html.twig +++ b/app/Resources/views/model/detail.html.twig @@ -117,6 +117,9 @@ {% block javascripts %} {{ parent() }} + + +