-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c5fb20
commit 8d50bfd
Showing
7 changed files
with
248 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the package magicsunday/webtrees-descendants-chart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; | ||
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesAllPage; | ||
use Fisharebest\Webtrees\I18N; | ||
use MagicSunday\Webtrees\DescendantsChart\Configuration; | ||
|
||
/** | ||
* @var Configuration $configuration | ||
* @var string $moduleName | ||
* @var string $title | ||
* @var string $description | ||
*/ | ||
?> | ||
|
||
<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ModulesAllPage::class) => I18N::translate('Modules'), $title]]) ?> | ||
|
||
<h1><?= $title ?></h1> | ||
<p><?= $description ?></p> | ||
|
||
<form method="post"> | ||
<div class="mb-3"> | ||
<?= view($moduleName.'::modules/descendants-chart/form/generations', ['configuration' => $configuration]) ?> | ||
</div> | ||
<div class="mb-3"> | ||
<?= view($moduleName.'::modules/descendants-chart/form/orientation', ['configuration' => $configuration]) ?> | ||
</div> | ||
|
||
<div class="row mb-3"> | ||
<div class="offset-sm-3 col-sm-9"> | ||
<button type="submit" class="btn btn-primary"> | ||
<?= I18N::translate('save') ?> | ||
</button> | ||
|
||
<a href="<?= route(ControlPanel::class) ?>" class="btn btn-secondary"> | ||
<?= view('icons/cancel') ?> | ||
<?= I18N::translate('cancel') ?> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<?= csrf_field() ?> | ||
</form> |
35 changes: 35 additions & 0 deletions
35
resources/views/modules/descendants-chart/form/generations.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the package magicsunday/webtrees-descendants-chart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use MagicSunday\Webtrees\DescendantsChart\Configuration; | ||
|
||
/** | ||
* @var Configuration $configuration | ||
*/ | ||
?> | ||
|
||
<div class="form-group row"> | ||
<label class="col-sm-3 col-form-label wt-page-options-label" for="generations"> | ||
<?= I18N::translate('Generations') ?> | ||
</label> | ||
<div class="col-sm-9 wt-page-options-value"> | ||
<?= | ||
view('components/select', [ | ||
'id' => 'generations', | ||
'name' => 'generations', | ||
'selected' => $configuration->getGenerations(), | ||
'options' => $configuration->getGenerationsList(), | ||
'class' => 'form-control-sm', | ||
]) | ||
?> | ||
</div> | ||
</div> |
33 changes: 33 additions & 0 deletions
33
resources/views/modules/descendants-chart/form/orientation.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the package magicsunday/webtrees-descendants-chart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Fisharebest\Webtrees\I18N; | ||
use MagicSunday\Webtrees\DescendantsChart\Configuration; | ||
|
||
/** | ||
* @var Configuration $configuration | ||
*/ | ||
?> | ||
|
||
<div class="form-group row"> | ||
<label class="col-form-label col-sm-3 wt-page-options-label"> | ||
<?= I18N::translate('Orientation') ?> | ||
</label> | ||
<div class="col-sm-9 wt-page-options-value" id="layout"> | ||
<?= | ||
view('components/radios-inline', [ | ||
'name' => 'layout', | ||
'options' => $configuration->getLayouts(), | ||
'selected' => $configuration->getLayout(), | ||
]) | ||
?> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the package magicsunday/webtrees-descendants-chart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MagicSunday\Webtrees\DescendantsChart\Traits; | ||
|
||
use Fisharebest\Webtrees\FlashMessages; | ||
use Fisharebest\Webtrees\I18N; | ||
use MagicSunday\Webtrees\DescendantsChart\Configuration; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
/** | ||
* Trait ModuleConfigTrait. | ||
* | ||
* @author Rico Sonntag <mail@ricosonntag.de> | ||
* @license https://opensource.org/licenses/GPL-3.0 GNU General Public License v3.0 | ||
* @link https://github.com/magicsunday/webtrees-descendants-chart/ | ||
*/ | ||
trait ModuleConfigTrait | ||
{ | ||
use \Fisharebest\Webtrees\Module\ModuleConfigTrait; | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* | ||
* @return ResponseInterface | ||
*/ | ||
public function getAdminAction(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$this->layout = 'layouts/administration'; | ||
|
||
return $this->viewResponse( | ||
$this->name() . '::modules/descendants-chart/config', | ||
[ | ||
'configuration' => new Configuration($request, $this), | ||
'moduleName' => $this->name(), | ||
'title' => $this->title(), | ||
'description' => $this->description(), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* | ||
* @return ResponseInterface | ||
*/ | ||
public function postAdminAction(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$configuration = new Configuration($request, $this); | ||
|
||
$this->setPreference('default_generations', (string) $configuration->getGenerations()); | ||
$this->setPreference('default_tree_layout', $configuration->getLayout()); | ||
|
||
FlashMessages::addMessage( | ||
I18N::translate( | ||
'The preferences for the module “%s” have been updated.', | ||
$this->title() | ||
), | ||
'success' | ||
); | ||
|
||
return redirect($this->getConfigLink()); | ||
} | ||
} |