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() {
|
onVisible: function() {
|
||||||
$('.image img').visibility('refresh');
|
$('.image img').visibility('refresh');
|
||||||
},
|
},
|
||||||
history: true,
|
// history: true,
|
||||||
historyType: 'hash'
|
historyType: 'hash'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ $(document).ready(function(){
|
|||||||
onVisible: function() {
|
onVisible: function() {
|
||||||
$('.image img').visibility('refresh');
|
$('.image img').visibility('refresh');
|
||||||
},
|
},
|
||||||
history: true,
|
// history: true,
|
||||||
historyType: 'hash'
|
historyType: 'hash'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,4 +52,31 @@ $(document).ready(function(){
|
|||||||
$('.ui.sidebar')
|
$('.ui.sidebar')
|
||||||
.sidebar('attach events', '.toc.item')
|
.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'
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
@ -107,27 +107,3 @@
|
|||||||
{% include 'footer.html.twig' %}
|
{% include 'footer.html.twig' %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% 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 %}
|
{% block body %}
|
||||||
|
|
||||||
{% endblock %}
|
{% 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 %}
|
{% 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 %}
|
{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
|
|
||||||
{% block javascripts %}
|
{% block javascripts %}
|
||||||
{{ parent() }}
|
{{ 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">
|
<script type="text/javascript">
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
$('#model-viewer').ModelViewer('{{ path('media_file', {'path': model.path }) }}');
|
$('#model-viewer').ModelViewer('{{ path('media_file', {'path': model.path }) }}');
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="spacing top">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="spacing top">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,14 +30,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="ui top attached tabular menu submenu">
|
<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 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 {% 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/multicolor"><i class="list layout icon"></i> Multi-Color</a>
|
||||||
</div>
|
</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})) }}
|
{{ render(path('set_models', {id: set.id})) }}
|
||||||
</div>
|
</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})) }}
|
{{ render(path('set_colors', {id: set.id})) }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% 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