Revize 4399f189
Přidáno uživatelem Jan Šedivý před téměř 6 roky(ů)
app/FrontModule/component/Transliteration/TransliterationSearchResultList.latte | ||
---|---|---|
58 | 58 |
</div> |
59 | 59 |
|
60 | 60 |
{/foreach} |
61 |
{/snippet} |
|
61 |
|
|
62 |
{control searchSettingsForm} |
|
63 |
{/snippet} |
|
64 |
|
|
65 |
{block scripts} |
|
66 |
<script> |
|
67 |
$(document).ready(function () { |
|
68 |
let limit = $('select[name="limit"]'); |
|
69 |
limit.change(function () { |
|
70 |
console.log(limit.val()); |
|
71 |
$.nette.ajax({ |
|
72 |
url: {link changeLimit!}, |
|
73 |
data: {'limit': limit.val()} |
|
74 |
}) |
|
75 |
}); |
|
76 |
|
|
77 |
$('select[name="lines"]').change(function () { |
|
78 |
|
|
79 |
}); |
|
80 |
}) |
|
81 |
</script> |
|
82 |
{/block} |
app/FrontModule/component/Transliteration/TransliterationSearchResultList.php | ||
---|---|---|
5 | 5 |
|
6 | 6 |
use App\Model\Repository\TransliterationRepository; |
7 | 7 |
use App\Model\TransliterationSearchModel; |
8 |
use App\Utils\Form; |
|
8 | 9 |
use App\Utils\Paginator; |
9 | 10 |
use Nette\Application\UI\Control; |
10 | 11 |
use Tracy\Debugger; |
... | ... | |
20 | 21 |
/** @var PaginatorControl */ |
21 | 22 |
private $paginator; |
22 | 23 |
|
24 |
/** |
|
25 |
* @var \Nette\Utils\ArrayHash|null |
|
26 |
* @persistent |
|
27 |
*/ |
|
23 | 28 |
private $searchTerms; |
29 |
|
|
24 | 30 |
private $resultRows; |
25 | 31 |
private $totalCount; |
26 | 32 |
|
... | ... | |
69 | 75 |
$this->paginator = new Paginator($page, $limit); |
70 | 76 |
$this->redrawControl('resultList'); |
71 | 77 |
} |
78 |
|
|
79 |
public function createComponentSearchSettingsForm() |
|
80 |
{ |
|
81 |
$form = new Form(); |
|
82 |
|
|
83 |
$form->addSelect('limit', 'Results per page: ', Paginator::ALLOWED_LIMITS); |
|
84 |
$form->addSelect('lines', 'Show adjacent lines', TransliterationRepository::ADJACENT_LINES); |
|
85 |
|
|
86 |
return $form; |
|
87 |
} |
|
88 |
|
|
89 |
public function handleChangeLimit($limit) |
|
90 |
{ |
|
91 |
$this->paginator = new Paginator(1, Paginator::ALLOWED_LIMITS[$limit]); |
|
92 |
$this->redrawControl('resultList'); |
|
93 |
} |
|
72 | 94 |
} |
73 | 95 |
|
74 | 96 |
interface ITransliterationSearchResultListFactory |
app/model/repository/TransliterationRepository.php | ||
---|---|---|
30 | 30 |
const COLUMN_DATE = 'date'; |
31 | 31 |
const COLUMN_NOTE = 'note'; |
32 | 32 |
|
33 |
const ADJACENT_LINES = [0, 1, 2, 3, 5, 10, 15]; |
|
34 |
|
|
33 | 35 |
/** |
34 | 36 |
* Vyhledává texty podle slov v řádcích textu |
35 | 37 |
* @param ArrayHash $queryParams objekt s podmínkami pro hledaný text |
Také k dispozici: Unified diff
Re #7328 Ajax pro změnu výsledků na stránku