10
10
use App \Services \FilesService ;
11
11
use App \Utils \Helpers ;
12
12
use DateTimeImmutable ;
13
- use Doctrine \ORM \ORMException ;
14
13
use Nette \Application \AbortException ;
15
14
use Nette \Application \UI \Control ;
16
15
use Nette \Application \UI \Form ;
17
16
use Nette \Forms \Container ;
18
17
use Nette \Http \FileUpload ;
19
- use Nette \Localization \ITranslator ;
18
+ use Nette \Localization \Translator ;
20
19
use Nette \Utils \Html ;
21
20
use stdClass ;
22
21
use Ublaboo \DataGrid \DataGrid ;
32
31
*/
33
32
class DocumentsGridControl extends Control
34
33
{
35
- private ITranslator $ translator ;
34
+ private Translator $ translator ;
36
35
37
36
private DocumentRepository $ documentRepository ;
38
37
@@ -41,7 +40,7 @@ class DocumentsGridControl extends Control
41
40
private TagRepository $ tagRepository ;
42
41
43
42
public function __construct (
44
- ITranslator $ translator ,
43
+ Translator $ translator ,
45
44
DocumentRepository $ documentRepository ,
46
45
TagRepository $ tagRepository ,
47
46
FilesService $ filesService
@@ -95,7 +94,7 @@ public function createComponentDocumentsGrid(string $name): void
95
94
->setAttribute ('href ' , $ document ->getFile ())
96
95
->setAttribute ('target ' , '_blank ' )
97
96
->setAttribute ('class ' , 'btn btn-xs btn-secondary ' )
98
- ->addHtml (Html::el ('span ' )->setAttribute ('class ' , 'fa fa-download ' ))
97
+ ->addHtml (Html::el ('span ' )->setAttribute ('class ' , 'fa fa-file-arrow-down ' ))
99
98
->addText (' ' . basename ($ document ->getFile ()));
100
99
});
101
100
@@ -152,9 +151,6 @@ public function createComponentDocumentsGrid(string $name): void
152
151
153
152
/**
154
153
* Zpracuje přidání dokumentu.
155
- *
156
- * @throws ORMException
157
- * @throws AbortException
158
154
*/
159
155
public function add (stdClass $ values ): void
160
156
{
@@ -172,15 +168,11 @@ public function add(stdClass $values): void
172
168
$ this ->documentRepository ->save ($ document );
173
169
174
170
$ this ->getPresenter ()->flashMessage ('admin.cms.documents.message.save_success ' , 'success ' );
175
-
176
- $ this ->redirect ('this ' );
171
+ $ this ->getPresenter ()->redrawControl ('flashes ' );
177
172
}
178
173
179
174
/**
180
175
* Zpracuje úpravu dokumentu.
181
- *
182
- * @throws ORMException
183
- * @throws AbortException
184
176
*/
185
177
public function edit (string $ id , stdClass $ values ): void
186
178
{
@@ -202,14 +194,12 @@ public function edit(string $id, stdClass $values): void
202
194
$ this ->documentRepository ->save ($ document );
203
195
204
196
$ this ->getPresenter ()->flashMessage ('admin.cms.documents.message.save_success ' , 'success ' );
205
-
206
- $ this ->redirect ('this ' );
197
+ $ this ->getPresenter ()->redrawControl ('flashes ' );
207
198
}
208
199
209
200
/**
210
201
* Zpracuje odstranění dokumentu.
211
202
*
212
- * @throws ORMException
213
203
* @throws AbortException
214
204
*/
215
205
public function handleDelete (int $ id ): void
@@ -218,8 +208,8 @@ public function handleDelete(int $id): void
218
208
$ this ->filesService ->delete ($ document ->getFile ());
219
209
$ this ->documentRepository ->remove ($ document );
220
210
221
- $ this ->getPresenter ()-> flashMessage ( ' admin.cms.documents.message.delete_success ' , ' success ' );
222
-
223
- $ this ->redirect ('this ' );
211
+ $ p = $ this ->getPresenter ();
212
+ $ p -> flashMessage ( ' admin.cms.documents.message.delete_success ' , ' success ' );
213
+ $ p ->redirect ('this ' );
224
214
}
225
215
}
0 commit comments