Revize 94fce7fe
Přidáno uživatelem Filip Jani před téměř 6 roky(ů)
app/AdminModule/component/Transliteration/TransliterationEditForm.php | ||
---|---|---|
141 | 141 |
$multiplier->addCreateButton('Add', 1, $redrawCallback); |
142 | 142 |
$multiplier->addRemoveButton('Remove', $redrawCallback); |
143 | 143 |
|
144 |
if($this->transliterationId != null){ |
|
145 |
$this->form->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBookAbbrevForSelect()); |
|
146 |
$this->form->setDefaults($this->getDefaults()); |
|
147 |
} |
|
148 |
|
|
149 | 144 |
$this->form->addSubmit('submit', 'Save'); |
150 | 145 |
|
146 |
$this->form->setDefaults($this->getDefaults()); |
|
147 |
|
|
151 | 148 |
$this->form->onValidate[] = [$this, 'formValidate']; |
152 | 149 |
$this->form->onSuccess[] = [$this, 'formSuccess']; |
153 | 150 |
|
... | ... | |
209 | 206 |
*/ |
210 | 207 |
private function getDefaults() |
211 | 208 |
{ |
209 |
$array = []; |
|
210 |
|
|
212 | 211 |
if($this->transliterationId != null){ |
213 | 212 |
$array = $this->transliterationRepository->findRow($this->transliterationId)->toArray(); |
214 | 213 |
$references = $this->litReferenceRepository->findByTransliterationId($this->transliterationId)->fetchAll(); |
... | ... | |
217 | 216 |
{ |
218 | 217 |
$array['references'][] = $activeRow->toArray(); |
219 | 218 |
} |
220 |
|
|
221 |
return $array; |
|
222 | 219 |
} |
220 |
|
|
221 |
return $array; |
|
223 | 222 |
} |
224 | 223 |
|
225 | 224 |
} |
app/AdminModule/component/Transliteration/TransliterationNewForm.latte | ||
---|---|---|
35 | 35 |
<div id="{\App\AdminModule\Components\TransliterationNewForm::BOOK_NEW_ID}"> |
36 | 36 |
<div class="row mb-2"> |
37 | 37 |
<div class="col-4"> |
38 |
{label $form['bookContainer'][\App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV], class => 'required'} |
|
38 |
{label $form['bookContainer'][\App\Model\Repository\BookRepository::COLUMN_BOOK_ABBREV], class => 'required'}
|
|
39 | 39 |
</div> |
40 | 40 |
<div class="col-8"> |
41 |
{input $form['bookContainer'][\App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV]} |
|
41 |
{input $form['bookContainer'][\App\Model\Repository\BookRepository::COLUMN_BOOK_ABBREV]}
|
|
42 | 42 |
</div> |
43 | 43 |
</div> |
44 | 44 |
|
app/AdminModule/component/Transliteration/TransliterationNewForm.php | ||
---|---|---|
148 | 148 |
->toggle(self::BOOK_NEW_ID) |
149 | 149 |
->endCondition(); |
150 | 150 |
|
151 |
$bookContainer->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBookAbbrevForSelect()); |
|
151 |
$bookContainer->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBooksAbbrevForSelect());
|
|
152 | 152 |
|
153 |
$bookContainer->addText(BookRepository::COLUMN_BOOK_ABREV, 'Abbreviation') |
|
153 |
$bookContainer->addText(BookRepository::COLUMN_BOOK_ABBREV, 'Abbreviation')
|
|
154 | 154 |
->addConditionOn($this->form['bookContainer']['book'], Form::EQUAL, self::BOOK_NEW) |
155 | 155 |
->addRule(Form::REQUIRED, 'Field %label is required', TRUE); |
156 | 156 |
$bookContainer->addText(BookRepository::COLUMN_BOOK_AUTHOR, 'Author'); |
app/FrontModule/component/ExampleGrid.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
|
|
4 |
namespace App\FrontModule\Components; |
|
5 |
|
|
6 |
|
|
7 |
use App\Utils\DataGrid\DataGrid; |
|
8 |
use App\Model\Repository\LineRepository; |
|
9 |
use Ublaboo\DataGrid\Exception\DataGridException; |
|
10 |
|
|
11 |
/** |
|
12 |
* Ukázkový datagrid, bude smazán při předání |
|
13 |
* - všechny možnosti použití gridu lze vidět na |
|
14 |
* https://gitlab.com/Fifal/dvm/blob/21afc037e3604093197e140defc05925df0b8c28/web-project/app/components/variant/VariantGrid.php |
|
15 |
* |
|
16 |
* @package App\Components |
|
17 |
*/ |
|
18 |
class ExampleGrid extends DataGrid |
|
19 |
{ |
|
20 |
/** @var LineRepository */ |
|
21 |
private $lineRepository; |
|
22 |
|
|
23 |
public function __construct(LineRepository $lineRepository) |
|
24 |
{ |
|
25 |
$this->lineRepository = $lineRepository; |
|
26 |
|
|
27 |
parent::__construct(); |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* Abstraktní metoda, slouží k nastavení primárního klíče a nastavení datasource |
|
32 |
* 1. $this->setPrimaryKey(); |
|
33 |
* 2. $this->setDataSource(); |
|
34 |
* |
|
35 |
* @throws DataGridException |
|
36 |
*/ |
|
37 |
public function init() |
|
38 |
{ |
|
39 |
$this->setPrimaryKey(LineRepository::COLUMN_ID); |
|
40 |
$this->setDataSource($this->lineRepository->findAll()); |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* Definice sloupečků, akcí, vyhledávácích filtrů gridu |
|
45 |
* |
|
46 |
* @throws DataGridException |
|
47 |
*/ |
|
48 |
public function define() |
|
49 |
{ |
|
50 |
$this->addColumnNumber(LineRepository::COLUMN_ID, "ID"); |
|
51 |
$this->addColumnText(LineRepository::COLUMN_TRANSLITERATION, "Transliterace"); |
|
52 |
$this->addFilterText(LineRepository::COLUMN_TRANSLITERATION, "Transliterace"); |
|
53 |
|
|
54 |
$this->addAction(LineRepository::COLUMN_TRANSLITERATION, "Smazat"); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
interface IExampleGirdFactory |
|
59 |
{ |
|
60 |
/** |
|
61 |
* Funkce create je implementována již v předkovi |
|
62 |
* |
|
63 |
* @return ExampleGrid |
|
64 |
*/ |
|
65 |
public function create(); |
|
66 |
} |
app/FrontModule/presenters/HomepagePresenter.php | ||
---|---|---|
3 | 3 |
namespace App\FrontModule\Presenters; |
4 | 4 |
|
5 | 5 |
use App\FrontModule\Components\IUserSettingsFormFactory; |
6 |
use App\FrontModule\Components\IExampleGirdFactory; |
|
7 | 6 |
use App\FrontModule\Components\ILoginFormFactory; |
8 | 7 |
use App\Enum\EFlashMessage; |
9 | 8 |
use Nette; |
... | ... | |
11 | 10 |
|
12 | 11 |
final class HomepagePresenter extends Nette\Application\UI\Presenter |
13 | 12 |
{ |
14 |
/** @var IExampleGirdFactory */ |
|
15 |
private $exampleGridFactory; |
|
16 | 13 |
/** @var ILoginFormFactory */ |
17 | 14 |
private $loginFormFactory; |
18 | 15 |
|
19 | 16 |
/** @var IUserSettingsFormFactory */ |
20 | 17 |
private $userSettingsFormFactory; |
21 | 18 |
|
22 |
public function __construct(IExampleGirdFactory $exampleGridFactory, |
|
23 |
ILoginFormFactory $loginFormFactory, |
|
19 |
public function __construct(ILoginFormFactory $loginFormFactory, |
|
24 | 20 |
IUserSettingsFormFactory $userSettingsFormFactory |
25 | 21 |
) |
26 | 22 |
{ |
27 | 23 |
parent::__construct(); |
28 | 24 |
|
29 |
$this->exampleGridFactory = $exampleGridFactory; |
|
30 | 25 |
$this->loginFormFactory = $loginFormFactory; |
31 | 26 |
$this->userSettingsFormFactory = $userSettingsFormFactory; |
32 | 27 |
} |
... | ... | |
79 | 74 |
public function createComponentUserSettingsForm(){ |
80 | 75 |
return $this->userSettingsFormFactory->create(); |
81 | 76 |
} |
82 |
|
|
83 |
/** |
|
84 |
* Vytvoření ukázkového gridu |
|
85 |
*/ |
|
86 |
public function createComponentDataGrid() |
|
87 |
{ |
|
88 |
return $this->exampleGridFactory->create(); |
|
89 |
} |
|
90 | 77 |
} |
app/config/components.neon | ||
---|---|---|
1 | 1 |
services: |
2 | 2 |
# Gridy |
3 |
- App\FrontModule\Components\IExampleGirdFactory |
|
4 | 3 |
- App\AdminModule\Components\IUserGridFactory |
5 | 4 |
- App\AdminModule\Components\IMuseumGridFactory |
6 | 5 |
- App\AdminModule\Components\IObjectTypeGridFactory |
app/templates/@menu.latte | ||
---|---|---|
16 | 16 |
<a n:class="nav-link, $presenter->isLinkCurrent(':Front:Contact:default') ? active" n:href=":Front:Contact:default">Contact & members</a> |
17 | 17 |
</li> |
18 | 18 |
<li class="nav-item"> |
19 |
<a n:class="nav-link, $presenter->isLinkCurrent(':Admin:Transliteration:*') ? active" n:href=":Admin:Transliteration:new">Input new text</a>
|
|
19 |
<a n:class="nav-link, $presenter->isLinkCurrent(':Admin:Transliteration:new') ? active" n:href=":Admin:Transliteration:new">Input new text</a>
|
|
20 | 20 |
</li> |
21 | 21 |
{if $user->loggedIn && ($user->isInRole(\App\Enum\EUserRole::ADMIN) || $user->isInRole(\App\Enum\EUserRole::USER))} |
22 | 22 |
<li class="nav-item"> |
Také k dispozici: Unified diff
Úpravy po mergi