Compliance list now shows next hearing date
Search added to case list Export added to compliance and cause list
This commit is contained in:
parent
cd4a091b63
commit
211b076d2b
@ -54,6 +54,7 @@ def case_info(item: Case) -> List[schemas.ComplianceList]:
|
|||||||
title=item.title,
|
title=item.title,
|
||||||
proceedings=h.proceedings if h.proceedings is not None else "",
|
proceedings=h.proceedings if h.proceedings is not None else "",
|
||||||
complianceDate=h.compliance_date,
|
complianceDate=h.compliance_date,
|
||||||
|
nextHearingDate=h.next_hearing_date,
|
||||||
)
|
)
|
||||||
for h in item.hearings
|
for h in item.hearings
|
||||||
if h.compliance_date is not None and h.compliance_done is False
|
if h.compliance_date is not None and h.compliance_done is False
|
||||||
|
@ -15,6 +15,7 @@ class ComplianceList(BaseModel):
|
|||||||
title: str
|
title: str
|
||||||
proceedings: str
|
proceedings: str
|
||||||
compliance_date: date
|
compliance_date: date
|
||||||
|
next_hearing_date: date
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
anystr_strip_whitespace = True
|
anystr_strip_whitespace = True
|
||||||
@ -26,3 +27,9 @@ class ComplianceList(BaseModel):
|
|||||||
if isinstance(value, date):
|
if isinstance(value, date):
|
||||||
return value
|
return value
|
||||||
return datetime.strptime(value, "%d-%b-%Y").date()
|
return datetime.strptime(value, "%d-%b-%Y").date()
|
||||||
|
|
||||||
|
@validator("next_hearing_date", pre=True)
|
||||||
|
def parse_next_hearing_date(cls, value):
|
||||||
|
if isinstance(value, date):
|
||||||
|
return value
|
||||||
|
return datetime.strptime(value, "%d-%b-%Y").date()
|
||||||
|
@ -8,31 +8,54 @@ import { Case } from '../../core/case';
|
|||||||
|
|
||||||
export class CaseListDataSource extends DataSource<Case> {
|
export class CaseListDataSource extends DataSource<Case> {
|
||||||
private dataValues: Case[] = [];
|
private dataValues: Case[] = [];
|
||||||
private data: Observable<Case[]> = new Observable<Case[]>();
|
private searchValues = '';
|
||||||
constructor(public d: Observable<Case[]>, private paginator?: MatPaginator) {
|
private data: Observable<Case[]>;
|
||||||
|
private search: Observable<string>;
|
||||||
|
constructor(
|
||||||
|
public d: Observable<Case[]>,
|
||||||
|
public s: Observable<string>,
|
||||||
|
private paginator?: MatPaginator,
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
this.data = d.pipe(tap((x) => (this.dataValues = x)));
|
this.data = d.pipe(tap((x) => (this.dataValues = x)));
|
||||||
|
this.search = s.pipe(tap((x) => (this.searchValues = x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<Case[]> {
|
connect(): Observable<Case[]> {
|
||||||
const dataMutations: (Observable<Case[]> | EventEmitter<PageEvent>)[] = [this.data];
|
const dataMutations: (Observable<Case[]> | Observable<string> | EventEmitter<PageEvent>)[] = [
|
||||||
|
this.data,
|
||||||
|
this.search,
|
||||||
|
];
|
||||||
if (this.paginator) {
|
if (this.paginator) {
|
||||||
dataMutations.push((this.paginator as MatPaginator).page);
|
dataMutations.push((this.paginator as MatPaginator).page);
|
||||||
}
|
}
|
||||||
|
|
||||||
return merge(...dataMutations)
|
return merge(...dataMutations)
|
||||||
.pipe(
|
.pipe(
|
||||||
|
map(() => this.getFilteredData([...this.dataValues])),
|
||||||
tap((x: Case[]) => {
|
tap((x: Case[]) => {
|
||||||
if (this.paginator) {
|
if (this.paginator) {
|
||||||
this.paginator.length = x.length;
|
this.paginator.length = x.length;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.pipe(map((x: Case[]) => this.getPagedData(this.dataValues)));
|
.pipe(map((x: Case[]) => this.getPagedData(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {}
|
disconnect() {}
|
||||||
|
|
||||||
|
private getFilteredData(data: Case[]): Case[] {
|
||||||
|
return this.searchValues.split(' ').reduce(
|
||||||
|
(p: Case[], c: string) =>
|
||||||
|
p.filter((x) => {
|
||||||
|
const accountString = `${x.caseSource.prefix}-${x.officeFileNumber} ${x.courtCaseNumber} ${x.year} ${x.title}
|
||||||
|
${x.docketNumber} ${x.remarks}`.toLowerCase();
|
||||||
|
return accountString.indexOf(c) !== -1;
|
||||||
|
}),
|
||||||
|
Object.assign([], data),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private getPagedData(data: Case[]) {
|
private getPagedData(data: Case[]) {
|
||||||
if (this.paginator === undefined) {
|
if (this.paginator === undefined) {
|
||||||
return data;
|
return data;
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label>Search</mat-label>
|
||||||
|
<input matInput placeholder="Search" formControlName="search" />
|
||||||
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||||
@ -48,12 +52,6 @@
|
|||||||
<mat-cell *matCellDef="let row">{{ row.courtCaseNumber }}</mat-cell>
|
<mat-cell *matCellDef="let row">{{ row.courtCaseNumber }}</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Case Connected With Column -->
|
|
||||||
<ng-container matColumnDef="caseConnectedWith">
|
|
||||||
<mat-header-cell *matHeaderCellDef>Connected Case</mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let row">{{ row.caseConnectedWith }}</mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<!-- Court Column -->
|
<!-- Court Column -->
|
||||||
<ng-container matColumnDef="court">
|
<ng-container matColumnDef="court">
|
||||||
<mat-header-cell *matHeaderCellDef>Forum</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef>Forum</mat-header-cell>
|
||||||
@ -78,12 +76,6 @@
|
|||||||
<mat-cell *matCellDef="let row">{{ row.courtStatus?.name }}</mat-cell>
|
<mat-cell *matCellDef="let row">{{ row.courtStatus?.name }}</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Office Status Column -->
|
|
||||||
<ng-container matColumnDef="officeStatus">
|
|
||||||
<mat-header-cell *matHeaderCellDef>Office Status</mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let row">{{ row.officeStatus?.name }}</mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<!-- Remarks Column -->
|
<!-- Remarks Column -->
|
||||||
<ng-container matColumnDef="remarks">
|
<ng-container matColumnDef="remarks">
|
||||||
<mat-header-cell *matHeaderCellDef>Remarks</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef>Remarks</mat-header-cell>
|
||||||
|
@ -3,7 +3,7 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
|||||||
import { MatPaginator } from '@angular/material/paginator';
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { distinctUntilChanged, startWith, switchMap, tap } from 'rxjs/operators';
|
import { debounceTime, distinctUntilChanged, startWith, switchMap, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Case } from '../../core/case';
|
import { Case } from '../../core/case';
|
||||||
import { CaseSource } from '../../core/case-source';
|
import { CaseSource } from '../../core/case-source';
|
||||||
@ -21,18 +21,17 @@ export class CaseListComponent implements OnInit {
|
|||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
caseSources: CaseSource[] = [];
|
caseSources: CaseSource[] = [];
|
||||||
list: Observable<Case[]> = new Observable<Case[]>();
|
list: Observable<Case[]> = new Observable<Case[]>();
|
||||||
dataSource: CaseListDataSource = new CaseListDataSource(this.list);
|
search: Observable<string>;
|
||||||
|
dataSource: CaseListDataSource;
|
||||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||||
displayedColumns = [
|
displayedColumns = [
|
||||||
'officeFileNumber',
|
'officeFileNumber',
|
||||||
'title',
|
'title',
|
||||||
'courtCaseNumber',
|
'courtCaseNumber',
|
||||||
'caseConnectedWith',
|
|
||||||
'court',
|
'court',
|
||||||
'appearOnBehalfOf',
|
'appearOnBehalfOf',
|
||||||
'nextHearingDate',
|
'nextHearingDate',
|
||||||
'courtStatus',
|
'courtStatus',
|
||||||
'officeStatus',
|
|
||||||
'remarks',
|
'remarks',
|
||||||
'receiptDate',
|
'receiptDate',
|
||||||
];
|
];
|
||||||
@ -41,7 +40,14 @@ export class CaseListComponent implements OnInit {
|
|||||||
// Create form
|
// Create form
|
||||||
this.form = this.fb.group({
|
this.form = this.fb.group({
|
||||||
caseSource: '',
|
caseSource: '',
|
||||||
|
search: '',
|
||||||
});
|
});
|
||||||
|
this.search = (this.form.get('search') as FormControl).valueChanges.pipe(
|
||||||
|
startWith(''),
|
||||||
|
debounceTime(150),
|
||||||
|
distinctUntilChanged(),
|
||||||
|
);
|
||||||
|
this.dataSource = new CaseListDataSource(this.list, this.search);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -50,6 +56,7 @@ export class CaseListComponent implements OnInit {
|
|||||||
this.caseSources = data.caseSources;
|
this.caseSources = data.caseSources;
|
||||||
this.form.setValue({
|
this.form.setValue({
|
||||||
caseSource: '08efc7cc-e4a1-4d24-bcba-58ca9bc29994',
|
caseSource: '08efc7cc-e4a1-4d24-bcba-58ca9bc29994',
|
||||||
|
search: '',
|
||||||
});
|
});
|
||||||
this.list = (this.form.get('caseSource') as FormControl).valueChanges.pipe(
|
this.list = (this.form.get('caseSource') as FormControl).valueChanges.pipe(
|
||||||
startWith('08efc7cc-e4a1-4d24-bcba-58ca9bc29994'),
|
startWith('08efc7cc-e4a1-4d24-bcba-58ca9bc29994'),
|
||||||
@ -57,7 +64,7 @@ export class CaseListComponent implements OnInit {
|
|||||||
switchMap((x) => this.ser.list(x)),
|
switchMap((x) => this.ser.list(x)),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
this.dataSource = new CaseListDataSource(this.list, this.paginator);
|
this.dataSource = new CaseListDataSource(this.list, this.search, this.paginator);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextHearingDate(row: Case): string {
|
nextHearingDate(row: Case): string {
|
||||||
|
@ -7,7 +7,7 @@ import { map, tap } from 'rxjs/operators';
|
|||||||
import { Case } from '../core/case';
|
import { Case } from '../core/case';
|
||||||
|
|
||||||
export class CauseListDatasource extends DataSource<Case> {
|
export class CauseListDatasource extends DataSource<Case> {
|
||||||
private dataValues: Case[] = [];
|
public dataValues: Case[] = [];
|
||||||
private data: Observable<Case[]> = new Observable<Case[]>();
|
private data: Observable<Case[]> = new Observable<Case[]>();
|
||||||
constructor(public d: Observable<Case[]>, private paginator?: MatPaginator) {
|
constructor(public d: Observable<Case[]>, private paginator?: MatPaginator) {
|
||||||
super();
|
super();
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
<mat-datepicker #finishDate></mat-datepicker>
|
<mat-datepicker #finishDate></mat-datepicker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-raised-button color="primary" (click)="show()" fxFlex="20%">Show</button>
|
<button mat-raised-button color="primary" (click)="show()" fxFlex="20%">Show</button>
|
||||||
|
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||||
|
<mat-icon>save_alt</mat-icon>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||||
|
@ -108,4 +108,44 @@ export class CauseListComponent implements OnInit {
|
|||||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportCsv() {
|
||||||
|
const csvData = new Blob([this.toCsv(this.dataSource.dataValues)], {
|
||||||
|
type: 'text/csv;charset=utf-8;',
|
||||||
|
});
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = window.URL.createObjectURL(csvData);
|
||||||
|
link.setAttribute('download', 'cause-list.csv');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
toCsv(data: Case[]): string {
|
||||||
|
const header = [
|
||||||
|
'File No.',
|
||||||
|
'Title',
|
||||||
|
'Court Case Number',
|
||||||
|
'Forum',
|
||||||
|
'Court / Item Number',
|
||||||
|
'Bench',
|
||||||
|
'Proceedings',
|
||||||
|
'Next Hearing',
|
||||||
|
'On Behalf of',
|
||||||
|
'Other Hearings',
|
||||||
|
'Remarks',
|
||||||
|
];
|
||||||
|
const csv = data.map(
|
||||||
|
(row) =>
|
||||||
|
`${row.caseSource.prefix}-${row.officeFileNumber}\t${row.title}\t${row.courtCaseNumber}\t${
|
||||||
|
row.court?.name
|
||||||
|
}\t${this.courtNumber(row)} / ${this.itemNumber(row)}\t${this.bench(
|
||||||
|
row,
|
||||||
|
)}\t${this.proceedings(row)}\t${this.nextHearingDate(row)}\t${
|
||||||
|
row.appearOnBehalfOf
|
||||||
|
}\t${this.otherHearingDates(row)}\t${row.remarks}`,
|
||||||
|
);
|
||||||
|
csv.unshift(header.join('\t'));
|
||||||
|
return csv.join('\r\n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-title-group>
|
<mat-card-title-group>
|
||||||
<mat-card-title>Compliances</mat-card-title>
|
<mat-card-title>Compliances</mat-card-title>
|
||||||
|
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||||
|
<mat-icon>save_alt</mat-icon>
|
||||||
|
</button>
|
||||||
</mat-card-title-group>
|
</mat-card-title-group>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||||
@ -30,6 +33,12 @@
|
|||||||
<mat-cell *matCellDef="let row">{{ row.complianceDate }}</mat-cell>
|
<mat-cell *matCellDef="let row">{{ row.complianceDate }}</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Next Hearing Date Column -->
|
||||||
|
<ng-container matColumnDef="nextHearingDate">
|
||||||
|
<mat-header-cell *matHeaderCellDef>Next Hearing Date</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let row">{{ row.nextHearingDate }}</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||||
</mat-table>
|
</mat-table>
|
||||||
|
@ -4,6 +4,8 @@ import { MatPaginator } from '@angular/material/paginator';
|
|||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
|
||||||
|
import { Case } from '../core/case';
|
||||||
|
|
||||||
import { ComplianceList } from './compliance-list';
|
import { ComplianceList } from './compliance-list';
|
||||||
import { ComplianceListDatasource } from './compliance-list-datasource';
|
import { ComplianceListDatasource } from './compliance-list-datasource';
|
||||||
|
|
||||||
@ -17,7 +19,13 @@ export class ComplianceListComponent implements OnInit {
|
|||||||
info: ComplianceList[] = [];
|
info: ComplianceList[] = [];
|
||||||
dataSource: ComplianceListDatasource = new ComplianceListDatasource(this.info);
|
dataSource: ComplianceListDatasource = new ComplianceListDatasource(this.info);
|
||||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||||
displayedColumns = ['officeFileNumber', 'title', 'proceedings', 'complianceDate'];
|
displayedColumns = [
|
||||||
|
'officeFileNumber',
|
||||||
|
'title',
|
||||||
|
'proceedings',
|
||||||
|
'complianceDate',
|
||||||
|
'nextHearingDate',
|
||||||
|
];
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute) {}
|
constructor(private route: ActivatedRoute) {}
|
||||||
|
|
||||||
@ -29,4 +37,26 @@ export class ComplianceListComponent implements OnInit {
|
|||||||
this.dataSource = new ComplianceListDatasource(this.info, this.paginator);
|
this.dataSource = new ComplianceListDatasource(this.info, this.paginator);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportCsv() {
|
||||||
|
const csvData = new Blob([this.toCsv(this.info)], {
|
||||||
|
type: 'text/csv;charset=utf-8;',
|
||||||
|
});
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = window.URL.createObjectURL(csvData);
|
||||||
|
link.setAttribute('download', 'cause-list.csv');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
toCsv(data: ComplianceList[]): string {
|
||||||
|
const header = ['File No.', 'Title', 'Proceedings', 'Next Hearing', 'Compliance Date'];
|
||||||
|
const csv = data.map(
|
||||||
|
(row) =>
|
||||||
|
`${row.officeFileNumber}\t${row.title}\t${row.proceedings}\t${row.nextHearingDate}\t${row.complianceDate}`,
|
||||||
|
);
|
||||||
|
csv.unshift(header.join('\t'));
|
||||||
|
return csv.join('\r\n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ export class ComplianceList {
|
|||||||
title: string;
|
title: string;
|
||||||
proceedings: string;
|
proceedings: string;
|
||||||
complianceDate: string;
|
complianceDate: string;
|
||||||
|
nextHearingDate: string;
|
||||||
|
|
||||||
public constructor(init?: Partial<ComplianceList>) {
|
public constructor(init?: Partial<ComplianceList>) {
|
||||||
this.id = '';
|
this.id = '';
|
||||||
@ -15,6 +16,7 @@ export class ComplianceList {
|
|||||||
this.title = '';
|
this.title = '';
|
||||||
this.proceedings = '';
|
this.proceedings = '';
|
||||||
this.complianceDate = '';
|
this.complianceDate = '';
|
||||||
|
this.nextHearingDate = '';
|
||||||
Object.assign(this, init);
|
Object.assign(this, init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user