Case Sources added primarily to filter the kind of cases in case list.
This commit is contained in:
@@ -300,6 +300,11 @@ def update_auth():
|
|||||||
.where(permissions.c.name == op.inline_literal("ContactPersons"))
|
.where(permissions.c.name == op.inline_literal("ContactPersons"))
|
||||||
.values({"name": op.inline_literal("Contacts")})
|
.values({"name": op.inline_literal("Contacts")})
|
||||||
)
|
)
|
||||||
|
op.execute(
|
||||||
|
permissions.update()
|
||||||
|
.where(permissions.c.name == op.inline_literal("AllowFeeMenu"))
|
||||||
|
.values({"name": op.inline_literal("Case Sources")})
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def update_hearings():
|
def update_hearings():
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class Case(Base):
|
|||||||
court_status_id=None,
|
court_status_id=None,
|
||||||
case_source_id=None,
|
case_source_id=None,
|
||||||
is_deleted=None,
|
is_deleted=None,
|
||||||
id=None,
|
id_=None,
|
||||||
):
|
):
|
||||||
self.office_file_number = office_file_number
|
self.office_file_number = office_file_number
|
||||||
self.court_case_number = court_case_number
|
self.court_case_number = court_case_number
|
||||||
@@ -127,4 +127,4 @@ class Case(Base):
|
|||||||
self.court_status_id = court_status_id
|
self.court_status_id = court_status_id
|
||||||
self.is_deleted = False if is_deleted is None else is_deleted
|
self.is_deleted = False if is_deleted is None else is_deleted
|
||||||
self.case_source_id = case_source_id
|
self.case_source_id = case_source_id
|
||||||
self.id = id
|
self.id = id_
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ def show_list(db: Session = Depends(get_db), user: UserToken = Depends(get_user)
|
|||||||
return [case_info(item) for item in db.query(Case).order_by(desc(Case.receipt_date)).all()]
|
return [case_info(item) for item in db.query(Case).order_by(desc(Case.receipt_date)).all()]
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/list/{source_id}", response_model=List[schemas.Case])
|
||||||
|
def show_list_of_source(source_id: uuid.UUID, db: Session = Depends(get_db), user: UserToken = Depends(get_user)) -> List[schemas.Case]:
|
||||||
|
return [case_info(item) for item in db.query(Case).filter(Case.case_source_id == source_id).order_by(desc(Case.receipt_date)).all()]
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{id_}", response_model=schemas.Case)
|
@router.get("/{id_}", response_model=schemas.Case)
|
||||||
def show_id(
|
def show_id(
|
||||||
id_: uuid.UUID,
|
id_: uuid.UUID,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ def get_db():
|
|||||||
def save(
|
def save(
|
||||||
data: schemas.CaseSourceIn,
|
data: schemas.CaseSourceIn,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["case_sources"]),
|
user: UserToken = Security(get_user, scopes=["case-sources"]),
|
||||||
) -> schemas.CaseSource:
|
) -> schemas.CaseSource:
|
||||||
try:
|
try:
|
||||||
item = CaseSource(name=data.name, prefix=data.prefix)
|
item = CaseSource(name=data.name, prefix=data.prefix)
|
||||||
@@ -53,7 +53,7 @@ def update(
|
|||||||
id_: uuid.UUID,
|
id_: uuid.UUID,
|
||||||
data: schemas.CaseSourceIn,
|
data: schemas.CaseSourceIn,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["case_sources"]),
|
user: UserToken = Security(get_user, scopes=["case-sources"]),
|
||||||
) -> schemas.CaseSource:
|
) -> schemas.CaseSource:
|
||||||
try:
|
try:
|
||||||
item: CaseSource = db.query(CaseSource).filter(CaseSource.id == id_).first()
|
item: CaseSource = db.query(CaseSource).filter(CaseSource.id == id_).first()
|
||||||
@@ -76,7 +76,7 @@ def update(
|
|||||||
def delete(
|
def delete(
|
||||||
id_: uuid.UUID,
|
id_: uuid.UUID,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["case_sources"]),
|
user: UserToken = Security(get_user, scopes=["case-sources"]),
|
||||||
) -> schemas.CaseSourceBlank:
|
) -> schemas.CaseSourceBlank:
|
||||||
try:
|
try:
|
||||||
item: CaseSource = db.query(CaseSource).filter(CaseSource.id == id_).first()
|
item: CaseSource = db.query(CaseSource).filter(CaseSource.id == id_).first()
|
||||||
@@ -97,7 +97,7 @@ def delete(
|
|||||||
@router.get("", response_model=schemas.CaseSourceBlank)
|
@router.get("", response_model=schemas.CaseSourceBlank)
|
||||||
def show_blank(
|
def show_blank(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["case_sources"]),
|
user: UserToken = Security(get_user, scopes=["case-sources"]),
|
||||||
) -> schemas.CaseSourceBlank:
|
) -> schemas.CaseSourceBlank:
|
||||||
return case_source_blank()
|
return case_source_blank()
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ def show_list(db: Session = Depends(get_db), user: UserToken = Depends(get_user)
|
|||||||
def show_id(
|
def show_id(
|
||||||
id_: uuid.UUID,
|
id_: uuid.UUID,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["case_sources"]),
|
user: UserToken = Security(get_user, scopes=["case-sources"]),
|
||||||
) -> schemas.CaseSource:
|
) -> schemas.CaseSource:
|
||||||
item: CaseSource = db.query(CaseSource).filter(CaseSource.id == id_).first()
|
item: CaseSource = db.query(CaseSource).filter(CaseSource.id == id_).first()
|
||||||
return case_source_info(item)
|
return case_source_info(item)
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ const routes: Routes = [
|
|||||||
path: 'advocates',
|
path: 'advocates',
|
||||||
loadChildren: () => import('./advocates/advocates.module').then((mod) => mod.AdvocatesModule),
|
loadChildren: () => import('./advocates/advocates.module').then((mod) => mod.AdvocatesModule),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'case-sources',
|
||||||
|
loadChildren: () => import('./case-sources/case-sources.module').then((mod) => mod.CaseSourcesModule),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'case-types',
|
path: 'case-types',
|
||||||
loadChildren: () => import('./case-types/case-types.module').then((mod) => mod.CaseTypesModule),
|
loadChildren: () => import('./case-types/case-types.module').then((mod) => mod.CaseTypesModule),
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.right-align {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<div fxLayout="row" fxFlex="50%" fxLayoutAlign="space-around center" class="example-card">
|
||||||
|
<mat-card fxFlex>
|
||||||
|
<mat-card-title-group>
|
||||||
|
<mat-card-title>Case Source</mat-card-title>
|
||||||
|
</mat-card-title-group>
|
||||||
|
<mat-card-content>
|
||||||
|
<form [formGroup]="form" fxLayout="column">
|
||||||
|
<div
|
||||||
|
fxLayout="row"
|
||||||
|
fxLayoutAlign="space-around start"
|
||||||
|
fxLayout.lt-md="column"
|
||||||
|
fxLayoutGap="20px"
|
||||||
|
fxLayoutGap.lt-md="0px"
|
||||||
|
>
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label>Name</mat-label>
|
||||||
|
<input
|
||||||
|
matInput
|
||||||
|
#nameElement
|
||||||
|
placeholder="Name"
|
||||||
|
formControlName="name"
|
||||||
|
/>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
fxLayout="row"
|
||||||
|
fxLayoutAlign="space-around start"
|
||||||
|
fxLayout.lt-md="column"
|
||||||
|
fxLayoutGap="20px"
|
||||||
|
fxLayoutGap.lt-md="0px"
|
||||||
|
>
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label>Prefix</mat-label>
|
||||||
|
<input
|
||||||
|
matInput
|
||||||
|
placeholder="Prefix"
|
||||||
|
formControlName="prefix"
|
||||||
|
/>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</mat-card-content>
|
||||||
|
<mat-card-actions>
|
||||||
|
<button mat-raised-button color="primary" (click)="save()">Save</button>
|
||||||
|
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CaseSourceDetailComponent } from './case-source-detail.component';
|
||||||
|
|
||||||
|
describe('CaseSourceDetailComponent', () => {
|
||||||
|
let component: CaseSourceDetailComponent;
|
||||||
|
let fixture: ComponentFixture<CaseSourceDetailComponent>;
|
||||||
|
|
||||||
|
beforeEach(
|
||||||
|
waitForAsync(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [CaseSourceDetailComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(CaseSourceDetailComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { CaseSource } from '../../core/case-source';
|
||||||
|
import { ToasterService } from '../../core/toaster.service';
|
||||||
|
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||||
|
import { CaseSourceService } from '../case-source.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-case-source-detail',
|
||||||
|
templateUrl: './case-source-detail.component.html',
|
||||||
|
styleUrls: ['./case-source-detail.component.css'],
|
||||||
|
})
|
||||||
|
export class CaseSourceDetailComponent implements OnInit, AfterViewInit {
|
||||||
|
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||||
|
form: FormGroup;
|
||||||
|
item: CaseSource = new CaseSource();
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
private dialog: MatDialog,
|
||||||
|
private fb: FormBuilder,
|
||||||
|
private toaster: ToasterService,
|
||||||
|
private ser: CaseSourceService,
|
||||||
|
) {
|
||||||
|
// Create form
|
||||||
|
this.form = this.fb.group({
|
||||||
|
name: '',
|
||||||
|
prefix: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.route.data.subscribe((value) => {
|
||||||
|
const data = value as { item: CaseSource };
|
||||||
|
this.showItem(data.item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
showItem(item: CaseSource) {
|
||||||
|
this.item = item;
|
||||||
|
this.form.setValue({
|
||||||
|
name: this.item.name || '',
|
||||||
|
prefix: this.item.prefix,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.nameElement !== undefined) {
|
||||||
|
this.nameElement.nativeElement.focus();
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
save() {
|
||||||
|
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||||
|
() => {
|
||||||
|
this.toaster.show('Success', '');
|
||||||
|
this.router.navigateByUrl('/case-sources');
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
this.toaster.show('Error', error);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete() {
|
||||||
|
this.ser.delete(this.item.id as string).subscribe(
|
||||||
|
() => {
|
||||||
|
this.toaster.show('Success', '');
|
||||||
|
this.router.navigateByUrl('/case-sources');
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
this.toaster.show('Error', error);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmDelete(): void {
|
||||||
|
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||||
|
width: '250px',
|
||||||
|
data: { title: 'Delete Case Source?', content: 'Are you sure? This cannot be undone.' },
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||||
|
if (result) {
|
||||||
|
this.delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getItem(): CaseSource {
|
||||||
|
const formModel = this.form.value;
|
||||||
|
this.item.name = formModel.name;
|
||||||
|
this.item.prefix = formModel.prefix;
|
||||||
|
return this.item;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { inject, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CaseSourceListResolver } from './case-source-list-resolver.service';
|
||||||
|
|
||||||
|
describe('CaseSourceListResolverService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [CaseSourceListResolver],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([CaseSourceListResolver], (service: CaseSourceListResolver) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Resolve } from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
|
||||||
|
import { CaseSource } from '../core/case-source';
|
||||||
|
|
||||||
|
import { CaseSourceService } from './case-source.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class CaseSourceListResolver implements Resolve<CaseSource[]> {
|
||||||
|
constructor(private ser: CaseSourceService) {}
|
||||||
|
|
||||||
|
resolve(): Observable<CaseSource[]> {
|
||||||
|
return this.ser.list();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { DataSource } from '@angular/cdk/collections';
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
|
import { CaseSource } from '../../core/case-source';
|
||||||
|
|
||||||
|
export class CaseSourceListDataSource extends DataSource<CaseSource> {
|
||||||
|
constructor(public data: CaseSource[]) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(): Observable<CaseSource[]> {
|
||||||
|
return observableOf(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<mat-card>
|
||||||
|
<mat-card-title-group>
|
||||||
|
<mat-card-title>Case Sources</mat-card-title>
|
||||||
|
<a mat-button [routerLink]="['/case-sources', 'new']">
|
||||||
|
<mat-icon>add_box</mat-icon>
|
||||||
|
Add
|
||||||
|
</a>
|
||||||
|
</mat-card-title-group>
|
||||||
|
<mat-card-content>
|
||||||
|
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||||
|
<!-- Name Column -->
|
||||||
|
<ng-container matColumnDef="name">
|
||||||
|
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let row"
|
||||||
|
><a [routerLink]="['/case-sources', row.id]">{{ row.name }}</a></mat-cell
|
||||||
|
>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Prefix Column -->
|
||||||
|
<ng-container matColumnDef="prefix">
|
||||||
|
<mat-header-cell *matHeaderCellDef>Prefix</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let row">{{ row.prefix }}</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||||
|
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||||
|
</mat-table>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CaseSourceListComponent } from './case-source-list.component';
|
||||||
|
|
||||||
|
describe('CaseSourceListComponent', () => {
|
||||||
|
let component: CaseSourceListComponent;
|
||||||
|
let fixture: ComponentFixture<CaseSourceListComponent>;
|
||||||
|
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [CaseSourceListComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(CaseSourceListComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should compile', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
import { CaseSource } from '../../core/case-source';
|
||||||
|
|
||||||
|
import { CaseSourceListDataSource } from './case-source-list-datasource';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-case-source-list',
|
||||||
|
templateUrl: './case-source-list.component.html',
|
||||||
|
styleUrls: ['./case-source-list.component.css'],
|
||||||
|
})
|
||||||
|
export class CaseSourceListComponent implements OnInit {
|
||||||
|
list: CaseSource[] = [];
|
||||||
|
dataSource: CaseSourceListDataSource = new CaseSourceListDataSource(this.list);
|
||||||
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||||
|
displayedColumns = ['name', 'prefix'];
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.route.data.subscribe((value) => {
|
||||||
|
const data = value as { list: CaseSource[] };
|
||||||
|
this.list = data.list;
|
||||||
|
});
|
||||||
|
this.dataSource = new CaseSourceListDataSource(this.list);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { inject, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CaseSourceResolver } from './case-source-resolver.service';
|
||||||
|
|
||||||
|
describe('CaseSourceResolver', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [CaseSourceResolver],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([CaseSourceResolver], (service: CaseSourceResolver) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
|
||||||
|
import { CaseSource } from '../core/case-source';
|
||||||
|
|
||||||
|
import { CaseSourceService } from './case-source.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class CaseSourceResolver implements Resolve<CaseSource> {
|
||||||
|
constructor(private ser: CaseSourceService) {}
|
||||||
|
|
||||||
|
resolve(route: ActivatedRouteSnapshot): Observable<CaseSource> {
|
||||||
|
const id = route.paramMap.get('id');
|
||||||
|
return this.ser.get(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { inject, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CaseSourceService } from './case-source.service';
|
||||||
|
|
||||||
|
describe('CaseSourceService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [CaseSourceService],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([CaseSourceService], (service: CaseSourceService) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
import { catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { CaseSource } from '../core/case-source';
|
||||||
|
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||||
|
|
||||||
|
const httpOptions = {
|
||||||
|
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||||
|
};
|
||||||
|
const url = '/api/case-sources';
|
||||||
|
const serviceName = 'CaseSourceService';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class CaseSourceService {
|
||||||
|
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||||
|
|
||||||
|
get(id: string | null): Observable<CaseSource> {
|
||||||
|
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||||
|
return this.http
|
||||||
|
.get<CaseSource>(getUrl)
|
||||||
|
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<CaseSource>;
|
||||||
|
}
|
||||||
|
|
||||||
|
list(): Observable<CaseSource[]> {
|
||||||
|
return this.http
|
||||||
|
.get<CaseSource[]>(`${url}/list`)
|
||||||
|
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<CaseSource[]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
save(caseSource: CaseSource): Observable<CaseSource> {
|
||||||
|
return this.http
|
||||||
|
.post<CaseSource>(url, caseSource, httpOptions)
|
||||||
|
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<CaseSource>;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(caseSource: CaseSource): Observable<CaseSource> {
|
||||||
|
return this.http
|
||||||
|
.put<CaseSource>(`${url}/${caseSource.id}`, caseSource, httpOptions)
|
||||||
|
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<CaseSource>;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveOrUpdate(caseSource: CaseSource): Observable<CaseSource> {
|
||||||
|
if (!caseSource.id) {
|
||||||
|
return this.save(caseSource);
|
||||||
|
}
|
||||||
|
return this.update(caseSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: string): Observable<CaseSource> {
|
||||||
|
return this.http
|
||||||
|
.delete<CaseSource>(`${url}/${id}`, httpOptions)
|
||||||
|
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<CaseSource>;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { CaseSourcesRoutingModule } from './case-sources-routing.module';
|
||||||
|
|
||||||
|
describe('CasesRoutingModule', () => {
|
||||||
|
let caseSourcesRoutingModule: CaseSourcesRoutingModule;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
caseSourcesRoutingModule = new CaseSourcesRoutingModule();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(caseSourcesRoutingModule).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
|
import { AuthGuard } from '../auth/auth-guard.service';
|
||||||
|
|
||||||
|
import { CaseSourceDetailComponent } from './case-source-detail/case-source-detail.component';
|
||||||
|
import { CaseSourceListResolver } from './case-source-list-resolver.service';
|
||||||
|
import { CaseSourceListComponent } from './case-source-list/case-source-list.component';
|
||||||
|
import { CaseSourceResolver } from './case-source-resolver.service';
|
||||||
|
|
||||||
|
const caseSourcesRoutes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: CaseSourceListComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
data: {
|
||||||
|
permission: 'Case Sources',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
list: CaseSourceListResolver,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'new',
|
||||||
|
component: CaseSourceDetailComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
data: {
|
||||||
|
permission: 'Case Sources',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
item: CaseSourceResolver,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: ':id',
|
||||||
|
component: CaseSourceDetailComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
data: {
|
||||||
|
permission: 'Case Sources',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
item: CaseSourceResolver,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [CommonModule, RouterModule.forChild(caseSourcesRoutes)],
|
||||||
|
exports: [RouterModule],
|
||||||
|
providers: [CaseSourceListResolver, CaseSourceResolver],
|
||||||
|
})
|
||||||
|
export class CaseSourcesRoutingModule {}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { CaseSourcesModule } from './case-sources.module';
|
||||||
|
|
||||||
|
describe('CaseSourcesModule', () => {
|
||||||
|
let caseSourcesModule: CaseSourcesModule;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
caseSourcesModule = new CaseSourcesModule();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(caseSourcesModule).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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 { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||||
|
import { MatTableModule } from '@angular/material/table';
|
||||||
|
|
||||||
|
import { CaseSourceDetailComponent } from './case-source-detail/case-source-detail.component';
|
||||||
|
import { CaseSourceListComponent } from './case-source-list/case-source-list.component';
|
||||||
|
import { CaseSourcesRoutingModule } from './case-sources-routing.module';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
CdkTableModule,
|
||||||
|
FlexLayoutModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatCardModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatProgressSpinnerModule,
|
||||||
|
MatTableModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
CaseSourcesRoutingModule,
|
||||||
|
],
|
||||||
|
declarations: [CaseSourceListComponent, CaseSourceDetailComponent],
|
||||||
|
})
|
||||||
|
export class CaseSourcesModule {}
|
||||||
@@ -13,6 +13,6 @@ export class CaseListResolver implements Resolve<Case[]> {
|
|||||||
constructor(private ser: CaseService) {}
|
constructor(private ser: CaseService) {}
|
||||||
|
|
||||||
resolve(): Observable<Case[]> {
|
resolve(): Observable<Case[]> {
|
||||||
return this.ser.list();
|
return this.ser.list(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,47 @@
|
|||||||
import { DataSource } from '@angular/cdk/collections';
|
import { DataSource } from '@angular/cdk/collections';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import {merge, Observable, of as observableOf} from 'rxjs';
|
||||||
|
|
||||||
import { Case } from '../../core/case';
|
import { Case } from '../../core/case';
|
||||||
|
import {MatPaginator, PageEvent} from "@angular/material/paginator";
|
||||||
|
import {EventEmitter} from "@angular/core";
|
||||||
|
import {map, tap} from "rxjs/operators";
|
||||||
|
|
||||||
export class CaseListDataSource extends DataSource<Case> {
|
export class CaseListDataSource extends DataSource<Case> {
|
||||||
constructor(public data: Case[]) {
|
private dataValues: Case[] = [];
|
||||||
|
private data: Observable<Case[]> = new Observable<Case[]>();
|
||||||
|
constructor(public d: Observable<Case[]>, private paginator?: MatPaginator) {
|
||||||
super();
|
super();
|
||||||
|
this.data = d.pipe(tap(x=> this.dataValues = x));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(): Observable<Case[]> {
|
connect(): Observable<Case[]> {
|
||||||
return observableOf(this.data);
|
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() {}
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,24 @@
|
|||||||
</a>
|
</a>
|
||||||
</mat-card-title-group>
|
</mat-card-title-group>
|
||||||
<mat-card-content>
|
<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>
|
||||||
|
<mat-label>Case Source</mat-label>
|
||||||
|
<mat-select placeholder="Case Source" formControlName="caseSource">
|
||||||
|
<mat-option *ngFor="let cs of caseSources" [value]="cs.id">
|
||||||
|
{{ cs.name }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||||
<!-- Office File Number Column -->
|
<!-- Office File Number Column -->
|
||||||
<ng-container matColumnDef="officeFileNumber">
|
<ng-container matColumnDef="officeFileNumber">
|
||||||
@@ -93,5 +111,13 @@
|
|||||||
<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>
|
||||||
|
<mat-paginator
|
||||||
|
#paginator
|
||||||
|
[length]="0"
|
||||||
|
[pageIndex]="0"
|
||||||
|
[pageSize]="10"
|
||||||
|
[pageSizeOptions]="[10, 25, 50, 100, 250]"
|
||||||
|
>
|
||||||
|
</mat-paginator>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
import { Case } from '../../core/case';
|
import { Case } from '../../core/case';
|
||||||
|
|
||||||
import { CaseListDataSource } from './case-list-datasource';
|
import { CaseListDataSource } from './case-list-datasource';
|
||||||
|
import {CaseSource} from "../../core/case-source";
|
||||||
|
import {FormBuilder, FormControl, FormGroup} from "@angular/forms";
|
||||||
|
import {distinctUntilChanged, startWith, switchMap, tap} from "rxjs/operators";
|
||||||
|
import {CaseService} from "../case.service";
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import {MatPaginator} from "@angular/material/paginator";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-case-list',
|
selector: 'app-case-list',
|
||||||
@@ -11,7 +17,10 @@ import { CaseListDataSource } from './case-list-datasource';
|
|||||||
styleUrls: ['./case-list.component.css'],
|
styleUrls: ['./case-list.component.css'],
|
||||||
})
|
})
|
||||||
export class CaseListComponent implements OnInit {
|
export class CaseListComponent implements OnInit {
|
||||||
list: Case[] = [];
|
@ViewChild(MatPaginator, { static: true }) paginator?: MatPaginator;
|
||||||
|
form: FormGroup;
|
||||||
|
caseSources: CaseSource[] = [];
|
||||||
|
list: Observable<Case[]> = new Observable<Case[]>();
|
||||||
dataSource: CaseListDataSource = new CaseListDataSource(this.list);
|
dataSource: CaseListDataSource = new CaseListDataSource(this.list);
|
||||||
/** 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 = [
|
||||||
@@ -30,13 +39,27 @@ export class CaseListComponent implements OnInit {
|
|||||||
'lowerCourtCaseNumber',
|
'lowerCourtCaseNumber',
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute) {}
|
constructor(private route: ActivatedRoute, private fb: FormBuilder, private ser: CaseService) {
|
||||||
|
// Create form
|
||||||
|
this.form = this.fb.group({
|
||||||
|
caseSource: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.data.subscribe((value) => {
|
this.route.data.subscribe((value) => {
|
||||||
const data = value as { list: Case[] };
|
const data = value as { list: Case[]; caseSources: CaseSource[] };
|
||||||
this.list = data.list;
|
this.caseSources = data.caseSources;
|
||||||
|
this.list = observableOf(data.list);
|
||||||
|
|
||||||
|
this.list = (this.form.get('caseSource') as FormControl).valueChanges.pipe(
|
||||||
|
startWith(''),
|
||||||
|
distinctUntilChanged(),
|
||||||
|
switchMap((x) => this.ser.list(x)),
|
||||||
|
tap(x=>console.log(x))
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
this.dataSource = new CaseListDataSource(this.list);
|
this.dataSource = new CaseListDataSource(this.list, this.paginator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,10 @@ export class CaseService {
|
|||||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Case>;
|
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Case>;
|
||||||
}
|
}
|
||||||
|
|
||||||
list(): Observable<Case[]> {
|
list(caseSource: string | null): Observable<Case[]> {
|
||||||
|
const listUrl: string = caseSource === null ? `${url}/list` : `${url}/list/${caseSource}`;
|
||||||
return this.http
|
return this.http
|
||||||
.get<Case[]>(`${url}/list`)
|
.get<Case[]>(listUrl)
|
||||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Case[]>;
|
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Case[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { CaseDetailComponent } from './case-detail/case-detail.component';
|
|||||||
import { CaseListResolver } from './case-list-resolver.service';
|
import { CaseListResolver } from './case-list-resolver.service';
|
||||||
import { CaseListComponent } from './case-list/case-list.component';
|
import { CaseListComponent } from './case-list/case-list.component';
|
||||||
import { CaseResolver } from './case-resolver.service';
|
import { CaseResolver } from './case-resolver.service';
|
||||||
|
import {CaseSourceListResolver} from "../case-sources/case-source-list-resolver.service";
|
||||||
|
|
||||||
const advocatesRoutes: Routes = [
|
const advocatesRoutes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,7 @@ const advocatesRoutes: Routes = [
|
|||||||
permission: 'Cases',
|
permission: 'Cases',
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
caseSources: CaseSourceListResolver,
|
||||||
list: CaseListResolver,
|
list: CaseListResolver,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { MatTableModule } from '@angular/material/table';
|
|||||||
import { CaseDetailComponent } from './case-detail/case-detail.component';
|
import { CaseDetailComponent } from './case-detail/case-detail.component';
|
||||||
import { CaseListComponent } from './case-list/case-list.component';
|
import { CaseListComponent } from './case-list/case-list.component';
|
||||||
import { CasesRoutingModule } from './cases-routing.module';
|
import { CasesRoutingModule } from './cases-routing.module';
|
||||||
|
import {MatPaginatorModule} from "@angular/material/paginator";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -29,6 +30,7 @@ import { CasesRoutingModule } from './cases-routing.module';
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
CasesRoutingModule,
|
CasesRoutingModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
|
MatPaginatorModule,
|
||||||
],
|
],
|
||||||
declarations: [CaseListComponent, CaseDetailComponent],
|
declarations: [CaseListComponent, CaseDetailComponent],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export class CaseSource {
|
||||||
|
id: string | undefined;
|
||||||
|
name: string;
|
||||||
|
prefix: string;
|
||||||
|
|
||||||
|
public constructor(init?: Partial<CaseSource>) {
|
||||||
|
this.id = undefined;
|
||||||
|
this.name = '';
|
||||||
|
this.prefix = '';
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<mat-menu #mastersMenu="matMenu">
|
<mat-menu #mastersMenu="matMenu">
|
||||||
<a mat-menu-item routerLink="/acts">Acts</a>
|
<a mat-menu-item routerLink="/acts">Acts</a>
|
||||||
<a mat-menu-item routerLink="/advocates">Advocates</a>
|
<a mat-menu-item routerLink="/advocates">Advocates</a>
|
||||||
|
<a mat-menu-item routerLink="/case-sources">Case Sources</a>
|
||||||
<a mat-menu-item routerLink="/case-types">Case Types</a>
|
<a mat-menu-item routerLink="/case-types">Case Types</a>
|
||||||
<a mat-menu-item routerLink="/contacts">Contacts</a>
|
<a mat-menu-item routerLink="/contacts">Contacts</a>
|
||||||
<a mat-menu-item routerLink="/courts">Courts</a>
|
<a mat-menu-item routerLink="/courts">Courts</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user