Added the office_file_number to case in frontend.
Get new office file number in new case. Convert the office_file_number field in the databse to integer
This commit is contained in:
@ -12,6 +12,14 @@
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Source</mat-label>
|
||||
<mat-select placeholder="Source" formControlName="caseSource">
|
||||
<mat-option *ngFor="let cs of caseSources" [value]="cs.id">
|
||||
{{ cs.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Office File Number</mat-label>
|
||||
<input
|
||||
|
||||
@ -8,6 +8,7 @@ import { distinctUntilChanged, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { Act } from '../../core/act';
|
||||
import { Case } from '../../core/case';
|
||||
import { CaseSource } from '../../core/case-source';
|
||||
import { CaseType } from '../../core/case-type';
|
||||
import { Court } from '../../core/court';
|
||||
import { CourtStatus } from '../../core/court-status';
|
||||
@ -28,6 +29,7 @@ import { CaseService } from '../case.service';
|
||||
export class CaseDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup;
|
||||
caseSources: CaseSource[] = [];
|
||||
caseTypes: CaseType[] = [];
|
||||
courts: Court[] = [];
|
||||
departments: Department[] = [];
|
||||
@ -45,10 +47,10 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: CaseService,
|
||||
private officeService: OfficeService,
|
||||
) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
caseSource: '',
|
||||
officeFileNumber: '',
|
||||
courtCaseNumber: '',
|
||||
year: '',
|
||||
@ -85,6 +87,7 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as {
|
||||
item: Case;
|
||||
caseSources: CaseSource[];
|
||||
caseTypes: CaseType[];
|
||||
courts: Court[];
|
||||
departments: Department[];
|
||||
@ -93,6 +96,7 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
||||
acts: Act[];
|
||||
natures: Nature[];
|
||||
};
|
||||
this.caseSources = data.caseSources;
|
||||
this.caseTypes = data.caseTypes;
|
||||
this.courts = data.courts;
|
||||
this.departments = data.departments;
|
||||
@ -107,6 +111,7 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
||||
showItem(item: Case) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
caseSource: this.item.caseSource.id,
|
||||
officeFileNumber: this.item.officeFileNumber,
|
||||
courtCaseNumber: this.item.courtCaseNumber,
|
||||
year: this.item.year,
|
||||
@ -144,11 +149,21 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
||||
officeStatus: this.item.officeStatus ? this.item.officeStatus.id : '',
|
||||
courtStatus: this.item.courtStatus ? this.item.courtStatus.id : '',
|
||||
});
|
||||
this.offices = (this.form.get('department') as FormControl).valueChanges.pipe(
|
||||
startWith(this.item.department ? this.item.department.id : ''),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => this.officeService.filteredList(x)),
|
||||
);
|
||||
(this.form.get('caseSource') as FormControl).valueChanges
|
||||
.pipe(
|
||||
startWith(this.item.caseSource.id),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => this.ser.newOfficeFileNumber(x)),
|
||||
)
|
||||
.subscribe((x) => {
|
||||
if (
|
||||
this.item.officeFileNumber === null ||
|
||||
this.item.officeFileNumber === undefined ||
|
||||
this.item.officeFileNumber === ''
|
||||
) {
|
||||
this.form.patchValue({ officeFileNumber: x });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
||||
@ -30,7 +30,9 @@
|
||||
<ng-container matColumnDef="officeFileNumber">
|
||||
<mat-header-cell *matHeaderCellDef>File No.</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a [routerLink]="['/cases', row.id]">{{ row.officeFileNumber }}</a></mat-cell
|
||||
><a [routerLink]="['/cases', row.id]"
|
||||
>{{ row.caseSource.prefix }}-{{ row.officeFileNumber }}</a
|
||||
></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
|
||||
@ -48,12 +48,13 @@ export class CaseListComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Case[]; caseSources: CaseSource[] };
|
||||
const data = value as { caseSources: CaseSource[] };
|
||||
this.caseSources = data.caseSources;
|
||||
this.list = observableOf(data.list);
|
||||
|
||||
this.form.setValue({
|
||||
caseSource: '08efc7cc-e4a1-4d24-bcba-58ca9bc29994',
|
||||
});
|
||||
this.list = (this.form.get('caseSource') as FormControl).valueChanges.pipe(
|
||||
startWith(''),
|
||||
startWith('08efc7cc-e4a1-4d24-bcba-58ca9bc29994'),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => this.ser.list(x)),
|
||||
);
|
||||
|
||||
@ -56,4 +56,12 @@ export class CaseService {
|
||||
.delete<Case>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<Case>;
|
||||
}
|
||||
|
||||
newOfficeFileNumber(caseTypeId: string): Observable<number> {
|
||||
return this.http
|
||||
.get<number>(`${url}/id/${caseTypeId}`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get newOfficeFileNumber=${caseTypeId}`)),
|
||||
) as Observable<number>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ const advocatesRoutes: Routes = [
|
||||
},
|
||||
resolve: {
|
||||
caseSources: CaseSourceListResolver,
|
||||
list: CaseListResolver,
|
||||
// list: CaseListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -43,6 +43,7 @@ const advocatesRoutes: Routes = [
|
||||
},
|
||||
resolve: {
|
||||
item: CaseResolver,
|
||||
caseSources: CaseSourceListResolver,
|
||||
caseTypes: CaseTypeListResolver,
|
||||
courts: CourtListResolver,
|
||||
departments: DepartmentListResolver,
|
||||
@ -61,6 +62,7 @@ const advocatesRoutes: Routes = [
|
||||
},
|
||||
resolve: {
|
||||
item: CaseResolver,
|
||||
caseSources: CaseSourceListResolver,
|
||||
caseTypes: CaseTypeListResolver,
|
||||
courts: CourtListResolver,
|
||||
departments: DepartmentListResolver,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { Act } from './act';
|
||||
import { CaseSource } from './case-source';
|
||||
import { CaseType } from './case-type';
|
||||
import { Court } from './court';
|
||||
import { CourtStatus } from './court-status';
|
||||
@ -9,6 +10,7 @@ import { OfficeStatus } from './office-status';
|
||||
|
||||
export class Case {
|
||||
id: string | undefined;
|
||||
caseSource: CaseSource;
|
||||
officeFileNumber: string;
|
||||
courtCaseNumber: string;
|
||||
year: string;
|
||||
@ -41,6 +43,7 @@ export class Case {
|
||||
|
||||
public constructor(init?: Partial<Case>) {
|
||||
this.id = undefined;
|
||||
this.caseSource = new CaseSource();
|
||||
this.officeFileNumber = '';
|
||||
this.courtCaseNumber = '';
|
||||
this.year = '';
|
||||
|
||||
Reference in New Issue
Block a user