Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDLS-373: Amend breadcrumbs for multi-client users #1729

Merged
merged 13 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,13 @@ public function iSelectTheLinkIShouldSeeTheDetailsOfTheChosenClient($link)
$this->assertPageContainsText(sprintf('%s\'s details', $client->getFirstname()));
$this->assertPageContainsText($client->getCaseNumber());
}

/**
* @Given /^I click on the button to edit my client's details$/
*/
public function IClickOnTheButtonToEditMyClientsDetails()
{
$clientName = $this->loggedInUserDetails->getClientFirstName();
$this->clickLink(sprintf('Edit %s\'s details', $clientName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ Feature: View client details
Then I should not see "Client details"

@lay-pfa-high-not-started-multi-client-deputy
Scenario: A user has access to the client details page of the client they have selected
Scenario: A user has access to the client details page of the client they have selected and correct breadcrumbs
Given a Lay Deputy tries to login with their "primary" email address
Then they should be on the Choose a Client homepage
And I select the first client from the Choose a Client page
When I select the first client from the Choose a Client page
Then I should see "Client details"
When I select the "Client details" link I should see the details of the chosen client
And I click on the button to edit my client's details
Then the Lay deputy navigates back to the Choose a Client homepage using the breadcrumb
4 changes: 4 additions & 0 deletions client/app/src/Controller/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public function editAction(Request $request)
*/
public function editClientDetailsAction(Request $request, int $clientId)
{
$user = $this->userApi->getUserWithData();
$deputyHasMultiClients = $this->getUser()->isLayDeputy() && $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid());

$from = $request->get('from');
$preUpdateClient = $this->clientApi->getById($clientId);

Expand Down Expand Up @@ -131,6 +134,7 @@ public function editClientDetailsAction(Request $request, int $clientId)
return [
'client' => $preUpdateClient,
'form' => $form->createView(),
'deputyHasMultiClients' => $deputyHasMultiClients,
];
}

Expand Down
18 changes: 17 additions & 1 deletion client/app/src/Controller/Report/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use App\Controller\AbstractController;
use App\Entity as EntityDir;
use App\Entity\User;
use App\Form as FormDir;
use App\Service\Client\Internal\ClientApi;
use App\Service\Client\Internal\ReportApi;
use App\Service\Client\RestClient;
use App\Service\StepRedirector;
Expand Down Expand Up @@ -32,7 +34,8 @@ class ActionController extends AbstractController
public function __construct(
RestClient $restClient,
ReportApi $reportApi,
StepRedirector $stepRedirector
StepRedirector $stepRedirector,
private ClientApi $clientApi,
) {
$this->restClient = $restClient;
$this->reportApi = $reportApi;
Expand All @@ -41,22 +44,29 @@ public function __construct(

/**
* @Route("/report/{reportId}/actions", name="actions")
*
* @Template("@App/Report/Action/start.html.twig")
*/
public function startAction(Request $request, $reportId)
{
/** @var User $user */
$user = $this->getUser();
$isMultiClientDeputy = 'ROLE_LAY_DEPUTY' == $user->getRoleName() ? $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid()) : null;

$report = $this->reportApi->getReportIfNotSubmitted($reportId, self::$jmsGroups);
if (EntityDir\Report\Status::STATE_NOT_STARTED != $report->getStatus()->getActionsState()['state']) {
return $this->redirectToRoute('actions_summary', ['reportId' => $reportId]);
}

return [
'report' => $report,
'isMultiClientDeputy' => $isMultiClientDeputy,
];
}

/**
* @Route("/report/{reportId}/actions/step/{step}", name="actions_step")
*
* @Template("@App/Report/Action/step.html.twig")
*/
public function stepAction(Request $request, $reportId, $step, TranslatorInterface $translator)
Expand Down Expand Up @@ -116,10 +126,15 @@ public function stepAction(Request $request, $reportId, $step, TranslatorInterfa

/**
* @Route("/report/{reportId}/actions/summary", name="actions_summary")
*
* @Template("@App/Report/Action/summary.html.twig")
*/
public function summaryAction(Request $request, $reportId)
{
/** @var User $user */
$user = $this->getUser();
$isMultiClientDeputy = 'ROLE_LAY_DEPUTY' == $user->getRoleName() ? $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid()) : null;

$fromPage = $request->get('from');
$report = $this->reportApi->getReportIfNotSubmitted($reportId, self::$jmsGroups);
if (EntityDir\Report\Status::STATE_NOT_STARTED == $report->getStatus()->getActionsState()['state'] && 'skip-step' != $fromPage) {
Expand All @@ -130,6 +145,7 @@ public function summaryAction(Request $request, $reportId)
'comingFromLastStep' => 'skip-step' == $fromPage || 'last-step' == $fromPage,
'report' => $report,
'status' => $report->getStatus(),
'isMultiClientDeputy' => $isMultiClientDeputy,
];
}

Expand Down
62 changes: 31 additions & 31 deletions client/app/src/Controller/Report/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace App\Controller\Report;

use App\Controller\AbstractController;
use App\Entity as EntityDir;
use App\Entity\Report;
use App\Entity\User;
use App\Form as FormDir;
use App\Service\Client\Internal\ClientApi;
use App\Service\Client\Internal\ReportApi;
use App\Service\Client\RestClient;
use App\Service\StepRedirector;
Expand All @@ -21,47 +22,41 @@ class AssetController extends AbstractController
'asset-state',
];

/** @var RestClient */
private $restClient;

/** @var ReportApi */
private $reportApi;

/** @var StepRedirector */
private $stepRedirector;

public function __construct(
RestClient $restClient,
ReportApi $reportApi,
StepRedirector $stepRedirector
private RestClient $restClient,
private ReportApi $reportApi,
private StepRedirector $stepRedirector,
private ClientApi $clientApi,
) {
$this->restClient = $restClient;
$this->reportApi = $reportApi;
$this->stepRedirector = $stepRedirector;
}

/**
* @Route("/report/{reportId}/assets", name="assets")
* @Template("@App/Report/Asset/start.html.twig")
*
* @param $reportId
* @Template("@App/Report/Asset/start.html.twig")
*
* @return array|RedirectResponse
*/
public function startAction($reportId)
{
/** @var User $user */
$user = $this->getUser();
$isMultiClientDeputy = 'ROLE_LAY_DEPUTY' == $user->getRoleName() ? $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid()) : null;

$report = $this->reportApi->getReportIfNotSubmitted($reportId, self::$jmsGroups);
if (EntityDir\Report\Status::STATE_NOT_STARTED != $report->getStatus()->getAssetsState()['state']) {
if (Report\Status::STATE_NOT_STARTED != $report->getStatus()->getAssetsState()['state']) {
return $this->redirectToRoute('assets_summary', ['reportId' => $reportId]);
}

return [
'report' => $report,
'isMultiClientDeputy' => $isMultiClientDeputy,
];
}

/**
* @Route("/report/{reportId}/assets/exist", name="assets_exist")
*
* @Template("@App/Report/Asset/exist.html.twig")
*/
public function existAction(Request $request, $reportId)
Expand All @@ -82,7 +77,7 @@ public function existAction(Request $request, $reportId)
switch ($report->getNoAssetToAdd()) {
case 0: // yes
return $this->redirectToRoute('assets_type', ['reportId' => $reportId]);
case 1: //no
case 1: // no
$this->restClient->put('report/'.$reportId, $report, ['noAssetsToAdd']);

return $this->redirectToRoute('assets_summary', ['reportId' => $reportId]);
Expand All @@ -103,12 +98,13 @@ public function existAction(Request $request, $reportId)

/**
* @Route("/report/{reportId}/assets/step-type", name="assets_type")
*
* @Template("@App/Report/Asset/type.html.twig")
*/
public function typeAction(Request $request, $reportId)
{
$report = $this->reportApi->getReportIfNotSubmitted($reportId, self::$jmsGroups);
$form = $this->createForm(FormDir\Report\Asset\AssetTypeTitle::class, new EntityDir\Report\AssetOther(), [
$form = $this->createForm(FormDir\Report\Asset\AssetTypeTitle::class, new Report\AssetOther(), [
]);
$form->handleRequest($request);

Expand All @@ -132,6 +128,7 @@ public function typeAction(Request $request, $reportId)

/**
* @Route("/report/{reportId}/assets/other/{title}/add", name="asset_other_add")
*
* @Template("@App/Report/Asset/Other/add.html.twig")
*/
public function otherAddAction(Request $request, $reportId, $title)
Expand Down Expand Up @@ -163,6 +160,7 @@ public function otherAddAction(Request $request, $reportId, $title)

/**
* @Route("/report/{reportId}/assets/other/edit/{assetId}", name="asset_other_edit")
*
* @Template("@App/Report/Asset/Other/edit.html.twig")
*/
public function otherEditAction(Request $request, $reportId, $assetId = null)
Expand Down Expand Up @@ -196,9 +194,8 @@ public function otherEditAction(Request $request, $reportId, $assetId = null)

/**
* @Route("/report/{reportId}/assets/add_another", name="assets_add_another")
* @Template("@App/Report/Asset/addAnother.html.twig")
*
* @param $reportId
* @Template("@App/Report/Asset/addAnother.html.twig")
*
* @return array|RedirectResponse
*/
Expand Down Expand Up @@ -226,6 +223,7 @@ public function addAnotherAction(Request $request, $reportId)

/**
* @Route("/report/{reportId}/assets/property/step{step}/{assetId}", name="assets_property_step", requirements={"step":"\d+"})
*
* @Template("@App/Report/Asset/Property/step.html.twig")
*/
public function propertyStepAction(Request $request, $reportId, $step, $assetId = null)
Expand Down Expand Up @@ -254,7 +252,7 @@ public function propertyStepAction(Request $request, $reportId, $step, $assetId
$asset = array_shift($assets);
$stepRedirector->setFromPage('summary');
} else { // add new asset
$asset = new EntityDir\Report\AssetProperty();
$asset = new Report\AssetProperty();
}

// add URL-data into model
Expand Down Expand Up @@ -347,30 +345,32 @@ public function propertyStepAction(Request $request, $reportId, $step, $assetId

/**
* @Route("/report/{reportId}/assets/summary", name="assets_summary")
* @Template("@App/Report/Asset/summary.html.twig")
*
* @param $reportId
* @Template("@App/Report/Asset/summary.html.twig")
*
* @return array|RedirectResponse
*/
public function summaryAction($reportId)
{
/** @var User $user */
$user = $this->getUser();
$isMultiClientDeputy = 'ROLE_LAY_DEPUTY' == $user->getRoleName() ? $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid()) : null;

$report = $this->reportApi->getReportIfNotSubmitted($reportId, self::$jmsGroups);
if (EntityDir\Report\Status::STATE_NOT_STARTED == $report->getStatus()->getAssetsState()['state']) {
if (Report\Status::STATE_NOT_STARTED == $report->getStatus()->getAssetsState()['state']) {
return $this->redirect($this->generateUrl('assets', ['reportId' => $reportId]));
}

return [
'report' => $report,
'isMultiClientDeputy' => $isMultiClientDeputy,
];
}

/**
* @Route("/report/{reportId}/assets/{assetId}/delete", name="asset_delete")
* @Template("@App/Common/confirmDelete.html.twig")
*
* @param $reportId
* @param $assetId
* @Template("@App/Common/confirmDelete.html.twig")
*
* @return array|RedirectResponse
*/
Expand All @@ -391,7 +391,7 @@ public function deleteAction(Request $request, $reportId, $assetId)

$asset = $this->restClient->get("report/{$reportId}/asset/{$assetId}", 'Report\\Asset');

if ($asset instanceof EntityDir\Report\AssetProperty) {
if ($asset instanceof Report\AssetProperty) {
$summary = [
['label' => 'deletePage.summary.type', 'value' => 'deletePage.summary.property', 'format' => 'translate'],
['label' => 'deletePage.summary.address', 'value' => implode(', ', $asset->getAddressValidLines())],
Expand Down
26 changes: 10 additions & 16 deletions client/app/src/Controller/Report/BalanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace App\Controller\Report;

use App\Controller\AbstractController;
use App\Entity\User;
use App\Form as FormDir;
use App\Service\Client\Internal\ClientApi;
use App\Service\Client\Internal\ReportApi;
use App\Service\Client\RestClient;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
Expand Down Expand Up @@ -34,30 +36,26 @@ class BalanceController extends AbstractController
'balance-state',
];

/** @var RestClient */
private $restClient;

/** @var ReportApi */
private $reportApi;

public function __construct(
RestClient $restClient,
ReportApi $reportApi
private RestClient $restClient,
private ReportApi $reportApi,
private ClientApi $clientApi,
) {
$this->restClient = $restClient;
$this->reportApi = $reportApi;
}

/**
* @Route("/report/{reportId}/balance", name="balance")
*
* @param $reportId
* @Template("@App/Report/Balance/balance.html.twig")
*
* @return array|RedirectResponse
*/
public function balanceAction(Request $request, $reportId)
{
/** @var User $user */
$user = $this->getUser();
$isMultiClientDeputy = 'ROLE_LAY_DEPUTY' == $user->getRoleName() ? $this->clientApi->checkDeputyHasMultiClients($user->getDeputyUid()) : null;

$report = $this->reportApi->getReportIfNotSubmitted($reportId, self::$jmsGroups);
$form = $this->createForm(FormDir\Report\ReasonForBalanceType::class, $report);
$form->handleRequest($request);
Expand All @@ -66,18 +64,14 @@ public function balanceAction(Request $request, $reportId)
$data = $form->getData();
$this->restClient->put('report/'.$reportId, $data, ['balance_mismatch_explanation']);

// $request->getSession()->getFlashBag()->add(
// 'notice',
// 'Balance explanation added'
// );

return $this->redirectToRoute('report_overview', ['reportId' => $report->getId()]);
}

return [
'report' => $report,
'form' => $form->createView(),
'backLink' => $this->generateUrl('report_overview', ['reportId' => $report->getId()]),
'isMultiClientDeputy' => $isMultiClientDeputy,
];
}

Expand Down
Loading
Loading