Skip to content

Commit

Permalink
Oprava nefunkční administrace po přejmenování stránky (#769)
Browse files Browse the repository at this point in the history
* oprava nefunkční administrace po přejmenování stránky

* coding standard

* coding standard
  • Loading branch information
jan-stanek authored Nov 21, 2020
1 parent 8d72799 commit 9649722
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/AdminModule/ConfigurationModule/Forms/WebFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Nextras\FormsRendering\Renderers\Bs3FormRenderer;
use stdClass;
use Throwable;
use function array_key_exists;
use const UPLOAD_ERR_OK;

/**
Expand Down Expand Up @@ -71,7 +72,10 @@ public function create() : Form

$form->addText('footer', 'admin.configuration.web_footer');

$form->addSelect('redirectAfterLogin', 'admin.configuration.web_redirect_after_login', $this->pageRepository->getPagesOptions())
$redirectAfterLoginOptions = $this->pageRepository->getPagesOptions();
$redirectAfterLoginValue = $this->settingsService->getValue(Settings::REDIRECT_AFTER_LOGIN);

$form->addSelect('redirectAfterLogin', 'admin.configuration.web_redirect_after_login', $redirectAfterLoginOptions)
->addRule(Form::FILLED, 'admin.configuration.web_redirect_after_login_empty');

$form->addText('ga_id', 'admin.configuration.web_ga_id');
Expand All @@ -80,7 +84,7 @@ public function create() : Form

$form->setDefaults([
'footer' => $this->settingsService->getValue(Settings::FOOTER),
'redirectAfterLogin' => $this->settingsService->getValue(Settings::REDIRECT_AFTER_LOGIN),
'redirectAfterLogin' => array_key_exists($redirectAfterLoginValue, $redirectAfterLoginOptions) ? $redirectAfterLoginValue : null,
'ga_id' => $this->settingsService->getValue(Settings::GA_ID),
]);

Expand Down
5 changes: 4 additions & 1 deletion app/AdminModule/Forms/EditRoleFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Nextras\FormComponents\Controls\DateTimeControl;
use stdClass;
use Throwable;
use function array_key_exists;
use function in_array;

/**
Expand Down Expand Up @@ -178,6 +179,8 @@ public function create(int $id) : Form
->setValidationScope([])
->setHtmlAttribute('class', 'btn btn-warning');

$redirectAfterLoginValue = $this->role->getRedirectAfterLogin();

$form->setDefaults([
'id' => $id,
'name' => $this->role->getName(),
Expand All @@ -192,7 +195,7 @@ public function create(int $id) : Form
'minimumAge' => $this->role->getMinimumAge(),
'permissions' => $this->permissionRepository->findPermissionsIds($this->role->getPermissions()),
'pages' => $this->pageRepository->findPagesSlugs($this->role->getPages()),
'redirectAfterLogin' => $this->role->getRedirectAfterLogin(),
'redirectAfterLogin' => array_key_exists($redirectAfterLoginValue, $pagesOptions) ? $redirectAfterLoginValue : null,
'incompatibleRoles' => $this->roleRepository->findRolesIds($this->role->getIncompatibleRoles()),
'requiredRoles' => $this->roleRepository->findRolesIds($this->role->getRequiredRoles()),
]);
Expand Down

0 comments on commit 9649722

Please sign in to comment.