Skip to content

Commit

Permalink
Update case-header.component.ts (#1814)
Browse files Browse the repository at this point in the history
* Update query-case-details-header.component.ts

* Update yarn-audit-known-issues

* update toolkit version

* code tidy and fix sonar cloud issue

* code tidy

* version update
  • Loading branch information
olusegz07 authored Dec 3, 2024
1 parent d569e43 commit cd2175b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 51 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": "7.1.16-response-status",
"version": "7.1.17-response-status-case-name",
"engines": {
"node": ">=18.19.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": "7.1.16-response-status",
"version": "7.1.17-response-status-case-name",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export class PageValidationService {
public getInvalidFields(page: WizardPage, editForm: FormGroup): CaseField[] {
const failingCaseFields = [];
page.case_fields
.filter(caseField => !this.caseFieldService.isReadOnly(caseField))
.filter(caseField => !this.isHidden(caseField, editForm))
.map(caseField => {
.filter((caseField) => !this.caseFieldService.isReadOnly(caseField))
.filter((caseField) => !this.isHidden(caseField, editForm))
.forEach((caseField) => {
const theControl = FieldsUtils.isCaseFieldOfType(caseField, ['JudicialUser'])
? editForm.controls['data'].get(`${caseField.id}_judicialUserControl`)
: editForm.controls['data'].get(caseField.id);
? editForm.controls.data.get(`${caseField.id}_judicialUserControl`)
: editForm.controls.data.get(caseField.id);
if (!(this.checkDocumentField(caseField, theControl) && this.checkOptionalField(caseField, theControl))) {
failingCaseFields.push(caseField);
};
}
});
return failingCaseFields;
}
Expand All @@ -46,9 +46,8 @@ export class PageValidationService {
private checkOptionalField(caseField: CaseField, theControl: AbstractControl): boolean {
if (!theControl) {
return this.caseFieldService.isOptional(caseField);
} else {
return theControl.valid || theControl.disabled;
}
return theControl.valid || theControl.disabled;
}

private checkMandatoryField(caseField: CaseField, theControl: AbstractControl): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ import { Draft } from '../../domain/draft.model';
})

export class CaseHeaderComponent implements OnInit {
@Input() public caseDetails: CaseView;

@Input()
public caseDetails: CaseView;
public caseTitle: CaseField;
public caseFields: CaseField[];

public ngOnInit(): void {
this.caseTitle = new CaseField();
this.caseTitle.label = this.caseDetails.state.title_display;
this.caseFields = this.getCaseFieldsInfo();
if (!this.isDraft() && this.caseDetails.state.title_display) {
this.caseTitle.label = this.caseDetails.state.title_display;
this.caseFields = this.getCaseFields();
}
}

public isDraft(): boolean {
return Draft.isDraft(this.caseDetails.case_id);
}

private getCaseFieldsInfo(): CaseField[] {
private getCaseFields(): CaseField[] {
const caseDataFields = this.caseDetails.tabs.reduce((acc, tab) => {
return acc.concat(tab.fields);
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,6 @@ export class SelectFlagTypeComponent implements OnInit, OnDestroy {
}
);

this.formGroup.addControl(CaseFlagFormFields.FLAG_TYPE, new FormControl(''));
this.formGroup.addControl(CaseFlagFormFields.OTHER_FLAG_DESCRIPTION, new FormControl(''));
this.formGroup.addControl(CaseFlagFormFields.IS_VISIBLE_INTERNALLY_ONLY, new FormControl(''));

// Should clear descriptionControlName if flagTypeControlName is changed
this.flagTypeControlChangesSubscription = this.formGroup.get(CaseFlagFormFields.FLAG_TYPE).valueChanges
.subscribe(_ => {
this.formGroup.get(CaseFlagFormFields.OTHER_FLAG_DESCRIPTION).setValue('');
this.cachedPath = [];

// required to clear language interpreter
this.formGroup.patchValue({
[SearchLanguageInterpreterControlNames.LANGUAGE_SEARCH_TERM]: '',
[SearchLanguageInterpreterControlNames.MANUAL_LANGUAGE_ENTRY]: ''
});
}
);

// If hmctsServiceId is present, use this to retrieve the relevant list of flag types
if (this.hmctsServiceId) {
this.flagRefdata$ = this.caseFlagRefdataService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
import { Component, Input, OnInit } from '@angular/core';
import { CaseView } from '../../../../../domain/case-view/case-view.model';
import { CaseField } from '../../../../../domain/definition/case-field.model';
import { Draft } from '../../../../../domain/draft.model';
import { ActivatedRoute } from '@angular/router';

@Component({
selector: 'ccd-query-case-details-header',
templateUrl: './query-case-details-header.component.html'
})

export class QueryCaseDetailsHeaderComponent implements OnInit {
@Input()
public caseDetails: CaseView;
@Input() public caseDetails: CaseView;
public caseTitle: CaseField;
public caseFields: CaseField[];
public caseView: CaseView;

constructor(activatedRoute: ActivatedRoute) {
this.caseView = activatedRoute.snapshot.data.case;
}

public ngOnInit(): void {
this.caseTitle = new CaseField();
if (!this.isDraft() && this.caseDetails.state.title_display) {
this.caseTitle.label = this.caseDetails.state.title_display;
this.caseFields = this.getCaseFields();
}
}

public isDraft(): boolean {
return Draft.isDraft(this.caseDetails.case_id);
this.caseTitle.label = this.caseDetails.state.title_display;
this.caseFields = this.getCaseFieldsInfo();
}

private getCaseFields(): CaseField[] {
private getCaseFieldsInfo(): CaseField[] {
const caseDataFields = this.caseDetails.tabs.reduce((acc, tab) => {
return acc.concat(tab.fields);
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class JurisdictionService {
}

public announceSelectedJurisdiction(jurisdiction: Jurisdiction): void {
console.info ('Announcing selected jurisdiction = ' + jurisdiction?.id);
this.selectedJurisdictionSource.next(jurisdiction);
this.selectedJurisdictionBS.next(jurisdiction);
}
Expand Down

0 comments on commit cd2175b

Please sign in to comment.