mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-18 05:10:07 -07:00
Save last selected inventory tab to session
This commit is contained in:
parent
248d9bd036
commit
4a2ea7b378
@ -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'
|
||||
}
|
||||
});
|
||||
});
|
@ -106,28 +106,4 @@
|
||||
</main>
|
||||
{% include 'footer.html.twig' %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{{ parent() }}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('.ui.search')
|
||||
.search({
|
||||
type: 'category',
|
||||
apiSettings: {
|
||||
action: 'search',
|
||||
url: '{{ path('search_autocomplete') }}?query={query}',
|
||||
},
|
||||
minCharacters: 3,
|
||||
fields: {
|
||||
title: 'name',
|
||||
description: 'id',
|
||||
url: 'url',
|
||||
image: 'img'
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
@ -23,10 +23,16 @@
|
||||
{% block body %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/style.js')) }}"></script>
|
||||
<script type="text/javascript">
|
||||
var routes = {
|
||||
search_autocomplete : "{{ path('search_autocomplete') }}",
|
||||
set_tab : "{{ path('set_tab', { 'tab': "PLACEHOLDER" }) }}"
|
||||
};
|
||||
</script>
|
||||
{% block javascripts %}
|
||||
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/three.js')) }}"></script>
|
||||
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/OrbitControls.js')) }}"></script>
|
||||
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/style.js')) }}"></script>
|
||||
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
@ -117,6 +117,9 @@
|
||||
|
||||
{% block javascripts %}
|
||||
{{ parent() }}
|
||||
|
||||
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/three.js')) }}"></script>
|
||||
<script type="text/javascript" src="{{ fileTimestamp(asset('resources/js/OrbitControls.js')) }}"></script>
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
$('#model-viewer').ModelViewer('{{ path('media_file', {'path': model.path }) }}');
|
||||
|
@ -16,7 +16,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="spacing top">
|
||||
<a class="show all" href="{{ path('set_index',{'s[query]':query}) }}">{{ 'view.all.sets' | trans }}</a>
|
||||
<a class="show all" href="{{ path('set_index',{'query':query}) }}">{{ 'view.all.sets' | trans }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -30,7 +30,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="spacing top">
|
||||
<a class="show all" href="{{ path('model_index',{'m[query]':query}) }}">{{ 'view.all.models' | trans }}</a>
|
||||
<a class="show all" href="{{ path('model_index',{'query':query}) }}">{{ 'view.all.models' | trans }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -30,14 +30,14 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="ui top attached tabular menu submenu">
|
||||
<a class="ui item {% if not app.session.get('multicolor') %}active{% endif %}" data-tab="inventory/unicolor"><i class="grid layout icon"></i> Uni-Color</a>
|
||||
<a class="ui item {% if app.session.get('multicolor') %}active{% endif %}" data-tab="inventory/multicolor"><i class="list layout icon"></i> Multi-Color</a>
|
||||
<a class="ui item setTab {% if app.session.get('tab') != 'inventory/multicolor' %}active{% endif %}" data-tab="inventory/unicolor"><i class="grid layout icon"></i> Uni-Color</a>
|
||||
<a class="ui item setTab {% if app.session.get('tab') == 'inventory/multicolor' %}active{% endif %}" data-tab="inventory/multicolor"><i class="list layout icon"></i> Multi-Color</a>
|
||||
</div>
|
||||
|
||||
<div class="ui bottom attached tab {% if not app.session.get('multicolor') %}active{% endif %}" data-tab="inventory/unicolor">
|
||||
<div class="ui bottom attached tab {% if app.session.get('tab') != 'inventory/multicolor' %}active{% endif %}" data-tab="inventory/unicolor">
|
||||
{{ render(path('set_models', {id: set.id})) }}
|
||||
</div>
|
||||
<div class="ui bottom attached tab {% if app.session.get('multicolor') %}active{% endif %}" data-tab="inventory/multicolor">
|
||||
<div class="ui bottom attached tab {% if app.session.get('tab') == 'inventory/multicolor' %}active{% endif %}" data-tab="inventory/multicolor">
|
||||
{{ render(path('set_colors', {id: set.id})) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
25
src/AppBundle/Controller/AjaxController.php
Normal file
25
src/AppBundle/Controller/AjaxController.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
|
||||
class AjaxController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/set_tab/{tab}", name="set_tab", requirements={"tab"=".+"})
|
||||
*/
|
||||
public function setDefaultTabAction(Request $request, $tab)
|
||||
{
|
||||
$session = $request->getSession();
|
||||
$session->set('tab', $tab);
|
||||
|
||||
$response = new Response();
|
||||
return $response;
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user