Revize c8d80ce7
Přidáno uživatelem Jan Palcút před téměř 6 roky(ů)
app/AdminModule/component/Book/BookEditForm.php | ||
---|---|---|
16 | 16 |
/** |
17 | 17 |
* @var Form |
18 | 18 |
*/ |
19 |
private $form;
|
|
19 |
protected $form;
|
|
20 | 20 |
/** |
21 | 21 |
* @var BookRepository |
22 | 22 |
*/ |
23 |
private $bookRepository;
|
|
23 |
protected $bookRepository;
|
|
24 | 24 |
|
25 | 25 |
public function __construct(BookRepository $bookRepository) |
26 | 26 |
{ |
app/AdminModule/component/Book/BookOptionForm.latte | ||
---|---|---|
1 |
{form form} |
|
2 |
<div class="row"> |
|
3 |
<div class="col-12"> |
|
4 |
|
|
5 |
<div class="row mb-2"> |
|
6 |
<div class="col-4"> |
|
7 |
{label \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID} |
|
8 |
</div> |
|
9 |
<div class="col-8"> |
|
10 |
{input \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID} |
|
11 |
</div> |
|
12 |
</div> |
|
13 |
|
|
14 |
<div class="row mb-2"> |
|
15 |
<div class="col-4"> |
|
16 |
{label \App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV} |
|
17 |
</div> |
|
18 |
<div class="col-8"> |
|
19 |
{input \App\Model\Repository\BookRepository::COLUMN_BOOK_ABREV} |
|
20 |
</div> |
|
21 |
</div> |
|
22 |
|
|
23 |
<div class="row mb-2"> |
|
24 |
<div class="col-4"> |
|
25 |
{label \App\Model\Repository\BookRepository::COLUMN_BOOK_AUTHOR} |
|
26 |
</div> |
|
27 |
<div class="col-8"> |
|
28 |
{input \App\Model\Repository\BookRepository::COLUMN_BOOK_AUTHOR} |
|
29 |
</div> |
|
30 |
</div> |
|
31 |
|
|
32 |
<div class="row mb-2"> |
|
33 |
<div class="col-4"> |
|
34 |
{label \App\Model\Repository\BookRepository::COLUMN_BOOK_NAME} |
|
35 |
</div> |
|
36 |
<div class="col-8"> |
|
37 |
{input \App\Model\Repository\BookRepository::COLUMN_BOOK_NAME} |
|
38 |
</div> |
|
39 |
</div> |
|
40 |
|
|
41 |
<div class="row mb-2"> |
|
42 |
<div class="col-4"> |
|
43 |
{label \App\Model\Repository\BookRepository::COLUMN_BOOK_DESCRIPTION} |
|
44 |
</div> |
|
45 |
<div class="col-8"> |
|
46 |
{input \App\Model\Repository\BookRepository::COLUMN_BOOK_DESCRIPTION} |
|
47 |
</div> |
|
48 |
</div> |
|
49 |
|
|
50 |
<div class="row mb-2"> |
|
51 |
<div class="col-4"> |
|
52 |
{label \App\Model\Repository\BookRepository::COLUMN_PLACE_OF_PUB} |
|
53 |
</div> |
|
54 |
<div class="col-8"> |
|
55 |
{input \App\Model\Repository\BookRepository::COLUMN_PLACE_OF_PUB} |
|
56 |
</div> |
|
57 |
</div> |
|
58 |
|
|
59 |
<div class="row mb-2"> |
|
60 |
<div class="col-4"> |
|
61 |
{label \App\Model\Repository\BookRepository::COLUMN_DATE_OF_PUB} |
|
62 |
</div> |
|
63 |
<div class="col-8"> |
|
64 |
{input \App\Model\Repository\BookRepository::COLUMN_DATE_OF_PUB} |
|
65 |
</div> |
|
66 |
</div> |
|
67 |
|
|
68 |
<div class="row mb-2"> |
|
69 |
<div class="col-4"> |
|
70 |
{label \App\Model\Repository\BookRepository::COLUMN_PAGES} |
|
71 |
</div> |
|
72 |
<div class="col-8"> |
|
73 |
{input \App\Model\Repository\BookRepository::COLUMN_PAGES} |
|
74 |
</div> |
|
75 |
</div> |
|
76 |
|
|
77 |
<div class="row mb-2"> |
|
78 |
<div class="col-4"> |
|
79 |
{label \App\Model\Repository\BookRepository::COLUMN_VOLUME} |
|
80 |
</div> |
|
81 |
<div class="col-8"> |
|
82 |
{input \App\Model\Repository\BookRepository::COLUMN_VOLUME} |
|
83 |
</div> |
|
84 |
</div> |
|
85 |
|
|
86 |
<div class="row mb-2"> |
|
87 |
<div class="col-4"> |
|
88 |
{label \App\Model\Repository\BookRepository::COLUMN_VOLUME_NO} |
|
89 |
</div> |
|
90 |
<div class="col-8"> |
|
91 |
{input \App\Model\Repository\BookRepository::COLUMN_VOLUME_NO} |
|
92 |
</div> |
|
93 |
</div> |
|
94 |
|
|
95 |
</div> |
|
96 |
</div> |
|
97 |
{/form} |
app/AdminModule/component/Book/BookOptionForm.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
|
|
4 |
namespace App\AdminModule\Components; |
|
5 |
|
|
6 |
|
|
7 |
use App\Model\Repository\BookRepository; |
|
8 |
use App\Model\Repository\TransliterationRepository; |
|
9 |
use App\Utils\Form; |
|
10 |
|
|
11 |
class BookOptionForm extends BookEditForm |
|
12 |
{ |
|
13 |
|
|
14 |
public function render() |
|
15 |
{ |
|
16 |
parent::render(); |
|
17 |
$this->template->setFile(__DIR__ . '/BookOptionForm.latte'); |
|
18 |
$this->template->render(); |
|
19 |
} |
|
20 |
|
|
21 |
public function createComponentForm() |
|
22 |
{ |
|
23 |
|
|
24 |
$this->form->addRadioList('book', 'Book option', [0 => 'Existing book', 1 => 'New book']) |
|
25 |
->addCondition($this->form::EQUAL, 0) |
|
26 |
->toggle(TransliterationRepository::COLUMN_BOOK_ID) |
|
27 |
->elseCondition($this->form::EQUAL, 1) |
|
28 |
->toggle(BookRepository::COLUMN_BOOK_ABREV) |
|
29 |
->toggle(BookRepository::COLUMN_BOOK_AUTHOR) |
|
30 |
->toggle(BookRepository::COLUMN_BOOK_NAME) |
|
31 |
->toggle(BookRepository::COLUMN_BOOK_SUBTITLE) |
|
32 |
->toggle(BookRepository::COLUMN_BOOK_DESCRIPTION) |
|
33 |
->toggle(BookRepository::COLUMN_PLACE_OF_PUB) |
|
34 |
->toggle(BookRepository::COLUMN_DATE_OF_PUB) |
|
35 |
->toggle(BookRepository::COLUMN_PAGES) |
|
36 |
->toggle(BookRepository::COLUMN_VOLUME) |
|
37 |
->toggle(BookRepository::COLUMN_VOLUME_NO) |
|
38 |
->endCondition(); |
|
39 |
|
|
40 |
$this->form->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBookAbbrevForSelect()) |
|
41 |
->setOption('id', TransliterationRepository::COLUMN_BOOK_ID); |
|
42 |
|
|
43 |
$this->form->addText(BookRepository::COLUMN_BOOK_ABREV, 'Abbreviation') |
|
44 |
->addRule(Form::REQUIRED, 'Field %label is required', TRUE) |
|
45 |
->setOption('id', BookRepository::COLUMN_BOOK_ABREV); |
|
46 |
|
|
47 |
$this->form->addText(BookRepository::COLUMN_BOOK_AUTHOR, 'Author') |
|
48 |
->setOption('id', BookRepository::COLUMN_BOOK_AUTHOR); |
|
49 |
|
|
50 |
$this->form->addText(BookRepository::COLUMN_BOOK_NAME, 'Name') |
|
51 |
->addRule(Form::REQUIRED, 'Field %label is required', TRUE) |
|
52 |
->setOption('id', BookRepository::COLUMN_BOOK_NAME); |
|
53 |
|
|
54 |
$this->form->addText(BookRepository::COLUMN_BOOK_SUBTITLE, 'Alternate name') |
|
55 |
->setOption('id', BookRepository::COLUMN_BOOK_SUBTITLE); |
|
56 |
|
|
57 |
$this->form->addTextArea(BookRepository::COLUMN_BOOK_DESCRIPTION, 'Description') |
|
58 |
->setOption('id', BookRepository::COLUMN_BOOK_DESCRIPTION); |
|
59 |
|
|
60 |
$this->form->addText(BookRepository::COLUMN_PLACE_OF_PUB, 'Publication place') |
|
61 |
->setOption('id', BookRepository::COLUMN_PLACE_OF_PUB); |
|
62 |
|
|
63 |
$this->form->addText(BookRepository::COLUMN_DATE_OF_PUB, 'Publication date') |
|
64 |
->setOption('id', BookRepository::COLUMN_DATE_OF_PUB); |
|
65 |
|
|
66 |
$this->form->addText(BookRepository::COLUMN_PAGES, 'Pages') |
|
67 |
->setOption('id', BookRepository::COLUMN_PAGES); |
|
68 |
|
|
69 |
$this->form->addText(BookRepository::COLUMN_VOLUME, 'Volume') |
|
70 |
->setOption('id', BookRepository::COLUMN_VOLUME); |
|
71 |
|
|
72 |
$this->form->addText(BookRepository::COLUMN_VOLUME_NO, 'Volume No.') |
|
73 |
; |
|
74 |
|
|
75 |
$this->form->setDefaults($this->getDefaults()); |
|
76 |
$this->form->setDefaults(['book' => '1']); |
|
77 |
|
|
78 |
$this->form->addSubmit('submit', 'Save'); |
|
79 |
|
|
80 |
$this->form->onSuccess[] = [$this, 'formSuccess']; |
|
81 |
|
|
82 |
return $this->form; |
|
83 |
} |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
interface IBookOptionFormFactory |
|
88 |
{ |
|
89 |
/** |
|
90 |
* @return BookOptionForm |
|
91 |
*/ |
|
92 |
public function create(); |
|
93 |
} |
app/AdminModule/component/Transliteration/TransliterationEditForm.latte | ||
---|---|---|
2 | 2 |
{form form} |
3 | 3 |
<div class="row"> |
4 | 4 |
<div class="col-12"> |
5 |
{if $addBook == true} |
|
5 | 6 |
<div class="row mb-2"> |
6 | 7 |
<div class="col-4"> |
7 | 8 |
{label \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID} |
... | ... | |
10 | 11 |
{input \App\Model\Repository\TransliterationRepository::COLUMN_BOOK_ID} |
11 | 12 |
</div> |
12 | 13 |
</div> |
13 |
|
|
14 |
{/if} |
|
14 | 15 |
<div class="row mb-2"> |
15 | 16 |
<div class="col-4"> |
16 | 17 |
{label \App\Model\Repository\TransliterationRepository::COLUMN_CHAPTER} |
app/AdminModule/component/Transliteration/TransliterationEditForm.php | ||
---|---|---|
93 | 93 |
public function render() |
94 | 94 |
{ |
95 | 95 |
$this->template->setFile(__DIR__ . '/TransliterationEditForm.latte'); |
96 |
|
|
97 |
$this->template->addBook = true; |
|
98 |
if($this->transliterationId == null){ |
|
99 |
$this->template->addBook = false; |
|
100 |
} |
|
101 |
|
|
96 | 102 |
$this->template->render(); |
97 | 103 |
} |
98 | 104 |
|
99 | 105 |
public function createComponentForm() |
100 | 106 |
{ |
101 |
$this->form->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBookAbbrevForSelect()); |
|
102 | 107 |
$this->form->addText(TransliterationRepository::COLUMN_CHAPTER, 'Chapter'); |
103 | 108 |
$this->form->addSelect(TransliterationRepository::COLUMN_MUSEUM_ID, 'Museum', $this->museumRepository->getMuseumNameForSelect()); |
104 | 109 |
$this->form->addText(TransliterationRepository::COLUMN_MUSEUM_NO, 'Museum No'); |
... | ... | |
127 | 132 |
$multiplier->addCreateButton('Add', 1, $redrawCallback); |
128 | 133 |
$multiplier->addRemoveButton('Remove', $redrawCallback); |
129 | 134 |
|
130 |
$this->form->setDefaults($this->getDefaults()); |
|
135 |
if($this->transliterationId != null){ |
|
136 |
$this->form->addSelect(TransliterationRepository::COLUMN_BOOK_ID, 'Book', $this->bookRepository->getBookAbbrevForSelect()); |
|
137 |
$this->form->setDefaults($this->getDefaults()); |
|
138 |
} |
|
131 | 139 |
|
132 | 140 |
$this->form->addSubmit('submit', 'Save'); |
133 | 141 |
|
... | ... | |
243 | 251 |
*/ |
244 | 252 |
private function getDefaults() |
245 | 253 |
{ |
246 |
$array = $this->transliterationRepository->findRow($this->transliterationId)->toArray(); |
|
247 |
$references = $this->litReferenceRepository->findByTransliterationId($this->transliterationId)->fetchAll(); |
|
254 |
if($this->transliterationId != null){ |
|
255 |
$array = $this->transliterationRepository->findRow($this->transliterationId)->toArray(); |
|
256 |
$references = $this->litReferenceRepository->findByTransliterationId($this->transliterationId)->fetchAll(); |
|
248 | 257 |
|
249 |
foreach ($references as $activeRow) |
|
250 |
{ |
|
251 |
$array['references'][] = $activeRow->toArray(); |
|
252 |
} |
|
258 |
foreach ($references as $activeRow)
|
|
259 |
{
|
|
260 |
$array['references'][] = $activeRow->toArray();
|
|
261 |
}
|
|
253 | 262 |
|
254 |
return $array; |
|
263 |
return $array; |
|
264 |
} |
|
255 | 265 |
} |
256 | 266 |
|
257 | 267 |
} |
app/AdminModule/component/Transliteration/TransliterationNewForm.latte | ||
---|---|---|
1 |
<div class="row"> |
|
2 |
<div class="col-12"> |
|
3 |
{control form} |
|
4 |
</div> |
|
5 |
</div> |
app/AdminModule/component/Transliteration/TransliterationNewForm.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
|
|
4 |
namespace App\AdminModule\Components; |
|
5 |
|
|
6 |
|
|
7 |
use Nette\Application\UI\Control; |
|
8 |
|
|
9 |
class TransliterationNewForm extends Control |
|
10 |
{ |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* TransliterationNewForm constructor. |
|
15 |
*/ |
|
16 |
public function __construct() |
|
17 |
{ |
|
18 |
parent::__construct(); |
|
19 |
} |
|
20 |
|
|
21 |
public function render() |
|
22 |
{ |
|
23 |
$this->template->setFile(__DIR__ . '/TransliterationNewForm.latte'); |
|
24 |
$this->template->render(); |
|
25 |
} |
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
interface ITransliterationNewFormFactory |
|
30 |
{ |
|
31 |
|
|
32 |
/** |
|
33 |
* @return TransliterationNewForm |
|
34 |
*/ |
|
35 |
public function create(); |
|
36 |
|
|
37 |
} |
app/AdminModule/presenters/TransliterationPresenter.php | ||
---|---|---|
4 | 4 |
namespace App\AdminModule\Presenters; |
5 | 5 |
|
6 | 6 |
|
7 |
use App\AdminModule\Components\IBookEditFormFactory; |
|
8 |
use App\AdminModule\Components\IBookOptionFormFactory; |
|
7 | 9 |
use App\AdminModule\Components\ITransliterationDataEditFormFactory; |
8 | 10 |
use App\AdminModule\Components\ITransliterationGridFactory; |
9 | 11 |
use App\AdminModule\Components\ITransliterationEditFormFactory; |
12 |
use App\AdminModule\Components\ITransliterationNewFormFactory; |
|
13 |
use App\FrontModule\Components\IKeyboard; |
|
10 | 14 |
use App\Model\Repository\TransliterationRepository; |
11 | 15 |
|
12 | 16 |
class TransliterationPresenter extends BaseUserPresenter |
... | ... | |
30 | 34 |
* @var ITransliterationDataEditFormFactory |
31 | 35 |
*/ |
32 | 36 |
private $transliterationDataEditFormFactory; |
37 |
/** |
|
38 |
* @var ITransliterationNewFormFactory |
|
39 |
*/ |
|
40 |
private $transliterationNewFormFactory; |
|
41 |
/** |
|
42 |
* @var IBookOptionFormFactory |
|
43 |
*/ |
|
44 |
private $bookOptionFormFactory; |
|
45 |
/** |
|
46 |
* @var IKeyboard |
|
47 |
*/ |
|
48 |
private $keyboard; |
|
33 | 49 |
|
34 | 50 |
public function __construct(ITransliterationGridFactory $transliterationGridFactory, |
35 | 51 |
ITransliterationEditFormFactory $transliterationEditFormFactory, |
36 | 52 |
TransliterationRepository $transliterationRepository, |
37 |
ITransliterationDataEditFormFactory $transliterationDataEditFormFactory |
|
53 |
ITransliterationDataEditFormFactory $transliterationDataEditFormFactory, |
|
54 |
ITransliterationNewFormFactory $transliterationNewFormFactory, |
|
55 |
IBookOptionFormFactory $bookOptionFormFactory, |
|
56 |
IKeyboard $keyboard |
|
38 | 57 |
) |
39 | 58 |
{ |
40 | 59 |
parent::__construct(); |
... | ... | |
42 | 61 |
$this->transliterationGridFactory = $transliterationGridFactory; |
43 | 62 |
$this->transliterationRepository = $transliterationRepository; |
44 | 63 |
$this->transliterationDataEditFormFactory = $transliterationDataEditFormFactory; |
64 |
$this->transliterationNewFormFactory = $transliterationNewFormFactory; |
|
65 |
$this->bookOptionFormFactory = $bookOptionFormFactory; |
|
66 |
$this->keyboard = $keyboard; |
|
45 | 67 |
} |
46 | 68 |
|
47 | 69 |
/** |
... | ... | |
84 | 106 |
return $this->transliterationDataEditFormFactory->create(); |
85 | 107 |
} |
86 | 108 |
|
109 |
public function createComponentTransliterationNewForm() |
|
110 |
{ |
|
111 |
return $this->transliterationNewFormFactory->create(); |
|
112 |
} |
|
113 |
|
|
114 |
public function createComponentBookOptionForm() |
|
115 |
{ |
|
116 |
return $this->bookOptionFormFactory->create(); |
|
117 |
} |
|
118 |
|
|
119 |
public function createComponentKeyboard() |
|
120 |
{ |
|
121 |
return $this->keyboard->create(); |
|
122 |
} |
|
123 |
|
|
87 | 124 |
} |
app/AdminModule/templates/Transliteration/new.latte | ||
---|---|---|
1 |
{block content} |
|
2 |
|
|
3 |
<div class="display-5">Enter New Transliteration</div> |
|
4 |
|
|
5 |
|
|
6 |
<div class="row mt-5"> |
|
7 |
<div class="col-5"> |
|
8 |
<fieldset> |
|
9 |
<legend>Book information</legend> |
|
10 |
|
|
11 |
{control bookOptionForm} |
|
12 |
</fieldset> |
|
13 |
</div> |
|
14 |
</div> |
|
15 |
|
|
16 |
<div class="row mt-5"> |
|
17 |
<div class="col-5"> |
|
18 |
<fieldset> |
|
19 |
<legend>Transliteration information</legend> |
|
20 |
|
|
21 |
{control transliterationEditForm} |
|
22 |
</fieldset> |
|
23 |
</div> |
|
24 |
</div> |
|
25 |
|
|
26 |
<div class="row mt-5"> |
|
27 |
<div class="col-5"> |
|
28 |
<fieldset> |
|
29 |
<legend>Transliteration data</legend> |
|
30 |
|
|
31 |
{control transliterationDataEditForm} |
|
32 |
</fieldset> |
|
33 |
</div> |
|
34 |
</div> |
|
35 |
|
|
36 |
<div class="row mt-5"> |
|
37 |
<div class="col-5"> |
|
38 |
{control keyboard} |
|
39 |
</div> |
|
40 |
</div> |
|
41 |
|
|
42 |
{/block} |
|
43 |
|
|
44 |
{block scripts} |
|
45 |
<script> |
|
46 |
$(function () { |
|
47 |
$.nette.init(); |
|
48 |
}); |
|
49 |
</script> |
app/config/components.neon | ||
---|---|---|
24 | 24 |
- App\AdminModule\Components\ITransliterationDataEditFormFactory |
25 | 25 |
- App\AdminModule\Components\IImportFormFactory |
26 | 26 |
- App\AdminModule\Components\IExportFormFactory |
27 |
- App\AdminModule\Components\ITransliterationNewFormFactory |
|
28 |
- App\AdminModule\Components\IBookOptionFormFactory |
|
29 |
|
|
30 |
|
|
27 | 31 |
|
28 | 32 |
- App\FrontModule\Components\IKeyboard |
29 | 33 |
- App\FrontModule\Components\ITransliterationSearchResultListFactory |
app/templates/@menu.latte | ||
---|---|---|
16 | 16 |
<a class="nav-link" href="#">Contact & members</a> |
17 | 17 |
</li> |
18 | 18 |
<li class="nav-item"> |
19 |
<a class="nav-link" href="#">Input new text</a>
|
|
19 |
<a class="nav-link" 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
Re #7507 vytvoření šablony pro vkládání nové iterace