Skip to content

Commit

Permalink
fix: VOL-5226 irfo gv permits now locked down for read only users (dv…
Browse files Browse the repository at this point in the history
  • Loading branch information
ilindsay authored May 9, 2024
1 parent 1309aba commit ae1f14b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Olcs\Controller\Operator;

use Common\Rbac\Service\Permission;
use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Helper\FormHelperService;
use Common\Service\Helper\TranslationHelperService;
use Dvsa\Olcs\Transfer\Command\Irfo\ApproveIrfoGvPermit as ApproveDto;
use Dvsa\Olcs\Transfer\Command\Irfo\CreateIrfoGvPermit as CreateDto;
use Dvsa\Olcs\Transfer\Command\Irfo\GenerateIrfoGvPermit as GenerateDto;
Expand All @@ -10,6 +14,7 @@
use Dvsa\Olcs\Transfer\Command\Irfo\WithdrawIrfoGvPermit as WithdrawDto;
use Dvsa\Olcs\Transfer\Query\Irfo\IrfoGvPermit as ItemDto;
use Dvsa\Olcs\Transfer\Query\Irfo\IrfoGvPermitList as ListDto;
use Laminas\Navigation\Navigation;
use Laminas\View\Model\ViewModel;
use Olcs\Controller\AbstractInternalController;
use Olcs\Controller\Interfaces\LeftViewProvider;
Expand Down Expand Up @@ -47,6 +52,19 @@ class OperatorIrfoGvPermitsController extends AbstractInternalController impleme
protected $tableName = 'operator.irfo.gv-permits';
protected $listDto = ListDto::class;
protected $listVars = ['organisation'];
private Permission $permissionService;


public function __construct(
TranslationHelperService $translationHelperService,
FormHelperService $formHelperService,
FlashMessengerHelperService $flashMessengerHelperService,
Navigation $navigation,
Permission $permissionService
) {
$this->permissionService = $permissionService;
parent::__construct($translationHelperService, $formHelperService, $flashMessengerHelperService, $navigation);
}

/**
* get Method leftView
Expand Down Expand Up @@ -99,6 +117,12 @@ public function getLeftView()
'irfoPermitStatus' => 'irfo_perm_s_pending'
];

public function detailsAction()
{
$this->placeholder()->setPlaceholder('isInternalReadOnly', $this->permissionService->isInternalReadOnly());
return parent::detailsAction();
}

/**
* not found action
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Olcs\Controller\Operator;

use Common\Rbac\Service\Permission;
use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Helper\FormHelperService;
use Common\Service\Helper\TranslationHelperService;
Expand All @@ -25,11 +26,14 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$navigation = $container->get('navigation');
assert($navigation instanceof Navigation);

$permissionService = $container->get(Permission::class);

return new OperatorIrfoGvPermitsController(
$translationHelper,
$formHelper,
$flashMessenger,
$navigation
$navigation,
$permissionService
);
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
<?php
$entity = $this->placeholder('details')->getValue();
$isInternalReadOnly = $this->placeholder('isInternalReadOnly')->getValue();

$actions = [];
if ($entity['isApprovable']) {
$actions[] = [
'url' => $this->url(null, ['action' => 'approve'], [], true),
'label' => 'Approve',
'class' => 'govuk-button'
];
}
if ($entity['isGeneratable']) {
$actions[] = [
'url' => $this->url(null, ['action' => 'generate'], [], true),
'label' => 'Generate',
'class' => 'govuk-button'
];
}
if ($entity['irfoPermitStatus']['id'] === 'irfo_perm_s_pending') {
$actions[] = [
'url' => $this->url(null, ['action' => 'withdraw'], [], true),
'label' => 'Withdraw',
'class' => 'govuk-button govuk-button--secondary'
];
$actions[] = [
'url' => $this->url(null, ['action' => 'refuse'], [], true),
'label' => 'Refuse',
'class' => 'govuk-button govuk-button--secondary'
];
} else {
$actions[] = [
'url' => $this->url(null, ['action' => 'reset'], [], true),
'label' => 'Reset',
'class' => 'govuk-button govuk-button--secondary'
];

if (!$isInternalReadOnly) {
if ($entity['isApprovable']) {
$actions[] = [
'url' => $this->url(null, ['action' => 'approve'], [], true),
'label' => 'Approve',
'class' => 'govuk-button',
];
}
if ($entity['isGeneratable']) {
$actions[] = [
'url' => $this->url(null, ['action' => 'generate'], [], true),
'label' => 'Generate',
'class' => 'govuk-button',
];
}
if ($entity['irfoPermitStatus']['id'] === 'irfo_perm_s_pending') {
$actions[] = [
'url' => $this->url(null, ['action' => 'withdraw'], [], true),
'label' => 'Withdraw',
'class' => 'govuk-button govuk-button--secondary',
];
$actions[] = [
'url' => $this->url(null, ['action' => 'refuse'], [], true),
'label' => 'Refuse',
'class' => 'govuk-button govuk-button--secondary',
];
} else {
$actions[] = [
'url' => $this->url(null, ['action' => 'reset'], [], true),
'label' => 'Reset',
'class' => 'govuk-button govuk-button--secondary',
];
}
}

echo $this->render('partials/read-only/main',
Expand Down

0 comments on commit ae1f14b

Please sign in to comment.