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

Csfd 15 ungrey back button #1706

Open
wants to merge 131 commits into
base: master
Choose a base branch
from
Open

Conversation

joeevanshmcts
Copy link

@joeevanshmcts joeevanshmcts commented Mar 26, 2024

JIRA link (if applicable)

Change Description

I've included the epic above to show how there are other items of work associated to this. The purpose of this pull request is to ensure that the existing changes get pushed into master, while they're not 100% complete, they're an improvement on what is currently there in production as of the time of writing this. There are still some issues with the implementation, it's not perfect, but it is an improvement.

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[X] No

joeevanshmcts and others added 25 commits February 12, 2024 15:09
We're in the process of debugging an issue where the user hits the review page & then hits change, the previous button is not always accessible.
CSFD-18 Event flow cancel navigation
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
52.0% Coverage on New Code (required ≥ 80%)
10.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Copy link
Contributor

@connorpgpmcelroy connorpgpmcelroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of minor comments and a few moderate ones. Quite a long PR and not necessarily my expertise in the application but looks like most of it is good and functional.

@@ -434,6 +493,20 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
}

public cancel(): void {
if (this.isLinkedCasesJourney()){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment - add cleanUpData method so that this can be used elsewhere if needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at least think about it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved it to its own reset function

tab?.fields?.some((field) => field.id === 'caseLinks')
)?.fields?.[0] ?? null;
const initalLinks = this.linkedCasesService.initialCaseLinkRefs;
if (linkedCasesTab && linkedCasesTab?.value.length !== initalLinks.length){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another minor comment - a few assumptions made here, i.e. that there is this.caseEdit.caseDetails.tabs and that linkedCasesTab.value exists, just check that they definitely will

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional checks for properties

@@ -36,6 +38,9 @@ import { CaseEditSubmitTitles } from './case-edit-submit-titles.enum';
import { CaseEditSubmitComponent } from './case-edit-submit.component';

import createSpyObj = jasmine.createSpyObj;
import { CaseFlagStateService } from '../services/case-flag-state.service';
import { LinkedCasesService } from '../../palette/linked-cases/services/linked-cases.service';
import exp from 'constants';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment - should constants not be a relative import i.e. ./constants?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved imports and removed unused imports

it('should display the "Previous" button if submission is not for a Case Flag', () => {
comp.eventTrigger.case_fields = [];
fixture.detectChanges();
expect(comp.caseEdit.isCaseFlagSubmission).toBe(false);
const previousButton = de.query(By.css('.button-secondary'));
expect(previousButton.nativeElement.textContent).toContain('Previous');
});

it('should remove any unsibmitted data on cancel', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsubmitted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -167,6 +177,20 @@ export class CaseEditSubmitComponent implements OnInit, OnDestroy {
}

public cancel(): void {
if (this.caseEdit.isLinkedCasesSubmission){
// if they cancel on the last CYA page we should ensure there is no unsubmitted data in the caseDetails
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment - Again could create other reusable method for this (removeUnsubmittedData)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split to child functions

this.linkedCasesStateEmitter.emit({
currentLinkedCasesPage: LinkedCasesPages.BEFORE_YOU_START,
errorMessages: this.errorMessages,
navigateToNextPage: true
});
}

public next() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public next(): void {
Also onNext and next as two methods placed together is confusing, can they be renamed and/or commented?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it was done like this, have simplified to one next function

import { CaseLink, LinkedCasesState } from './domain';
import { LinkedCasesEventTriggers, LinkedCasesPages } from './enums';
import { LinkedCasesService } from './services';
import { Subscription } from 'rxjs';
import { MultipageComponentStateService } from '../../../services';
import { Router } from '@angular/router';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

External imports before internal imports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved

private readonly caseEditDataService: CaseEditDataService,
private router: Router,
multipageComponentStateService: MultipageComponentStateService) {
super(multipageComponentStateService);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation confusing here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumped ) { to next line

}

public ngOnInit(): void {
const trigUrl = location.href;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor pedantic comment (sorry there's quite a few of these now) - trigUrl could be more descriptive e.g. triggeredUrl or toTriggerUrl depending on its usage

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point, renamed to trigger


public handleBackButton(event) {
event.preventDefault();
if (this.linkedCasesPage === 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another minor pedantic comment - see quite a few instances of ){ at the end of ifs and methods. Just did a find for '){' and there are 31 instances of it on the full change summary. Linting is obviously not picking it up but as it is not consistent with the application I would recommend changing them, especially for the end of methods/functions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done a search through the changes and updated all instances of ){

Copy link
Contributor

@connorpgpmcelroy connorpgpmcelroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks a lot better and more consistent, will approve, please see further comments to make small further editions

@@ -58,6 +62,9 @@ import { CaseEditPageText } from './case-edit-page-text.enum';
import { CaseEditPageComponent } from './case-edit-page.component';
import { ShowCondition } from '../../../directives';
import createSpyObj = jasmine.createSpyObj;
import { LinkedCasesService } from '../../palette/linked-cases/services/linked-cases.service';
import { CaseFlagStateService } from '../services/case-flag-state.service';
import { CaseTab } from 'ccd-case-ui-toolkit';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment - External imports before internal imports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think as it was a large diff I missed it before

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

}) =>
new CaseEditPageComponent(
new CaseEditPageComponent(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor comment - Indentation not needed here (can ignore)

expect(caseFlagStateService.lastPageFieldState).toEqual(3);
});

it('should remove any unsibmitted data on cancel', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsubmitted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

RiteshHMCTS
RiteshHMCTS previously approved these changes Feb 10, 2025
const initialCaseLinks = this.linkedCasesService.initialCaseLinkRefs || [];
console.log(initialCaseLinks);
console.log(proposedCaseLink);
return initialCaseLinks.includes(proposedCaseLink);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Josh-HMCTS can you remove these console.log

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

// the journey can become broken in some situations as the journeyPageNumber is not correct, account for this and set to the correct value
const journeyPageNumber = this.getJourneyCollection()['journeyPageNumber'];
const linkedCasesPageNumber = this.getJourneyCollection()['linkedCasesPage'];
console.log(journeyPageNumber, linkedCasesPageNumber)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Josh-HMCTS same here if we don't need it then we can remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

public validateTranslationNeeded(): void {
// it is possible that the user can select to have translation and then navigate back to remove the required translation in the same journey
// this function will check the user does not have any of the translation fields applied and remove if they do
console.log('validateTranslateNeeded');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Josh-HMCTS if we don't need this console.log, then remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants