Revize 1a669408
Přidáno uživatelem Petr Lukašík před téměř 6 roky(ů)
app/AdminModule/component/Transport/ExportForm.latte | ||
---|---|---|
1 |
<div class="row"> |
|
2 |
<div class="col-4"> |
|
3 |
{control form} |
|
4 |
</div> |
|
5 |
</div> |
app/AdminModule/component/Transport/ExportForm.php | ||
---|---|---|
1 |
<?php |
|
2 | ||
3 |
namespace App\AdminModule\Components; |
|
4 | ||
5 |
use App\Utils\Form; |
|
6 |
use Nette\Application\UI\Control; |
|
7 | ||
8 |
class ExportForm extends Control |
|
9 |
{ |
|
10 | ||
11 |
public function __construct() |
|
12 |
{ |
|
13 |
parent::__construct(); |
|
14 |
} |
|
15 | ||
16 | ||
17 |
public function render() |
|
18 |
{ |
|
19 |
$this->template->setFile(__DIR__ . '/ExportForm.latte'); |
|
20 |
$this->template->render(); |
|
21 |
} |
|
22 | ||
23 |
public function createComponentForm() |
|
24 |
{ |
|
25 |
$form = new Form(); |
|
26 | ||
27 |
$form->addButton('export', 'Export něco...'); |
|
28 | ||
29 |
return $form; |
|
30 |
} |
|
31 |
} |
|
32 | ||
33 |
interface IExportFormFactory |
|
34 |
{ |
|
35 |
/** |
|
36 |
* @return ExportForm |
|
37 |
*/ |
|
38 |
public function create(); |
|
39 |
} |
app/AdminModule/component/Transport/ImportForm.latte | ||
---|---|---|
1 |
<div class="row"> |
|
2 |
<div class="col-4"> |
|
3 |
{control form} |
|
4 |
</div> |
|
5 |
</div> |
app/AdminModule/component/Transport/ImportForm.php | ||
---|---|---|
1 |
<?php |
|
2 | ||
3 |
namespace App\AdminModule\Components; |
|
4 | ||
5 |
use App\Utils\Form; |
|
6 |
use Nette\Application\UI\Control; |
|
7 |
use Nette\Utils\ArrayHash; |
|
8 | ||
9 |
class ImportForm extends Control |
|
10 |
{ |
|
11 |
public function __construct() |
|
12 |
{ |
|
13 |
parent::__construct(); |
|
14 |
} |
|
15 | ||
16 | ||
17 |
public function render() |
|
18 |
{ |
|
19 |
$this->template->setFile(__DIR__ . '/ImportForm.latte'); |
|
20 |
$this->template->render(); |
|
21 |
} |
|
22 | ||
23 |
public function createComponentForm() |
|
24 |
{ |
|
25 |
$form = new Form(); |
|
26 | ||
27 |
$form->addUpload('import', 'File')->addRule(Form::REQUIRED, 'Field %label is required.'); |
|
28 | ||
29 |
$form->addSubmit('submit', 'Import file'); |
|
30 |
$form->onSuccess[] = [$this, 'formSuccess']; |
|
31 | ||
32 |
return $form; |
|
33 |
} |
|
34 | ||
35 |
public function formSuccess(Form $form) |
|
36 |
{ |
|
37 |
/** @var ArrayHash $values */ |
|
38 |
$values = $form->getValues(); |
|
39 |
$this->transliterationSearchModel->setSearchTerms($values); |
|
40 |
$this->presenter->redirect('Transliteration:searchResult'); |
|
41 |
} |
|
42 |
} |
|
43 | ||
44 |
interface IImportFormFactory |
|
45 |
{ |
|
46 |
/** |
|
47 |
* @return ImportForm |
|
48 |
*/ |
|
49 |
public function create(); |
|
50 |
} |
app/AdminModule/presenters/TransportPresenter.php | ||
---|---|---|
1 |
<?php |
|
2 | ||
3 |
namespace App\AdminModule\Presenters; |
|
4 | ||
5 |
use App\AdminModule\Components\IExportFormFactory; |
|
6 |
use App\AdminModule\Components\IImportFormFactory; |
|
7 | ||
8 |
class TransportPresenter extends BaseUserPresenter |
|
9 |
{ |
|
10 |
/** @var IImportFormFactory */ |
|
11 |
private $importFormFactory; |
|
12 | ||
13 |
/** @var IExportFormFactory */ |
|
14 |
private $exportFormFactory; |
|
15 | ||
16 |
public function __construct( |
|
17 |
IImportFormFactory $importFormFactory, |
|
18 |
IExportFormFactory $exportFormFactory |
|
19 |
) |
|
20 |
{ |
|
21 |
parent::__construct(); |
|
22 |
$this->importFormFactory = $importFormFactory; |
|
23 |
$this->exportFormFactory = $exportFormFactory; |
|
24 |
} |
|
25 | ||
26 |
public function createComponentImportForm() |
|
27 |
{ |
|
28 |
return $this->importFormFactory->create(); |
|
29 |
} |
|
30 | ||
31 |
public function createComponentExportForm() |
|
32 |
{ |
|
33 |
return $this->exportFormFactory->create(); |
|
34 |
} |
|
35 |
} |
app/AdminModule/templates/@adminMenu.latte | ||
---|---|---|
17 | 17 |
Museum </a></li> |
18 | 18 |
<li class="nav-item"><a n:href="Origin:default" n:class="nav-link, $presenter->isLinkCurrent('Origin:*') ? active" title="Origin"> |
19 | 19 |
Origin </a></li> |
20 |
<li class="nav-item"><a href="#" class="nav-link" title="Upload">
|
|
21 |
Upload texts </a></li>
|
|
20 |
<li class="nav-item"><a n:href="Transport:default" n:class="nav-link, $presenter->isLinkCurrent('Transport:*') ? active" title="Transport">
|
|
21 |
Import/export texts </a></li>
|
|
22 | 22 |
<li class="nav-item"><a href="#" class="nav-link" title="Replace"> |
23 |
Mass replace </a></li>
|
|
23 |
Mass replace </a></li>
|
|
24 | 24 |
</ul> |
app/AdminModule/templates/Transport/default.latte | ||
---|---|---|
1 |
{block content} |
|
2 |
<div class="row col-12"> |
|
3 |
<div class="display-5">Import text</div> |
|
4 |
</div> |
|
5 | ||
6 |
{control importForm} |
|
7 | ||
8 |
<div class="row col-12" style="margin-top: 5%"> |
|
9 |
<div class="display-5">Export text</div> |
|
10 |
</div> |
|
11 | ||
12 |
{control exportForm} |
|
13 |
{/block} |
app/config/components.neon | ||
---|---|---|
22 | 22 |
- App\AdminModule\Components\IBookEditFormFactory |
23 | 23 |
- App\AdminModule\Components\ITransliterationEditFormFactory |
24 | 24 |
- App\AdminModule\Components\ITransliterationDataEditFormFactory |
25 |
- App\AdminModule\Components\IImportFormFactory |
|
26 |
- App\AdminModule\Components\IExportFormFactory |
|
25 | 27 | |
26 | 28 |
- App\FrontModule\Components\IKeyboard |
27 | 29 |
- App\FrontModule\Components\ITransliterationSearchResultListFactory |
Také k dispozici: Unified diff
Re #7510 Vytvořeny komponenty, presenter a layout