|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Quick create view modal file. |
|
4
|
|
|
* |
|
5
|
|
|
* @package View |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright YetiForce Sp. z o.o. |
|
8
|
|
|
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) |
|
9
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace YF\Modules\Base\View; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Quick create view modal class. |
|
16
|
|
|
*/ |
|
17
|
|
|
class QuickCreateModal extends \App\Controller\Modal |
|
18
|
|
|
{ |
|
19
|
|
|
/** {@inheritdoc} */ |
|
20
|
|
|
public $showFooter = false; |
|
21
|
|
|
|
|
22
|
|
|
/** {@inheritdoc} */ |
|
23
|
|
|
public function checkPermission(): void |
|
24
|
|
|
{ |
|
25
|
|
|
parent::checkPermission(); |
|
26
|
|
|
if (!\YF\Modules\Base\Model\Module::isPermittedByModule($this->request->getModule(), 'CreateView')) { |
|
27
|
|
|
throw new \App\Exceptions\AppException('ERR_MODULE_PERMISSION_DENIED'); |
|
28
|
|
|
} |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** {@inheritdoc} */ |
|
32
|
|
|
protected function getTitle() |
|
33
|
|
|
{ |
|
34
|
|
|
return \App\Language::translate('LBL_VIEW_QUICK_CREATE', $this->request->getModule()) . ' - ' . \App\Language::translateModule($this->request->getModule()); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** {@inheritdoc} */ |
|
38
|
|
|
protected function getModalSize() |
|
39
|
|
|
{ |
|
40
|
|
|
return 'c-modal-xxl'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** {@inheritdoc} */ |
|
44
|
|
|
protected function getModalIcon(): string |
|
45
|
|
|
{ |
|
46
|
|
|
return 'yfm-' . $this->request->getModule(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** {@inheritdoc} */ |
|
50
|
|
|
public function process() |
|
51
|
|
|
{ |
|
52
|
|
|
$moduleName = $this->request->getModule(); |
|
53
|
|
|
$recordModel = \YF\Modules\Base\Model\Record::getInstance($moduleName); |
|
54
|
|
|
$moduleModel = $recordModel->getModuleModel(); |
|
55
|
|
|
$this->viewer->assign('RECORD', $recordModel); |
|
56
|
|
|
$this->viewer->assign('FIELDS', $moduleModel->getFieldsModels()); |
|
57
|
|
|
$this->viewer->assign('FIELDS_FORM', $moduleModel->getFormFields()); |
|
58
|
|
|
$this->viewer->assign('BLOCKS', $moduleModel->getBlocks()); |
|
59
|
|
|
$this->viewer->view($this->processTplName(), $moduleName); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** {@inheritdoc} */ |
|
63
|
|
|
public function processTplName(): string |
|
64
|
|
|
{ |
|
65
|
|
|
return 'Modal/QuickCreate.tpl'; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** {@inheritdoc} */ |
|
69
|
|
|
public function getModalJs(bool $loadForModule = true): array |
|
70
|
|
|
{ |
|
71
|
|
|
$moduleName = $this->getModuleNameFromRequest(); |
|
72
|
|
|
$action = $this->request->getAction(); |
|
73
|
|
|
$files = [ |
|
74
|
|
|
['layouts/' . \App\Viewer::getLayoutName() . '/modules/Base/resources/EditView.js'], |
|
75
|
|
|
['layouts/' . \App\Viewer::getLayoutName() . "/modules/Base/resources/{$action}.js", true], |
|
76
|
|
|
]; |
|
77
|
|
|
if ($loadForModule) { |
|
78
|
|
|
$files[] = ['layouts/' . \App\Viewer::getLayoutName() . '/modules/' . $this->getModuleNameFromRequest() . '/resources/EditView.js', true]; |
|
79
|
|
|
$files[] = ['layouts/' . \App\Viewer::getLayoutName() . "/modules/{$moduleName}/resources/{$action}.js", true]; |
|
80
|
|
|
} |
|
81
|
|
|
return $this->convertScripts($files, 'js'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|