Skip to content

Commit

Permalink
Revert "fix for exui-837 (#1559)" (#1576)
Browse files Browse the repository at this point in the history
This reverts commit 71c6cd2.
  • Loading branch information
RiteshHMCTS authored Sep 29, 2023
1 parent 71c6cd2 commit bb05e82
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 175 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "6.19.6",
"version": "6.19.5",
"engines": {
"yarn": "^3.5.0",
"npm": "^8.10.0"
Expand Down
2 changes: 1 addition & 1 deletion projects/ccd-case-ui-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "6.19.6",
"version": "6.19.5",
"engines": {
"yarn": "^3.5.0",
"npm": "^8.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
FormValueService,
LoadingService,
} from '../../../services';
import { ValidPageListCaseFieldsService } from '../services/valid-page-list-caseFields.service';
import { FieldsUtils } from '../../../services/fields/fields.utils';
import { text } from '../../../test/helpers';
import { MockRpxTranslatePipe } from '../../../test/mock-rpx-translate.pipe';
Expand Down Expand Up @@ -77,7 +76,6 @@ describe('CaseEditPageComponent - creation and update event trigger tests', () =
caseFieldService = {},
caseEditDataService = {},
loadingService = {},
validPageListCaseFieldsService = {}
}) =>
new CaseEditPageComponent(
caseEdit as CaseEditComponent,
Expand All @@ -89,8 +87,7 @@ describe('CaseEditPageComponent - creation and update event trigger tests', () =
dialog as MatDialog,
caseFieldService as CaseFieldService,
caseEditDataService as CaseEditDataService,
loadingService as LoadingService,
validPageListCaseFieldsService as ValidPageListCaseFieldsService
loadingService as LoadingService
);

it('should create', () => {
Expand Down Expand Up @@ -297,30 +294,15 @@ describe('CaseEditPageComponent - all other tests', () => {
let wizardPage = createWizardPage(
[createCaseField('field1', 'field1Value')],
false,
0,
1
0
);
const wizardPage1 = createWizardPage(
[createCaseField('field1', 'field1Value')],
false,
0,
2
);
const wizardPage2 = createWizardPage(
[createCaseField('field3', 'field3Value')],
false,
0,
3
);
const pageList = [wizardPage1, wizardPage2];
const readOnly = new CaseField();
const fieldTypeSanitiser = new FieldTypeSanitiser();
const formValueService = new FormValueService(fieldTypeSanitiser);
const formErrorService = new FormErrorService();
const firstPage = new WizardPage();
const caseFieldService = new CaseFieldService();
const pageValidationService = new PageValidationService(caseFieldService);
const validPageListCaseFieldsService = new ValidPageListCaseFieldsService();
let route: any;
let snapshot: any;
const FORM_GROUP_NO_JUDICIAL_USERS = new FormGroup({
Expand Down Expand Up @@ -391,8 +373,7 @@ describe('CaseEditPageComponent - all other tests', () => {
metadataFields: [caseField2],
},
getNextPage: () => null,
callbackErrorsSubject: new Subject<any>(),
validPageList: pageList
callbackErrorsSubject: new Subject<any>()
};
snapshot = {
queryParamMap: createSpyObj('queryParamMap', ['get']),
Expand Down Expand Up @@ -469,8 +450,7 @@ describe('CaseEditPageComponent - all other tests', () => {
{ provide: CaseEditDataService, useValue: caseEditDataService },
FieldsUtils,
PlaceholderService,
{ provide: LoadingService, useValue: loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
{ provide: LoadingService, useValue: loadingServiceMock }
],
}).compileComponents();
fixture = TestBed.createComponent(CaseEditPageComponent);
Expand Down Expand Up @@ -786,8 +766,7 @@ describe('CaseEditPageComponent - all other tests', () => {
metadataFields: [],
},
getNextPage: () => null,
callbackErrorsSubject: new Subject<any>(),
validPageList: pageList
callbackErrorsSubject: new Subject<any>()
};
snapshot = {
queryParamMap: createSpyObj('queryParamMap', ['get']),
Expand Down Expand Up @@ -865,7 +844,6 @@ describe('CaseEditPageComponent - all other tests', () => {
FieldsUtils,
PlaceholderService,
{ provide: LoadingService, useValue: loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
],
}).compileComponents();
})
Expand Down Expand Up @@ -963,8 +941,7 @@ describe('CaseEditPageComponent - all other tests', () => {
title_display: '# 1234567812345678: test',
},
},
getNextPage: () => null,
validPageList: pageList
getNextPage: () => null
};

route = {
Expand Down Expand Up @@ -1026,7 +1003,6 @@ describe('CaseEditPageComponent - all other tests', () => {
FieldsUtils,
PlaceholderService,
{ provide: LoadingService, useValue: loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
],
}).compileComponents();
})
Expand Down Expand Up @@ -1121,8 +1097,7 @@ describe('CaseEditPageComponent - all other tests', () => {
},
getNextPage: () => null,
callbackErrorsSubject: new Subject<any>(),
ignoreWarning: true,
validPageList: pageList
ignoreWarning: true
};
snapshot = {
queryParamMap: createSpyObj('queryParamMap', ['get']),
Expand Down Expand Up @@ -1150,7 +1125,6 @@ describe('CaseEditPageComponent - all other tests', () => {
eventData
);
spyOn(formValueService, 'removeUnnecessaryFields');
spyOn(validPageListCaseFieldsService, 'deleteNonValidatedFields');

caseEditDataService = createSpyObj('caseEditDataService',
[
Expand Down Expand Up @@ -1195,7 +1169,6 @@ describe('CaseEditPageComponent - all other tests', () => {
FieldsUtils,
PlaceholderService,
{ provide: LoadingService, useValue: loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
],
}).compileComponents();
})
Expand All @@ -1212,8 +1185,7 @@ describe('CaseEditPageComponent - all other tests', () => {
aCaseField('judicialUserField2', 'judicialUser2', 'JudicialUser', 'OPTIONAL', null),
],
false,
0,
2
0
);
comp.wizard = new Wizard([wizardPage]);
// Rebuild the FORM_GROUP object before use because it gets modified by the "should call validate" test
Expand Down Expand Up @@ -1247,7 +1219,6 @@ describe('CaseEditPageComponent - all other tests', () => {
expect(formValueService.sanitise).toHaveBeenCalled();
expect(formValueService.removeUnnecessaryFields).toHaveBeenCalled();
expect(loadingServiceMock.register).toHaveBeenCalled();
expect(validPageListCaseFieldsService.deleteNonValidatedFields).toHaveBeenCalled();

fixture.whenStable().then(() => {
expect(comp.caseEdit.eventTrigger.case_id).toEqual(DRAFT_PREFIX + draft.id);
Expand Down Expand Up @@ -1451,8 +1422,7 @@ describe('CaseEditPageComponent - all other tests', () => {
metadataFields: [caseField2],
},
getNextPage: () => null,
callbackErrorsSubject: new Subject<any>(),
validPageList: pageList
callbackErrorsSubject: new Subject<any>()
};
snapshot = {
queryParamMap: createSpyObj('queryParamMap', ['get']),
Expand Down Expand Up @@ -1528,8 +1498,7 @@ describe('CaseEditPageComponent - all other tests', () => {
{ provide: CaseEditDataService, useValue: caseEditDataService },
FieldsUtils,
PlaceholderService,
{ provide: LoadingService, useValue: loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
{ provide: LoadingService, useValue: loadingServiceMock }
],
}).compileComponents();
})
Expand Down Expand Up @@ -1652,8 +1621,7 @@ describe('CaseEditPageComponent - all other tests', () => {
tabs: [],
metadataFields: [],
},
getNextPage: () => null,
validPageList: pageList
getNextPage: () => null
};
snapshot = {
queryParamMap: createSpyObj('queryParamMap', ['get']),
Expand Down Expand Up @@ -1724,8 +1692,7 @@ describe('CaseEditPageComponent - all other tests', () => {
{ provide: CaseEditDataService, useValue: caseEditDataService },
FieldsUtils,
PlaceholderService,
{ provide: LoadingService, useValue: loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
{ provide: LoadingService, useValue: loadingServiceMock }
],
}).compileComponents();
})
Expand Down Expand Up @@ -1972,8 +1939,7 @@ describe('CaseEditPageComponent - all other tests', () => {
function createWizardPage(
fields: CaseField[] = [],
isMultiColumn = false,
order = 0,
id = 1
order = 0
): WizardPage {
const wp: WizardPage = new WizardPage();
wp.case_fields = fields;
Expand All @@ -1982,7 +1948,6 @@ describe('CaseEditPageComponent - all other tests', () => {
wp.getCol2Fields = () => fields;
wp.isMultiColumn = () => isMultiColumn;
wp.order = order;
wp.id
return wp;
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { CaseEditComponent } from '../case-edit/case-edit.component';
import { WizardPage } from '../domain/wizard-page.model';
import { Wizard } from '../domain/wizard.model';
import { PageValidationService } from '../services/page-validation.service';
import { ValidPageListCaseFieldsService } from '../services/valid-page-list-caseFields.service';

@Component({
selector: 'ccd-case-edit-page',
Expand Down Expand Up @@ -73,7 +72,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
}

constructor(
public caseEdit: CaseEditComponent,
public readonly caseEdit: CaseEditComponent,
private readonly route: ActivatedRoute,
private readonly formValueService: FormValueService,
private readonly formErrorService: FormErrorService,
Expand All @@ -82,8 +81,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
private readonly dialog: MatDialog,
private readonly caseFieldService: CaseFieldService,
private readonly caseEditDataService: CaseEditDataService,
private readonly loadingService: LoadingService,
private readonly validPageListCaseFieldsService: ValidPageListCaseFieldsService
private readonly loadingService: LoadingService
) {
}

Expand Down Expand Up @@ -278,9 +276,6 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
}

if (!this.caseEdit.isSubmitting && !this.currentPageIsNotValid()) {
if (this.caseEdit.validPageList.findIndex(page=> page.id === this.currentPage.id) === -1) {
this.caseEdit.validPageList.push(this.currentPage);
}
this.caseEdit.isSubmitting = true;
this.caseEdit.error = null;
const caseEventData: CaseEventData = this.buildCaseEventData();
Expand Down Expand Up @@ -571,9 +566,6 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
// Get hold of the CaseEventData.
const caseEventData: CaseEventData = this.formValueService.sanitise(formFields) as CaseEventData;

// delete fields which are not part of the case event journey wizard pages case fields
this.validPageListCaseFieldsService.deleteNonValidatedFields(this.caseEdit.validPageList, caseEventData.data, true, fromPreviousPage);

// Tidy it up before we return it.
this.formValueService.removeUnnecessaryFields(caseEventData.data, caseFields, clearEmpty, clearNonCase,
fromPreviousPage, this.currentPage.case_fields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { PaletteUtilsModule } from '../../palette';
import { Confirmation, Wizard, WizardPage, WizardPageField } from '../domain';
import { CaseNotifier } from '../services';
import { WizardFactoryService } from '../services/wizard-factory.service';
import { ValidPageListCaseFieldsService } from '../services/valid-page-list-caseFields.service';
import { CaseEditComponent } from './case-edit.component';
import createSpyObj = jasmine.createSpyObj;

Expand Down Expand Up @@ -212,7 +211,6 @@ describe('CaseEditComponent', () => {
const registrarService = new ConditionalShowRegistrarService();
let route: any;
let mockSessionStorageService: jasmine.SpyObj<SessionStorageService>;
const validPageListCaseFieldsService = new ValidPageListCaseFieldsService();

describe('profile available in route', () => {
routerStub = {
Expand Down Expand Up @@ -270,7 +268,6 @@ describe('CaseEditComponent', () => {
'populateLinkedCasesDetailsFromCaseFields'
]);
mockSessionStorageService = createSpyObj<SessionStorageService>('SessionStorageService', ['getItem', 'removeItem', 'setItem']);
spyOn(validPageListCaseFieldsService, 'deleteNonValidatedFields');

route = {
queryParams: of({Origin: 'viewDraft'}),
Expand Down Expand Up @@ -320,8 +317,7 @@ describe('CaseEditComponent', () => {
{provide: ActivatedRoute, useValue: route},
SessionStorageService,
WindowService,
{ provide: LoadingService, loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
{ provide: LoadingService, loadingServiceMock }
]
})
.compileComponents();
Expand Down Expand Up @@ -1223,7 +1219,6 @@ describe('CaseEditComponent', () => {
expect(formValueService.removeCaseFieldsOfType)
.toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Array), ['FlagLauncher', 'ComponentLauncher']);
expect(formValueService.repopulateFormDataFromCaseFieldValues).toHaveBeenCalled();
expect(validPageListCaseFieldsService.deleteNonValidatedFields).toHaveBeenCalled();
});

it('should NOT submit the case due to error', () => {
Expand Down Expand Up @@ -1400,8 +1395,7 @@ describe('CaseEditComponent', () => {
{provide: Router, useValue: routerStub},
{provide: ActivatedRoute, useValue: mockRouteNoProfile},
SessionStorageService,
WindowService,
ValidPageListCaseFieldsService
WindowService
]
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import {
FieldsPurger, FieldsUtils, FormErrorService, FormValueService, LoadingService,
SessionStorageService, WindowService
} from '../../../services';
import { ShowCondition } from '../../../directives/conditional-show/domain/conditional-show.model';
import { Confirmation, Wizard, WizardPage } from '../domain';
import { EventCompletionParams } from '../domain/event-completion-params.model';
import { CaseNotifier, WizardFactoryService } from '../services';
import { ValidPageListCaseFieldsService } from '../services/valid-page-list-caseFields.service';

@Component({
selector: 'ccd-case-edit',
Expand Down Expand Up @@ -83,8 +81,6 @@ export class CaseEditComponent implements OnInit, OnDestroy {

public callbackErrorsSubject: Subject<any> = new Subject();

public validPageList: WizardPage[] = [];

constructor(
private readonly fb: FormBuilder,
private readonly caseNotifier: CaseNotifier,
Expand All @@ -98,8 +94,7 @@ export class CaseEditComponent implements OnInit, OnDestroy {
private readonly windowsService: WindowService,
private readonly formValueService: FormValueService,
private readonly formErrorService: FormErrorService,
private readonly loadingService: LoadingService,
private readonly validPageListCaseFieldsService: ValidPageListCaseFieldsService
private readonly loadingService: LoadingService
) {}

public ngOnInit(): void {
Expand Down Expand Up @@ -291,10 +286,6 @@ export class CaseEditComponent implements OnInit, OnDestroy {
this.formValueService.populateLinkedCasesDetailsFromCaseFields(caseEventData.data, eventTrigger.case_fields);
// Remove "Launcher"-type fields (these have no values and are not intended to be persisted)
this.formValueService.removeCaseFieldsOfType(caseEventData.data, eventTrigger.case_fields, ['FlagLauncher', 'ComponentLauncher']);

// delete fields which are not part of the case event journey wizard pages case fields
this.validPageListCaseFieldsService.deleteNonValidatedFields(this.validPageList, caseEventData.data, false);

caseEventData.event_token = eventTrigger.event_token;
caseEventData.ignore_warning = this.ignoreWarning;
if (this.confirmation) {
Expand Down Expand Up @@ -400,9 +391,7 @@ private replaceHiddenFormValuesWithOriginalCaseData(formGroup: FormGroup, caseFi
if (parentField && parentField.formatted_value) {
rawFormValueData[key] = parentField.formatted_value[caseField.id];
} else {
if (!(caseField.hidden && caseField.retain_hidden_value)) {
rawFormValueData[key] = caseField.formatted_value;
}
rawFormValueData[key] = caseField.formatted_value;
}
}
}
Expand Down
Loading

0 comments on commit bb05e82

Please sign in to comment.