From 3bd04a3b94c91f2dec6bfa6f86873a415d3474e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20H=C3=BCbner?= Date: Mon, 27 Mar 2017 18:33:17 +0200 Subject: [PATCH] Update controllers --- app/Resources/{ => assets}/js/ModelViewer.js | 0 app/Resources/assets/js/style.js | 5 ++++ app/Resources/assets/style/_variables.scss | 0 app/Resources/assets/style/main.scss | 3 +++ app/Resources/assets/style/style.scss | 4 ++++ app/Resources/views/default/index.html.twig | 2 +- app/Resources/views/set/browse.html.twig | 25 ++++++++++++++------ app/Resources/views/set/detail.html.twig | 18 +++++++------- app/config/config.yml | 7 ++---- src/AppBundle/Controller/MediaController.php | 12 +++++----- src/AppBundle/Controller/SetController.php | 20 ++++++++++++---- src/AppBundle/Form/FilterSetType.php | 3 --- 12 files changed, 64 insertions(+), 35 deletions(-) rename app/Resources/{ => assets}/js/ModelViewer.js (100%) create mode 100644 app/Resources/assets/js/style.js create mode 100644 app/Resources/assets/style/_variables.scss create mode 100644 app/Resources/assets/style/main.scss create mode 100644 app/Resources/assets/style/style.scss diff --git a/app/Resources/js/ModelViewer.js b/app/Resources/assets/js/ModelViewer.js similarity index 100% rename from app/Resources/js/ModelViewer.js rename to app/Resources/assets/js/ModelViewer.js diff --git a/app/Resources/assets/js/style.js b/app/Resources/assets/js/style.js new file mode 100644 index 0000000..1dd56df --- /dev/null +++ b/app/Resources/assets/js/style.js @@ -0,0 +1,5 @@ +$(document).ready(function () { + $('.ui.dropdown') + .dropdown() + ; +}); \ No newline at end of file diff --git a/app/Resources/assets/style/_variables.scss b/app/Resources/assets/style/_variables.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/Resources/assets/style/main.scss b/app/Resources/assets/style/main.scss new file mode 100644 index 0000000..f61917a --- /dev/null +++ b/app/Resources/assets/style/main.scss @@ -0,0 +1,3 @@ +.ui.fixed + .ui.main { + margin-top: 5em; +} \ No newline at end of file diff --git a/app/Resources/assets/style/style.scss b/app/Resources/assets/style/style.scss new file mode 100644 index 0000000..263739b --- /dev/null +++ b/app/Resources/assets/style/style.scss @@ -0,0 +1,4 @@ +@import "variables"; + +@import "main"; + diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig index e8b7a5f..918e8e0 100644 --- a/app/Resources/views/default/index.html.twig +++ b/app/Resources/views/default/index.html.twig @@ -1,6 +1,6 @@ {% extends 'base.html.twig' %} -{% block body %} +{% block content %} {% endblock %} diff --git a/app/Resources/views/set/browse.html.twig b/app/Resources/views/set/browse.html.twig index 5aadde4..8bab86c 100644 --- a/app/Resources/views/set/browse.html.twig +++ b/app/Resources/views/set/browse.html.twig @@ -1,20 +1,31 @@ {% extends 'base.html.twig' %} -{% block body %} +{% block content %} {{ form_start(form) }} -
+
{{ form_row(form.theme) }} {{ form_row(form.subtheme) }} {{ form_row(form.years) }} +
+ + +
{{ form_end(form) }} - +
+
+ {% for set in sets %} + + {% endfor %} +
+
{% endblock %} {% block javascripts %} diff --git a/app/Resources/views/set/detail.html.twig b/app/Resources/views/set/detail.html.twig index d4f9e14..b64e766 100644 --- a/app/Resources/views/set/detail.html.twig +++ b/app/Resources/views/set/detail.html.twig @@ -1,27 +1,27 @@ {% extends 'base.html.twig' %} -{% block body %} +{% block content %} {{ dump(set) }} {{ dump(brset) }} -

{{ brset.name }}

- +

{{brset ? brset.name }}

