This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: LTA Admin Functionality (#194)
- Loading branch information
Showing
11 changed files
with
496 additions
and
194 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,51 @@ | ||
<?php | ||
|
||
namespace Admin\Controller; | ||
|
||
use Admin\Data\Mapper\LocalAuthority as LocalAuthorityMapper; | ||
use Admin\Form\Model\Form\LocalAuthority as LocalAuthorityForm; | ||
use Dvsa\Olcs\Transfer\Command\LocalAuthority\Update as UpdateDto; | ||
use Dvsa\Olcs\Transfer\Query\LocalAuthority\ById as ItemDto; | ||
use Dvsa\Olcs\Transfer\Query\LocalAuthority\LocalAuthorityList as ListDto; | ||
use Laminas\View\Model\ViewModel; | ||
use Olcs\Controller\AbstractInternalController; | ||
use Olcs\Controller\Interfaces\LeftViewProvider; | ||
|
||
class LocalAuthorityController extends AbstractInternalController implements LeftViewProvider | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $inlineScripts = [ | ||
'indexAction' => ['table-actions'], | ||
]; | ||
|
||
// list | ||
protected $tableName = 'admin-local-authority'; | ||
protected $defaultTableSortField = 'id'; | ||
protected $defaultTableOrderField = 'ASC'; | ||
protected $listDto = ListDto::class; | ||
|
||
// add/edit | ||
protected $itemDto = ItemDto::class; | ||
protected $formClass = LocalAuthorityForm::class; | ||
protected $mapperClass = LocalAuthorityMapper::class; | ||
protected $updateCommand = UpdateDto::class; | ||
|
||
protected $editContentTitle = 'Edit Local Authority'; | ||
|
||
protected $tableViewTemplate = 'pages/local-authority/index'; | ||
|
||
public function getLeftView() | ||
{ | ||
$view = new ViewModel( | ||
[ | ||
'navigationId' => 'admin-dashboard/admin-bus-registration/notice-period', | ||
'navigationTitle' => 'Local Authorities (LTA)' | ||
] | ||
); | ||
$view->setTemplate('admin/sections/admin/partials/generic-left'); | ||
|
||
return $view; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
module/Admin/src/Controller/LocalAuthorityControllerFactory.php
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 | ||
|
||
namespace Admin\Controller; | ||
|
||
use Common\Service\Helper\FlashMessengerHelperService; | ||
use Common\Service\Helper\FormHelperService; | ||
use Common\Service\Helper\TranslationHelperService; | ||
use Laminas\Navigation\Navigation; | ||
use Laminas\ServiceManager\Factory\FactoryInterface; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class LocalAuthorityControllerFactory implements FactoryInterface | ||
{ | ||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): LocalAuthorityController | ||
{ | ||
$translationHelper = $container->get(TranslationHelperService::class); | ||
assert($translationHelper instanceof TranslationHelperService); | ||
|
||
$formHelperService = $container->get(FormHelperService::class); | ||
assert($formHelperService instanceof FormHelperService); | ||
|
||
$flashMessenger = $container->get(FlashMessengerHelperService::class); | ||
assert($flashMessenger instanceof FlashMessengerHelperService); | ||
|
||
$navigation = $container->get('navigation'); | ||
assert($navigation instanceof Navigation); | ||
|
||
return new LocalAuthorityController( | ||
$translationHelper, | ||
$formHelperService, | ||
$flashMessenger, | ||
$navigation | ||
); | ||
} | ||
} |
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 | ||
|
||
namespace Admin\Data\Mapper; | ||
|
||
use Common\Data\Mapper\MapperInterface; | ||
use Laminas\Form\FormInterface; | ||
|
||
/** | ||
* Local Authority mapper | ||
* | ||
* @package Admin\Data\Mapper | ||
*/ | ||
class LocalAuthority implements MapperInterface | ||
{ | ||
/** | ||
* Should map data from a result array into an array suitable for a form | ||
* | ||
* @param array $data Data from command | ||
* | ||
* @return array | ||
*/ | ||
public static function mapFromResult(array $data): array | ||
{ | ||
return ['localAuthorityDetails' => $data]; | ||
} | ||
|
||
/** | ||
* Should map form data back into a command data structure | ||
* | ||
* @param array $data Data from form | ||
* | ||
* @return array | ||
*/ | ||
public static function mapFromForm(array $data): array | ||
{ | ||
return $data['localAuthorityDetails']; | ||
} | ||
|
||
/** | ||
* Should map errors onto the form, any global errors should be returned so they can be added | ||
* to the flash messenger | ||
* | ||
* @param FormInterface $form Form interface | ||
* @param array $errors array response from errors | ||
* | ||
* @return array | ||
*/ | ||
public static function mapFromErrors(FormInterface $form, array $errors): array | ||
{ | ||
return $errors; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
module/Admin/src/Form/Model/Fieldset/LocalAuthorityDetails.php
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,50 @@ | ||
<?php | ||
|
||
namespace Admin\Form\Model\Fieldset; | ||
|
||
use Common\Form\Model\Form\Traits\IdTrait; | ||
use Laminas\Form\Annotation as Form; | ||
|
||
/** | ||
* @codeCoverageIgnore No methods | ||
*/ | ||
class LocalAuthorityDetails | ||
{ | ||
use IdTrait; | ||
|
||
/** | ||
* @Form\Attributes({"id":"naptanCode", "readonly":"true", "disabled":"disabled"}) | ||
* @Form\Options({ | ||
* "label": "NAPTAN Code (Ready only)", | ||
* }) | ||
*/ | ||
public $naptanCode = null; | ||
|
||
/** | ||
* @Form\Attributes({"id":"txcName", "readonly":"true", "disabled":"disabled"}) | ||
* @Form\Options({ | ||
* "label": "TXC Name (Ready only)", | ||
* }) | ||
*/ | ||
public $txcName = null; | ||
|
||
/** | ||
* @Form\Required(true) | ||
* @Form\Attributes({"id":"emailAddress","placeholder":"","class":"medium", "required":false}) | ||
* @Form\Options({"label":"Email Address"}) | ||
* @Form\Type("Text") | ||
* @Form\Filter("Laminas\Filter\StringTrim") | ||
* @Form\Validator("Dvsa\Olcs\Transfer\Validators\EmailAddress") | ||
*/ | ||
public $emailAddress = null; | ||
|
||
/** | ||
* @Form\Attributes({"placeholder":"","class":"medium"}) | ||
* @Form\Options({"label":"LTA Descriptive Name"}) | ||
* @Form\Type("Text") | ||
* @Form\Required(true) | ||
* @Form\Filter({"name":"Laminas\Filter\StringTrim"}) | ||
* @Form\Validator("Laminas\Validator\StringLength", options={"max":255}) | ||
*/ | ||
public $description = null; | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Admin\Form\Model\Form; | ||
|
||
use Olcs\Form\Model\Fieldset\Base; | ||
use Laminas\Form\Annotation as Form; | ||
|
||
/** | ||
* @Form\Name("LocalAuthority") | ||
* @Form\Attributes({"method":"post"}) | ||
* @Form\Type("Common\Form\Form") | ||
* @Form\Options({"prefer_form_input_filter": true}) | ||
*/ | ||
class LocalAuthority extends Base | ||
{ | ||
/** | ||
* @Form\Name("localAuthorityDetails") | ||
* @Form\ComposedObject("Admin\Form\Model\Fieldset\LocalAuthorityDetails") | ||
*/ | ||
public $localAuthorityDetails = null; | ||
|
||
/** | ||
* @Form\Name("form-actions") | ||
* @Form\Attributes({"class":"govuk-button-group"}) | ||
* @Form\ComposedObject("Olcs\Form\Model\Fieldset\OkCancelFormActions") | ||
*/ | ||
public $formActions = null; | ||
} |
55 changes: 55 additions & 0 deletions
55
module/Admin/src/Table/Tables/admin-local-authority.table.php
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,55 @@ | ||
<?php | ||
|
||
return [ | ||
'variables' => [ | ||
'titleSingular' => 'Local Authority', | ||
'title' => 'Local Authorities' | ||
], | ||
'settings' => [ | ||
'crud' => [ | ||
'actions' => [ | ||
'edit' => ['requireRows' => true, 'class' => 'govuk-button govuk-button--secondary js-require--one'] | ||
] | ||
], | ||
'paginate' => [ | ||
'limit' => [ | ||
'default' => 25, | ||
'options' => [10, 25, 50] | ||
], | ||
] | ||
], | ||
'attributes' => [ | ||
], | ||
'columns' => [ | ||
[ | ||
'title' => 'ID', | ||
'name' => 'id', | ||
], | ||
[ | ||
'title' => 'Description', | ||
'name' => 'description', | ||
], | ||
[ | ||
'title' => 'Email Address', | ||
'name' => 'emailAddress', | ||
], | ||
[ | ||
'title' => 'TransXchange Name', | ||
'name' => 'txcName', | ||
], | ||
[ | ||
'title' => 'NAPTAN Code', | ||
'name' => 'naptanCode', | ||
], | ||
[ | ||
'title' => 'Traffic Area', | ||
'name' => 'trafficArea', | ||
'formatter' => fn($row) => $row['trafficArea']['name'] | ||
], | ||
[ | ||
'title' => 'markup-table-th-action', | ||
'width' => 'checkbox', | ||
'format' => '{{[elements/radio]}}' | ||
], | ||
] | ||
]; |
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,7 @@ | ||
<?php | ||
echo $this->render('pages/table'); | ||
?> | ||
<div class="govuk-inset-text"> | ||
<p>Only name changes and notification email changes can be actioned via this Interface</p> | ||
<p>Additions, deletions, merges, and changes to any other fields must be raised with the VOL CI Product Owner, to be actioned by the developers</p> | ||
</div> |