Hearing Date is not not null and unique for the court case.
Data import also needs to reflect this. Cause List made.
This commit is contained in:
parent
361d012d34
commit
2b5cf93ece
docker/app
luthor
alembic/versions
luthor
otis/src/app
app-routing.module.ts
cases/case-detail
cause-list
cause-list-datasource.tscause-list-resolver.service.spec.tscause-list-resolver.service.tscause-list-routing.module.spec.tscause-list-routing.module.tscause-list.component.csscause-list.component.htmlcause-list.component.spec.tscause-list.component.tscause-list.module.spec.tscause-list.module.tscause-list.service.spec.tscause-list.service.tscause-list.ts
nav-bar
@ -11,14 +11,6 @@ LABEL maintainer="Amritanshu <docker@tanshu.com>"
|
||||
COPY --from=builder /app/luthor /app
|
||||
COPY --from=builder /app/frontend /app/frontend
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y locales && \
|
||||
sed --in-place --expression='s/# en_IN UTF-8/en_IN UTF-8/' /etc/locale.gen && \
|
||||
dpkg-reconfigure --frontend=noninteractive locales
|
||||
|
||||
ENV LANG en_IN
|
||||
ENV LC_ALL en_IN
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install Poetry
|
||||
|
@ -256,7 +256,7 @@ def upgrade():
|
||||
sa.Column("bench", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("proceedings", sa.Unicode(length=2000), nullable=True),
|
||||
sa.Column("compliance_date", sa.DateTime(), nullable=True),
|
||||
sa.Column("next_hearing_date", sa.DateTime(), nullable=True),
|
||||
sa.Column("next_hearing_date", sa.DateTime(), nullable=False),
|
||||
sa.Column("court_status_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("old_court_status_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(["case_id"], ["cases.id"], name=op.f("fk_hearings_case_id_cases")),
|
||||
@ -264,6 +264,7 @@ def upgrade():
|
||||
["court_status_id"], ["court_statuses.id"], name=op.f("fk_hearings_court_status_id_court_statuses")
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_hearings")),
|
||||
sa.UniqueConstraint("next_hearing_date", "case_id", name=op.f("uq_hearings_next_hearing_date")),
|
||||
)
|
||||
op.create_index(op.f("ix_hearings_case_id"), "hearings", ["case_id"], unique=False)
|
||||
op.create_index(op.f("ix_hearings_next_hearing_date"), "hearings", ["next_hearing_date"], unique=False)
|
||||
|
@ -12,6 +12,7 @@ from .routers import (
|
||||
case,
|
||||
case_source,
|
||||
case_type,
|
||||
cause_list,
|
||||
contact,
|
||||
court,
|
||||
court_status,
|
||||
@ -38,6 +39,7 @@ app.include_router(user.router, prefix="/api/users", tags=["users"])
|
||||
|
||||
app.include_router(act.router, prefix="/api/acts", tags=["acts"])
|
||||
app.include_router(advocate.router, prefix="/api/advocates", tags=["advocates"])
|
||||
app.include_router(cause_list.router, prefix="/api/cause-list", tags=["cases"])
|
||||
app.include_router(case.router, prefix="/api/cases", tags=["cases"])
|
||||
app.include_router(case_source.router, prefix="/api/case-sources", tags=["case-sources"])
|
||||
app.include_router(case_type.router, prefix="/api/case-types", tags=["case-types"])
|
||||
|
110
luthor/luthor/routers/cause_list.py
Normal file
110
luthor/luthor/routers/cause_list.py
Normal file
@ -0,0 +1,110 @@
|
||||
from datetime import date, datetime
|
||||
|
||||
import luthor.schemas.case as schemas
|
||||
import luthor.schemas.cause_list as cl_schemas
|
||||
|
||||
from fastapi import APIRouter, Depends, Request, Security
|
||||
from luthor.models.hearing import Hearing
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..core.security import get_current_active_user as get_user
|
||||
from ..db.session import SessionLocal
|
||||
from ..models.case import Case
|
||||
from ..schemas.user_token import UserToken
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
# Dependency
|
||||
def get_db():
|
||||
try:
|
||||
db = SessionLocal()
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@router.get("", response_model=cl_schemas.CauseList)
|
||||
def report_blank(
|
||||
request: Request,
|
||||
s: str = None,
|
||||
f: str = None,
|
||||
db: Session = Depends(get_db),
|
||||
user: UserToken = Security(get_user, scopes=["cases"]),
|
||||
) -> cl_schemas.CauseList:
|
||||
s = date.today() if s is None else datetime.strptime(s, "%d-%b-%Y").date()
|
||||
f = date.today() if f is None else datetime.strptime(f, "%d-%b-%Y").date()
|
||||
return cl_schemas.CauseList(
|
||||
startDate=s,
|
||||
finishDate=f,
|
||||
cases=[
|
||||
case_info(item)
|
||||
for item in db.query(Case)
|
||||
.join(Case.hearings)
|
||||
.filter(Hearing.next_hearing_date >= s, Hearing.next_hearing_date <= f)
|
||||
.order_by(Hearing.next_hearing_date)
|
||||
.all()
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def case_info(item: Case) -> schemas.Case:
|
||||
return schemas.Case(
|
||||
id=item.id,
|
||||
caseSource=schemas.CaseSourceLink(
|
||||
id=item.case_source.id, name=item.case_source.name, prefix=item.case_source.prefix
|
||||
),
|
||||
officeFileNumber=item.office_file_number if item.office_file_number is not None else "",
|
||||
courtCaseNumber=item.court_case_number if item.court_case_number is not None else "",
|
||||
year=item.year,
|
||||
title=item.title if item.title is not None else "",
|
||||
docketNumber=item.docket_number if item.docket_number is not None else "",
|
||||
receiptDate=item.receipt_date,
|
||||
limitation_date=item.limitation_date,
|
||||
filingDate=item.filing_date,
|
||||
appearOnBehalfOf=item.appear_on_behalf_of if item.appear_on_behalf_of is not None else "",
|
||||
questionOfLaw=item.question_of_law if item.question_of_law is not None else "",
|
||||
aorName=item.aor_name if item.aor_name is not None else "",
|
||||
opposingCouncilAor=item.opposing_council_aor if item.opposing_council_aor is not None else "",
|
||||
opposingCouncilDetail=item.opposing_council_detail if item.opposing_council_detail is not None else "",
|
||||
lowerCourtCaseNumber=item.lower_court_case_number if item.lower_court_case_number is not None else "",
|
||||
dateOfImpugnedJudgement=item.date_of_impugned_judgement,
|
||||
briefDescription=item.brief_description if item.brief_description is not None else "",
|
||||
remarks=item.remarks if item.remarks is not None else "",
|
||||
slpCounter=item.slp_counter if item.slp_counter is not None else "",
|
||||
contactDetail=item.contact_detail if item.contact_detail is not None else "",
|
||||
caseConnectedWith=item.case_connected_with if item.case_connected_with is not None else "",
|
||||
bunchCases=item.bunch_cases if item.bunch_cases is not None else "",
|
||||
court=schemas.CourtLink(id=item.court.id, name=item.court.name) if item.court is not None else None,
|
||||
department=schemas.DepartmentLink(id=item.department.id, name=item.department.name)
|
||||
if item.department is not None
|
||||
else None,
|
||||
office=schemas.OfficeLink(id=item.office.id, name=item.office.name) if item.office is not None else None,
|
||||
caseType=schemas.CaseTypeLink(id=item.case_type.id, name=item.case_type.name)
|
||||
if item.case_type is not None
|
||||
else None,
|
||||
act=schemas.ActLink(id=item.act.id, name=item.act.name) if item.act is not None else None,
|
||||
nature=schemas.NatureLink(id=item.nature.id, name=item.nature.name) if item.nature is not None else None,
|
||||
officeStatus=schemas.OfficeStatusLink(id=item.office_status.id, name=item.office_status.name)
|
||||
if item.office_status is not None
|
||||
else None,
|
||||
courtStatus=schemas.CourtStatusLink(id=item.court_status.id, name=item.court_status.name)
|
||||
if item.court_status is not None
|
||||
else None,
|
||||
hearings=[
|
||||
schemas.Hearing(
|
||||
id=h.id,
|
||||
courtNumber=h.court_number if h.court_number is not None else "",
|
||||
itemNumber=h.item_number if h.item_number is not None else "",
|
||||
bench=h.bench if h.bench is not None else "",
|
||||
proceedings=h.proceedings if h.proceedings is not None else "",
|
||||
complianceDate=h.compliance_date,
|
||||
nextHearingDate=h.next_hearing_date,
|
||||
courtStatus=schemas.CourtStatusLink(id=h.court_status.id, name=h.court_status.name)
|
||||
if h.court_status is not None
|
||||
else None,
|
||||
)
|
||||
for h in item.hearings
|
||||
],
|
||||
)
|
30
luthor/luthor/schemas/cause_list.py
Normal file
30
luthor/luthor/schemas/cause_list.py
Normal file
@ -0,0 +1,30 @@
|
||||
from datetime import date, datetime
|
||||
from typing import List
|
||||
|
||||
from luthor.schemas.case import Case
|
||||
from pydantic import BaseModel, validator
|
||||
|
||||
from . import to_camel
|
||||
|
||||
|
||||
class CauseList(BaseModel):
|
||||
start_date: date
|
||||
finish_date: date
|
||||
cases: List[Case]
|
||||
|
||||
class Config:
|
||||
anystr_strip_whitespace = True
|
||||
alias_generator = to_camel
|
||||
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
|
||||
|
||||
@validator("start_date", pre=True)
|
||||
def parse_start_date(cls, value):
|
||||
if isinstance(value, date):
|
||||
return value
|
||||
return datetime.strptime(value, "%d-%b-%Y").date()
|
||||
|
||||
@validator("finish_date", pre=True)
|
||||
def parse_finish_date(cls, value):
|
||||
if isinstance(value, date):
|
||||
return value
|
||||
return datetime.strptime(value, "%d-%b-%Y").date()
|
@ -15,7 +15,7 @@ class HearingIn(BaseModel):
|
||||
bench: str
|
||||
proceedings: str
|
||||
compliance_date: Optional[date]
|
||||
next_hearing_date: Optional[date]
|
||||
next_hearing_date: date
|
||||
court_status: Optional[CourtStatusLink]
|
||||
|
||||
class Config:
|
||||
@ -35,8 +35,6 @@ class HearingIn(BaseModel):
|
||||
def parse_next_hearing_date(cls, value):
|
||||
if isinstance(value, date):
|
||||
return value
|
||||
if value is None:
|
||||
return None
|
||||
return datetime.strptime(value, "%d-%b-%Y").date()
|
||||
|
||||
|
||||
|
@ -13,6 +13,10 @@ const routes: Routes = [
|
||||
path: 'advocates',
|
||||
loadChildren: () => import('./advocates/advocates.module').then((mod) => mod.AdvocatesModule),
|
||||
},
|
||||
{
|
||||
path: 'cause-list',
|
||||
loadChildren: () => import('./cause-list/cause-list.module').then((mod) => mod.CauseListModule),
|
||||
},
|
||||
{
|
||||
path: 'case-sources',
|
||||
loadChildren: () =>
|
||||
|
@ -238,6 +238,7 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
getItem(): Case {
|
||||
const formModel = this.form.value;
|
||||
this.item.caseSource.id = formModel.caseSource;
|
||||
this.item.officeFileNumber = formModel.officeFileNumber;
|
||||
this.item.courtCaseNumber = formModel.courtCaseNumber;
|
||||
this.item.year = formModel.year;
|
||||
|
43
otis/src/app/cause-list/cause-list-datasource.ts
Normal file
43
otis/src/app/cause-list/cause-list-datasource.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
||||
import { merge, Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
|
||||
import { Case } from '../core/case';
|
||||
|
||||
export class CauseListDatasource extends DataSource<Case> {
|
||||
private dataValues: Case[] = [];
|
||||
private data: Observable<Case[]> = new Observable<Case[]>();
|
||||
constructor(public d: Observable<Case[]>, private paginator?: MatPaginator) {
|
||||
super();
|
||||
this.data = d.pipe(tap((x) => (this.dataValues = x)));
|
||||
}
|
||||
|
||||
connect(): Observable<Case[]> {
|
||||
const dataMutations: (Observable<Case[]> | EventEmitter<PageEvent>)[] = [this.data];
|
||||
if (this.paginator) {
|
||||
dataMutations.push((this.paginator as MatPaginator).page);
|
||||
}
|
||||
|
||||
return merge(...dataMutations)
|
||||
.pipe(
|
||||
tap((x: Case[]) => {
|
||||
if (this.paginator) {
|
||||
this.paginator.length = x.length;
|
||||
}
|
||||
}),
|
||||
)
|
||||
.pipe(map((x: Case[]) => this.getPagedData(this.dataValues)));
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
|
||||
private getPagedData(data: Case[]) {
|
||||
if (this.paginator === undefined) {
|
||||
return data;
|
||||
}
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
return data.slice(startIndex, startIndex + this.paginator.pageSize);
|
||||
}
|
||||
}
|
15
otis/src/app/cause-list/cause-list-resolver.service.spec.ts
Normal file
15
otis/src/app/cause-list/cause-list-resolver.service.spec.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CauseListResolver } from './cause-list-resolver.service';
|
||||
|
||||
describe('CauseListResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CauseListResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([CauseListResolver], (service: CauseListResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
19
otis/src/app/cause-list/cause-list-resolver.service.ts
Normal file
19
otis/src/app/cause-list/cause-list-resolver.service.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { CauseList } from './cause-list';
|
||||
import { CauseListService } from './cause-list.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CauseListResolver implements Resolve<CauseList> {
|
||||
constructor(private ser: CauseListService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<CauseList> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.list(startDate, finishDate);
|
||||
}
|
||||
}
|
13
otis/src/app/cause-list/cause-list-routing.module.spec.ts
Normal file
13
otis/src/app/cause-list/cause-list-routing.module.spec.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { CauseListRoutingModule } from './cause-list-routing.module';
|
||||
|
||||
describe('CauseListRoutingModule', () => {
|
||||
let causeListRoutingModule: CauseListRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
causeListRoutingModule = new CauseListRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(causeListRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
29
otis/src/app/cause-list/cause-list-routing.module.ts
Normal file
29
otis/src/app/cause-list/cause-list-routing.module.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { CauseListResolver } from './cause-list-resolver.service';
|
||||
import { CauseListComponent } from './cause-list.component';
|
||||
const advocatesRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: CauseListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cases',
|
||||
},
|
||||
resolve: {
|
||||
info: CauseListResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(advocatesRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [CauseListResolver],
|
||||
})
|
||||
export class CauseListRoutingModule {}
|
0
otis/src/app/cause-list/cause-list.component.css
Normal file
0
otis/src/app/cause-list/cause-list.component.css
Normal file
128
otis/src/app/cause-list/cause-list.component.html
Normal file
128
otis/src/app/cause-list/cause-list.component.html
Normal file
@ -0,0 +1,128 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Cases</mat-card-title>
|
||||
<a mat-button [routerLink]="['/cases', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex="40">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="startDate"
|
||||
(focus)="startDate.open()"
|
||||
placeholder="Start Date"
|
||||
formControlName="startDate"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #startDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="40">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="finishDate"
|
||||
(focus)="finishDate.open()"
|
||||
placeholder="Finish Date"
|
||||
formControlName="finishDate"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #finishDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" (click)="show()" fxFlex="20c">Show</button>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
<!-- Office File Number Column -->
|
||||
<ng-container matColumnDef="officeFileNumber">
|
||||
<mat-header-cell *matHeaderCellDef>File No.</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a [routerLink]="['/cases', row.id]"
|
||||
>{{ row.caseSource.prefix }}-{{ row.officeFileNumber }}</a
|
||||
></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Title Column -->
|
||||
<ng-container matColumnDef="title">
|
||||
<mat-header-cell *matHeaderCellDef>Title</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.title }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Court Case Number Column -->
|
||||
<ng-container matColumnDef="courtCaseNumber">
|
||||
<mat-header-cell *matHeaderCellDef>Case No.</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.courtCaseNumber }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Forum Column -->
|
||||
<ng-container matColumnDef="forum">
|
||||
<mat-header-cell *matHeaderCellDef>Forum</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.court?.name }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Court and Item Number Column -->
|
||||
<ng-container matColumnDef="courtAndItemNumber">
|
||||
<mat-header-cell *matHeaderCellDef>Court / Item Number</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ courtNumber(row) }} / {{ itemNumber(row) }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Bench Column -->
|
||||
<ng-container matColumnDef="bench">
|
||||
<mat-header-cell *matHeaderCellDef>Bench</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ bench(row) }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Proceedings Column -->
|
||||
<ng-container matColumnDef="proceedings">
|
||||
<mat-header-cell *matHeaderCellDef>Proceedings</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ proceedings(row) }}</mat-cell>
|
||||
</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">{{ nextHearingDate(row) }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Appear On Behalf Of Column -->
|
||||
<ng-container matColumnDef="appearOnBehalfOf">
|
||||
<mat-header-cell *matHeaderCellDef>On Behalf of</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.appearOnBehalfOf }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Other Hearing Dates Column -->
|
||||
<ng-container matColumnDef="otherHearingDates">
|
||||
<mat-header-cell *matHeaderCellDef>Other Hearing Dates</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ otherHearingDates(row) }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Remarks Column -->
|
||||
<ng-container matColumnDef="remarks">
|
||||
<mat-header-cell *matHeaderCellDef>Remarks</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.remarks }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
<mat-paginator
|
||||
#paginator
|
||||
[length]="0"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="10"
|
||||
[pageSizeOptions]="[10, 25, 50, 100, 250]"
|
||||
>
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
22
otis/src/app/cause-list/cause-list.component.spec.ts
Normal file
22
otis/src/app/cause-list/cause-list.component.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CauseListComponent } from './cause-list.component';
|
||||
|
||||
describe('CauseListComponent', () => {
|
||||
let component: CauseListComponent;
|
||||
let fixture: ComponentFixture<CauseListComponent>;
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [CauseListComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(CauseListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should compile', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
112
otis/src/app/cause-list/cause-list.component.ts
Normal file
112
otis/src/app/cause-list/cause-list.component.ts
Normal file
@ -0,0 +1,112 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
import { Case } from '../core/case';
|
||||
|
||||
import { CauseList } from './cause-list';
|
||||
import { CauseListDatasource } from './cause-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cause-list',
|
||||
templateUrl: './cause-list.component.html',
|
||||
styleUrls: ['./cause-list.component.css'],
|
||||
})
|
||||
export class CauseListComponent implements OnInit {
|
||||
@ViewChild(MatPaginator, { static: true }) paginator?: MatPaginator;
|
||||
form: FormGroup;
|
||||
info: CauseList = new CauseList();
|
||||
list: Observable<Case[]> = new Observable<Case[]>();
|
||||
dataSource: CauseListDatasource = new CauseListDatasource(this.list);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = [
|
||||
'officeFileNumber',
|
||||
'title',
|
||||
'courtCaseNumber',
|
||||
'forum',
|
||||
'courtAndItemNumber',
|
||||
'bench',
|
||||
'proceedings',
|
||||
'nextHearingDate',
|
||||
'appearOnBehalfOf',
|
||||
'otherHearingDates',
|
||||
'remarks',
|
||||
];
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router, private fb: FormBuilder) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { info: CauseList };
|
||||
|
||||
this.info = data.info;
|
||||
console.log(this.info.cases);
|
||||
this.form.setValue({
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||
});
|
||||
this.list = of(this.info.cases);
|
||||
this.dataSource = new CauseListDatasource(this.list, this.paginator);
|
||||
});
|
||||
}
|
||||
|
||||
courtNumber(row: Case): string {
|
||||
const [hearing] = row.hearings;
|
||||
return hearing.courtNumber;
|
||||
}
|
||||
|
||||
itemNumber(row: Case): string {
|
||||
const [hearing] = row.hearings;
|
||||
return hearing.itemNumber;
|
||||
}
|
||||
|
||||
bench(row: Case): string {
|
||||
const [hearing] = row.hearings;
|
||||
return hearing.bench;
|
||||
}
|
||||
|
||||
proceedings(row: Case): string {
|
||||
const [hearing] = row.hearings;
|
||||
return hearing.proceedings;
|
||||
}
|
||||
|
||||
nextHearingDate(row: Case): string {
|
||||
const [hearing] = row.hearings;
|
||||
return hearing.nextHearingDate || '';
|
||||
}
|
||||
|
||||
otherHearingDates(row: Case): string {
|
||||
return row.hearings
|
||||
.map((x) => x.nextHearingDate)
|
||||
.filter((x) => !!x)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['cause-list'], {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): CauseList {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return new CauseList({
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
});
|
||||
}
|
||||
}
|
13
otis/src/app/cause-list/cause-list.module.spec.ts
Normal file
13
otis/src/app/cause-list/cause-list.module.spec.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { CauseListModule } from './cause-list.module';
|
||||
|
||||
describe('CauseListModule', () => {
|
||||
let causeListModule: CauseListModule;
|
||||
|
||||
beforeEach(() => {
|
||||
causeListModule = new CauseListModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(causeListModule).toBeTruthy();
|
||||
});
|
||||
});
|
63
otis/src/app/cause-list/cause-list.module.ts
Normal file
63
otis/src/app/cause-list/cause-list.module.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import {
|
||||
DateAdapter,
|
||||
MAT_DATE_FORMATS,
|
||||
MAT_DATE_LOCALE,
|
||||
MatNativeDateModule,
|
||||
} from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
|
||||
import { CauseListRoutingModule } from './cause-list-routing.module';
|
||||
import { CauseListComponent } from './cause-list.component';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
},
|
||||
display: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
monthYearLabel: 'MMM YYYY',
|
||||
dateA11yLabel: 'DD-MMM-YYYY',
|
||||
monthYearA11yLabel: 'MMM YYYY',
|
||||
},
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
CauseListRoutingModule,
|
||||
MatSelectModule,
|
||||
MatPaginatorModule,
|
||||
MatDatepickerModule,
|
||||
MatDialogModule,
|
||||
],
|
||||
declarations: [CauseListComponent],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
|
||||
],
|
||||
})
|
||||
export class CauseListModule {}
|
15
otis/src/app/cause-list/cause-list.service.spec.ts
Normal file
15
otis/src/app/cause-list/cause-list.service.spec.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CauseListService } from './cause-list.service';
|
||||
|
||||
describe('CauseListService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CauseListService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([CauseListService], (service: CauseListService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
31
otis/src/app/cause-list/cause-list.service.ts
Normal file
31
otis/src/app/cause-list/cause-list.service.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { CauseList } from './cause-list';
|
||||
|
||||
const url = '/api/cause-list';
|
||||
const serviceName = 'CauseListService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CauseListService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(startDate: string | null, finishDate: string | null): Observable<CauseList> {
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
}
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return this.http
|
||||
.get<CauseList>(url, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<CauseList>;
|
||||
}
|
||||
}
|
14
otis/src/app/cause-list/cause-list.ts
Normal file
14
otis/src/app/cause-list/cause-list.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Case } from '../core/case';
|
||||
|
||||
export class CauseList {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
cases: Case[];
|
||||
|
||||
public constructor(init?: Partial<CauseList>) {
|
||||
this.startDate = '';
|
||||
this.finishDate = '';
|
||||
this.cases = [];
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
<mat-icon>home</mat-icon>
|
||||
Home
|
||||
</a>
|
||||
<a mat-button [routerLink]="['/cases']"> Cases </a>
|
||||
<a mat-button [routerLink]="['/cause-list']">Cause List</a>
|
||||
<mat-menu #mastersMenu="matMenu">
|
||||
<a mat-menu-item routerLink="/acts">Acts</a>
|
||||
<a mat-menu-item routerLink="/advocates">Advocates</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user