+ {% if set is not null %} - {% for inventory in set.inventories %} + {#{% for inventory in set.inventories %}#}

Parts

- {% for inventoryPart in inventory.inventoryParts %} + {% for inventoryPart in inventoryParts %}
- -

{{ inventoryPart.part.id }} {{ inventoryPart.quantity }}

+ +

{{ inventoryPart.part.number }} {{ inventoryPart.quantity }}

{% endfor %}
- {% else %} + {#{% else %}#} - {% endfor %} + {#{% endfor %}#} {% endif %} {% endblock %} \ No newline at end of file diff --git a/app/config/config.yml b/app/config/config.yml index 6bf6a57..e415e26 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -73,12 +73,9 @@ swiftmailer: spool: { type: memory } knp_menu: - # use "twig: false" to disable the Twig extension and the TwigRenderer twig: - template: KnpMenuBundle::menu.html.twig - # if true, enables the helper for PHP templates + template: menu/knp_menu.html.twig templating: false - # the renderer to use, list is also available by default default_renderer: twig knp_paginator: @@ -89,7 +86,7 @@ knp_paginator: sort_direction_name: direction # sort direction query parameter name distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements template: - pagination: KnpPaginatorBundle:Pagination:sliding.html.twig # sliding pagination controls template + pagination: KnpPaginatorBundle:Pagination:semantic_ui_pagination.html.twig # sliding pagination controls template sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template oneup_flysystem: diff --git a/src/AppBundle/Controller/MediaController.php b/src/AppBundle/Controller/MediaController.php index 958fab8..1006a11 100644 --- a/src/AppBundle/Controller/MediaController.php +++ b/src/AppBundle/Controller/MediaController.php @@ -32,7 +32,7 @@ class MediaController extends Controller // Create the disposition of the file $disposition = $response->headers->makeDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, - $model->getId().'.stl' + $model->getNumber().'.stl' ); $response->headers->set('Content-Disposition', $disposition); @@ -43,7 +43,7 @@ class MediaController extends Controller } /** - * @Route("/part/{id}", name="part_image") + * @Route("/part/{number}", name="part_image") * * @return Response */ @@ -51,20 +51,20 @@ class MediaController extends Controller { $mediaFilesystem = $this->get('oneup_flysystem.media_filesystem'); - if ($mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getId().'.png')) { - $response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getId().'.png'); + if ($mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getNumber().'.png')) { + $response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getNumber().'.png'); $response->headers->set('Content-Type', 'image/png'); // Create the disposition of the file $disposition = $response->headers->makeDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, - $part->getId().'png' + $part->getNumber().'png' ); $response->headers->set('Content-Disposition', $disposition); return $response; } - throw new FileNotFoundException($part->getId().'png'); + throw new FileNotFoundException($part->getNumber().'png'); } } diff --git a/src/AppBundle/Controller/SetController.php b/src/AppBundle/Controller/SetController.php index 1cec121..9784616 100644 --- a/src/AppBundle/Controller/SetController.php +++ b/src/AppBundle/Controller/SetController.php @@ -2,7 +2,11 @@ namespace AppBundle\Controller; +use AppBundle\Entity\Rebrickable\Color; +use AppBundle\Entity\Rebrickable\Inventory_Part; +use AppBundle\Entity\Rebrickable\Part; use AppBundle\Entity\Rebrickable\Set; +use AppBundle\Entity\Rebrickable\Theme; use AppBundle\Form\FilterSetType; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -40,17 +44,25 @@ class SetController extends Controller } /** - * @Route("/detail/{id}_{name}", name="set_detail") + * @Route("/detail/{number}_{name}", name="set_detail") */ - public function detailAction(Request $request, $id, $name = null) + public function detailAction(Request $request, $number, $name = null) { - $brset = $this->get('manager.brickset')->getSetByNumber($id); + $brset = $this->get('manager.brickset')->getSetByNumber($number); - $set = $this->get('doctrine.orm.default_entity_manager')->getRepository(Set::class)->find($id); + $set = $this->get('doctrine.orm.default_entity_manager')->getRepository(Set::class)->find($number); + + $em = $this->getDoctrine()->getManager(); + + $em->getRepository(Color::class)->findAll(); + + $em->getRepository(Theme::class)->findAll(); return $this->render('set/detail.html.twig', [ 'set' => $set, 'brset' => $brset, + 'parts' => $em->getRepository(Part::class)->findAllBySetNumber($number), + 'inventoryParts' => $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number), ]); } } diff --git a/src/AppBundle/Form/FilterSetType.php b/src/AppBundle/Form/FilterSetType.php index 50f57e2..3305c81 100644 --- a/src/AppBundle/Form/FilterSetType.php +++ b/src/AppBundle/Form/FilterSetType.php @@ -8,7 +8,6 @@ use AppBundle\Api\Client\Brickset\Entity\Year; use AppBundle\Api\Manager\BricksetManager; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Form; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvent; @@ -74,7 +73,5 @@ class FilterSetType extends AbstractType $formModifier($event->getForm()->getParent(), $theme); } ); - - $builder->add('submit', SubmitType::class); } }