mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-17 12:50:08 -07:00
Fix pagination
This commit is contained in:
parent
8ad9c14765
commit
ed5c70d349
@ -25,8 +25,8 @@
|
|||||||
<div class="ui header vertical noborder">
|
<div class="ui header vertical noborder">
|
||||||
<div class="ui text menu right floated">
|
<div class="ui text menu right floated">
|
||||||
<div class="header item">Sort By</div>
|
<div class="header item">Sort By</div>
|
||||||
{{ knp_pagination_sortable(models, 'Number', 'm.id', {'class':'item'}) }}
|
{{ knp_pagination_sortable(models, 'Number', 'm.id') }}
|
||||||
{{ knp_pagination_sortable(models, 'Name', ['m.name'], {'class':'item'}) }}
|
{{ knp_pagination_sortable(models, 'Name', 'm.name') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="found-count ui text menu">
|
<div class="found-count ui text menu">
|
||||||
<div class="header item">Showing</div>
|
<div class="header item">Showing</div>
|
||||||
|
12
app/Resources/views/pagination/sortable_link.html.twig
Normal file
12
app/Resources/views/pagination/sortable_link.html.twig
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{% if options['class'] == 'asc' %}
|
||||||
|
{% set icon = '<i class="icon sort content ascending"></i>' %}
|
||||||
|
{% set class = 'item active' %}
|
||||||
|
{% elseif options['class'] == 'desc' %}
|
||||||
|
{% set icon = '<i class="icon sort content descending"></i>' %}
|
||||||
|
{% set class = 'item active' %}
|
||||||
|
{% else %}
|
||||||
|
{% set icon = null %}
|
||||||
|
{% set class = 'item' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<a class="{{ class }}" {% for attr, value in options %} {{ attr }}="{{ value }}"{% endfor %}>{{ icon|raw }} {{ title }}</a>
|
@ -29,10 +29,12 @@
|
|||||||
<div class="ui header vertical noborder">
|
<div class="ui header vertical noborder">
|
||||||
<div class="ui text menu right floated">
|
<div class="ui text menu right floated">
|
||||||
<div class="header item">Sort By</div>
|
<div class="header item">Sort By</div>
|
||||||
{{ knp_pagination_sortable(sets, 'Number', 's.id', {'class':'item'}) }}
|
|
||||||
{{ knp_pagination_sortable(sets, 'Year', 's.year', {'class':'item'}) }}
|
{{ knp_pagination_sortable(sets, 'Number', ['s.id']) }}
|
||||||
{{ knp_pagination_sortable(sets, 'Name', ['s.name'], {'class':'item'}) }}
|
{{ knp_pagination_sortable(sets, 'Year', ['s.year']) }}
|
||||||
{{ knp_pagination_sortable(sets, 'Parts', ['s.partCount'], {'class':'item'}) }}
|
{{ knp_pagination_sortable(sets, 'Name', ['s.name']) }}
|
||||||
|
{{ knp_pagination_sortable(sets, 'Parts', ['s.partCount']) }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="found-count ui text menu">
|
<div class="found-count ui text menu">
|
||||||
<div class="header item">Showing</div>
|
<div class="header item">Showing</div>
|
||||||
|
@ -99,15 +99,15 @@ knp_menu:
|
|||||||
default_renderer: twig
|
default_renderer: twig
|
||||||
|
|
||||||
knp_paginator:
|
knp_paginator:
|
||||||
page_range: 10 # default page range used in pagination control
|
page_range: 5 # default page range used in pagination control
|
||||||
default_options:
|
default_options:
|
||||||
page_name: page # page query parameter name
|
page_name: page # page query parameter name
|
||||||
sort_field_name: sort # sort field query parameter name
|
sort_field_name: sort # sort field query parameter name
|
||||||
sort_direction_name: direction # sort direction query parameter name
|
sort_direction_name: dir # sort direction query parameter name
|
||||||
distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
|
distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
|
||||||
template:
|
template:
|
||||||
pagination: :pagination:knp_pagination.html.twig
|
pagination: :pagination:knp_pagination.html.twig
|
||||||
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
|
sortable: :pagination:sortable_link.html.twig
|
||||||
|
|
||||||
oneup_flysystem:
|
oneup_flysystem:
|
||||||
adapters:
|
adapters:
|
||||||
|
@ -10,27 +10,31 @@ fos_elastica:
|
|||||||
custom_analyzer:
|
custom_analyzer:
|
||||||
type: custom
|
type: custom
|
||||||
tokenizer: nGram
|
tokenizer: nGram
|
||||||
filter: [lowercase, snowball]
|
filter: [lowercase,stopwords]
|
||||||
tokenizer:
|
tokenizer:
|
||||||
nGram:
|
nGram:
|
||||||
type: nGram
|
type: nGram
|
||||||
min_gram: 3
|
min_gram: 3
|
||||||
max_gram: 10
|
max_gram: 20
|
||||||
filter:
|
filter:
|
||||||
snowball:
|
snowball:
|
||||||
type: snowball
|
type: snowball
|
||||||
language: English
|
language: English
|
||||||
|
stopwords:
|
||||||
|
type: stop
|
||||||
|
stopwords: [_english_]
|
||||||
|
ignore_case : true
|
||||||
types:
|
types:
|
||||||
set:
|
set:
|
||||||
mappings:
|
mappings:
|
||||||
id: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
id: ~
|
||||||
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
||||||
year: { type: integer }
|
year: { type: integer }
|
||||||
partCount: { type: integer }
|
partCount: { type: integer }
|
||||||
theme:
|
theme:
|
||||||
type: "object"
|
type: "object"
|
||||||
properties:
|
properties:
|
||||||
id: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
id: ~
|
||||||
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
||||||
persistence:
|
persistence:
|
||||||
driver: orm
|
driver: orm
|
||||||
@ -40,16 +44,16 @@ fos_elastica:
|
|||||||
repository: AppBundle\Repository\Search\SetRepository
|
repository: AppBundle\Repository\Search\SetRepository
|
||||||
model:
|
model:
|
||||||
mappings:
|
mappings:
|
||||||
id: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
id: ~
|
||||||
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
||||||
aliases:
|
aliases:
|
||||||
type: "object"
|
type: "object"
|
||||||
properties:
|
properties:
|
||||||
id: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
id: ~
|
||||||
category:
|
category:
|
||||||
type: "object"
|
type: "object"
|
||||||
properties:
|
properties:
|
||||||
id: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
id: ~
|
||||||
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
name: { analyzer: custom_analyzer, search_analyzer: "standard" }
|
||||||
keywords:
|
keywords:
|
||||||
type: "object"
|
type: "object"
|
||||||
|
@ -5,6 +5,7 @@ namespace AppBundle\Controller;
|
|||||||
use AppBundle\Entity\LDraw\Model;
|
use AppBundle\Entity\LDraw\Model;
|
||||||
use AppBundle\Form\Search\ModelSearchType;
|
use AppBundle\Form\Search\ModelSearchType;
|
||||||
use AppBundle\Model\ModelSearch;
|
use AppBundle\Model\ModelSearch;
|
||||||
|
use Knp\Component\Pager\Paginator;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
@ -32,15 +33,9 @@ class ModelController extends Controller
|
|||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
$elasticaManager = $this->get('fos_elastica.manager');
|
$elasticaManager = $this->get('fos_elastica.manager');
|
||||||
$results = $elasticaManager->getRepository(Model::class)->search($modelSearch);
|
$results = $elasticaManager->getRepository(Model::class)->search($modelSearch,5000);
|
||||||
|
|
||||||
$paginator = $this->get('knp_paginator');
|
|
||||||
$sets = $paginator->paginate(
|
|
||||||
$results,
|
|
||||||
$request->query->getInt('page', 1)/*page number*/,
|
|
||||||
$request->query->getInt('limit', 30)/*limit per page*/
|
|
||||||
);
|
|
||||||
|
|
||||||
|
/** @var Paginator $paginator */
|
||||||
$paginator = $this->get('knp_paginator');
|
$paginator = $this->get('knp_paginator');
|
||||||
$models = $paginator->paginate(
|
$models = $paginator->paginate(
|
||||||
$results,
|
$results,
|
||||||
|
@ -37,13 +37,13 @@ class ModelRepository extends Repository
|
|||||||
return new Query($boolQuery);
|
return new Query($boolQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search(ModelSearch $modelSearch)
|
public function search(ModelSearch $modelSearch, $limit = 500)
|
||||||
{
|
{
|
||||||
$query = $this->getSearchQuery($modelSearch);
|
$query = $this->getSearchQuery($modelSearch);
|
||||||
return $this->find($query, 500);
|
return $this->find($query, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findHighlighted($query, $limit = null) {
|
public function findHighlighted($query, $limit = 500) {
|
||||||
$modelSearch = new ModelSearch();
|
$modelSearch = new ModelSearch();
|
||||||
$modelSearch->setQuery($query);
|
$modelSearch->setQuery($query);
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ class SetRepository extends Repository
|
|||||||
$query->setQuery($searchQuery);
|
$query->setQuery($searchQuery);
|
||||||
$query->setFuzziness(0.7);
|
$query->setFuzziness(0.7);
|
||||||
$query->setMinimumShouldMatch('80%');
|
$query->setMinimumShouldMatch('80%');
|
||||||
|
$query->setOperator('and');
|
||||||
|
|
||||||
$boolQuery->addMust($query);
|
$boolQuery->addMust($query);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$query = new \Elastica\Query\MatchAll();
|
$query = new \Elastica\Query\MatchAll();
|
||||||
$boolQuery->addMust($query);
|
$boolQuery->addMust($query);
|
||||||
@ -69,7 +69,7 @@ class SetRepository extends Repository
|
|||||||
return $this->find($query, $limit);
|
return $this->find($query, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findHighlighted($query, $limit = null) {
|
public function findHighlighted($query, $limit = 500) {
|
||||||
$setSearch = new SetSearch();
|
$setSearch = new SetSearch();
|
||||||
$setSearch->setQuery($query);
|
$setSearch->setQuery($query);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user