Feature: Case Source to filter the cases using a select.

Fix: Import cases was flipping court status and office status
This commit is contained in:
2021-01-10 08:03:36 +05:30
parent 0ac788dffd
commit 57874daf52
29 changed files with 1116 additions and 829 deletions

View File

@ -18,6 +18,10 @@ const routes: Routes = [
path: 'case-types',
loadChildren: () => import('./case-types/case-types.module').then((mod) => mod.CaseTypesModule),
},
{
path: 'cases',
loadChildren: () => import('./cases/cases.module').then((mod) => mod.CasesModule),
},
{
path: 'contacts',
loadChildren: () => import('./contacts/contacts.module').then((mod) => mod.ContactsModule),

View File

@ -5,9 +5,15 @@ import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { distinctUntilChanged, startWith, switchMap, tap } from 'rxjs/operators';
import { Act } from '../../core/act';
import { Case } from '../../core/case';
import { CaseType } from '../../core/case-type';
import { Court } from '../../core/court';
import { CourtStatus } from '../../core/court-status';
import { Department } from '../../core/department';
import { Nature } from '../../core/nature';
import { Office } from '../../core/office';
import { OfficeStatus } from '../../core/office-status';
import { ToasterService } from '../../core/toaster.service';
import { OfficeService } from '../../offices/office.service';
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
@ -57,13 +63,36 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
showItem(item: Case) {
this.item = item;
this.form.setValue({
name: this.item.name,
mobile: this.item.mobile,
landline: this.item.landline,
email: this.item.email,
address: this.item.address,
officeFileNumber: this.item.officeFileNumber,
courtCaseNumber: this.item.courtCaseNumber,
year: this.item.year,
title: this.item.title,
docketNumber: this.item.docketNumber,
receiptDate: this.item.receiptDate,
limitationDate: this.item.limitationDate,
filingDate: this.item.filingDate,
appearOnBehalfOf: this.item.appearOnBehalfOf,
questionOfLaw: this.item.questionOfLaw,
aorName: this.item.aorName,
opposingCouncilAor: this.item.opposingCouncilAor,
opposingCouncilDetail: this.item.opposingCouncilDetail,
lowerCourtCaseNumber: this.item.lowerCourtCaseNumber,
dateOfImpugnedJudgement: this.item.dateOfImpugnedJudgement,
briefDescription: this.item.briefDescription,
remarks: this.item.remarks,
slpCounter: this.item.slpCounter,
contactDetail: this.item.contactDetail,
caseConnectedWith: this.item.caseConnectedWith,
bunchCases: this.item.bunchCases,
court: this.item.court ? this.item.court.id : '',
department: this.item.department ? this.item.department.id : '',
office: this.item.office ? this.item.office.id : '',
caseType: this.item.caseType ? this.item.caseType.id : '',
act: this.item.act ? this.item.act.id : '',
nature: this.item.nature ? this.item.nature.id : '',
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 : ''),
@ -119,11 +148,36 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
getItem(): Case {
const formModel = this.form.value;
this.item.name = formModel.name;
this.item.mobile = formModel.mobile;
this.item.landline = formModel.landline;
this.item.email = formModel.email;
this.item.address = formModel.address;
this.item.officeFileNumber = formModel.officeFileNumber;
this.item.courtCaseNumber = formModel.courtCaseNumber;
this.item.year = formModel.year;
this.item.title = formModel.title;
this.item.docketNumber = formModel.docketNumber;
this.item.receiptDate = formModel.receiptDate;
this.item.limitationDate = formModel.limitationDate;
this.item.filingDate = formModel.filingDate;
this.item.appearOnBehalfOf = formModel.appearOnBehalfOf;
this.item.questionOfLaw = formModel.questionOfLaw;
this.item.aorName = formModel.aorName;
this.item.opposingCouncilAor = formModel.opposingCouncilAor;
this.item.opposingCouncilDetail = formModel.opposingCouncilDetail;
this.item.lowerCourtCaseNumber = formModel.lowerCourtCaseNumber;
this.item.dateOfImpugnedJudgement = formModel.dateOfImpugnedJudgement;
this.item.briefDescription = formModel.briefDescription;
this.item.remarks = formModel.remarks;
this.item.slpCounter = formModel.slpCounter;
this.item.contactDetail = formModel.contactDetail;
this.item.caseConnectedWith = formModel.caseConnectedWith;
this.item.bunchCases = formModel.bunchCases;
if (formModel.court === undefined || formModel.court === '') {
this.item.court = undefined;
} else {
if (this.item.court === null || this.item.court === undefined) {
this.item.court = new Court();
}
this.item.court.id = formModel.court;
}
if (formModel.department === undefined || formModel.department === '') {
this.item.department = undefined;
} else {
@ -140,6 +194,46 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
}
this.item.office.id = formModel.office;
}
if (formModel.caseType === undefined || formModel.caseType === '') {
this.item.caseType = undefined;
} else {
if (this.item.caseType === null || this.item.caseType === undefined) {
this.item.caseType = new CaseType();
}
this.item.caseType.id = formModel.caseType;
}
if (formModel.act === undefined || formModel.act === '') {
this.item.act = undefined;
} else {
if (this.item.act === null || this.item.act === undefined) {
this.item.act = new Act();
}
this.item.act.id = formModel.act;
}
if (formModel.nature === undefined || formModel.nature === '') {
this.item.nature = undefined;
} else {
if (this.item.nature === null || this.item.nature === undefined) {
this.item.nature = new Nature();
}
this.item.nature.id = formModel.nature;
}
if (formModel.officeStatus === undefined || formModel.officeStatus === '') {
this.item.officeStatus = undefined;
} else {
if (this.item.officeStatus === null || this.item.officeStatus === undefined) {
this.item.officeStatus = new OfficeStatus();
}
this.item.officeStatus.id = formModel.officeStatus;
}
if (formModel.courtStatus === undefined || formModel.courtStatus === '') {
this.item.courtStatus = undefined;
} else {
if (this.item.courtStatus === null || this.item.courtStatus === undefined) {
this.item.courtStatus = new CourtStatus();
}
this.item.courtStatus.id = formModel.courtStatus;
}
return this.item;
}
}

View File

@ -8,45 +8,88 @@
</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>
<!-- 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.name }}</a></mat-cell
><a [routerLink]="['/cases', row.id]">{{ row.officeFileNumber }}</a></mat-cell
>
</ng-container>
<!-- Mobile Column -->
<ng-container matColumnDef="mobile">
<mat-header-cell *matHeaderCellDef>Mobile</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.mobile }}</mat-cell>
<!-- 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>
<!-- Landline Column -->
<ng-container matColumnDef="landline">
<mat-header-cell *matHeaderCellDef>Landline</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.landline }}</mat-cell>
<!-- Title 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>
<!-- Email Column -->
<ng-container matColumnDef="email">
<mat-header-cell *matHeaderCellDef>Email</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.email }}</mat-cell>
<!-- 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>
<!-- Address Column -->
<ng-container matColumnDef="address">
<!-- Court Column -->
<ng-container matColumnDef="court">
<mat-header-cell *matHeaderCellDef>Forum</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.court?.name }}</mat-cell>
</ng-container>
<!-- Appear On Behalf Of Column -->
<ng-container matColumnDef="appearOnBehalfOf">
<mat-header-cell *matHeaderCellDef>Address</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.address }}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.appearOnBehalfOf }}</mat-cell>
</ng-container>
<!-- Case Column -->
<!-- Next Hearing Date Column -->
<ng-container matColumnDef="nextHearingDate">
<mat-header-cell *matHeaderCellDef>Next Hearing Date</mat-header-cell>
<mat-cell *matCellDef="let row">Not Implemented</mat-cell>
</ng-container>
<!-- Court Satus Column -->
<ng-container matColumnDef="courtStatus">
<mat-header-cell *matHeaderCellDef>Court Status</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.courtStatus?.name }}</mat-cell>
</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 -->
<ng-container matColumnDef="remarks">
<mat-header-cell *matHeaderCellDef>Remarks</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.remarks }}</mat-cell>
</ng-container>
<!-- Receipt Date Column -->
<ng-container matColumnDef="receiptDate">
<mat-header-cell *matHeaderCellDef>Receipt Date</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.receiptDate }}</mat-cell>
</ng-container>
<!-- Office Column -->
<ng-container matColumnDef="office">
<mat-header-cell *matHeaderCellDef>Address</mat-header-cell>
<mat-header-cell *matHeaderCellDef>Office</mat-header-cell>
<mat-cell *matCellDef="let row"
>{{ row.department?.name }} / {{ row.office?.name }}</mat-cell
>
</ng-container>
<!-- Lower Court Case Number Column -->
<ng-container matColumnDef="lowerCourtCaseNumber">
<mat-header-cell *matHeaderCellDef>Lower Court Case Number</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.lowerCourtCaseNumber }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
</mat-table>

View File

@ -14,7 +14,21 @@ export class CaseListComponent implements OnInit {
list: Case[] = [];
dataSource: CaseListDataSource = new CaseListDataSource(this.list);
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name'];
displayedColumns = [
'officeFileNumber',
'title',
'courtCaseNumber',
'caseConnectedWith',
'court',
'appearOnBehalfOf',
'nextHearingDate',
'courtStatus',
'officeStatus',
'remarks',
'receiptDate',
'office',
'lowerCourtCaseNumber',
];
constructor(private route: ActivatedRoute) {}

View File

@ -3,8 +3,8 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from '../core/error-logger.service';
import { Case } from '../core/case';
import { ErrorLoggerService } from '../core/error-logger.service';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
@ -31,23 +31,23 @@ export class CaseService {
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Case[]>;
}
save(case: Case): Observable<Case> {
save(case_: Case): Observable<Case> {
return this.http
.post<Case>(url, case, httpOptions)
.post<Case>(url, case_, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<Case>;
}
update(case: Case): Observable<Case> {
update(case_: Case): Observable<Case> {
return this.http
.put<Case>(`${url}/${case.id}`, case, httpOptions)
.put<Case>(`${url}/${case_.id}`, case_, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<Case>;
}
saveOrUpdate(case: Case): Observable<Case> {
if (!case.id) {
return this.save(case);
saveOrUpdate(case_: Case): Observable<Case> {
if (!case_.id) {
return this.save(case_);
}
return this.update(case);
return this.update(case_);
}
delete(id: string): Observable<Case> {

View File

@ -42,7 +42,7 @@
<!-- Contact Column -->
<ng-container matColumnDef="office">
<mat-header-cell *matHeaderCellDef>Address</mat-header-cell>
<mat-header-cell *matHeaderCellDef>Office</mat-header-cell>
<mat-cell *matCellDef="let row"
>{{ row.department?.name }} / {{ row.office?.name }}</mat-cell
>

View File

@ -1,220 +1,3 @@
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('customers')"
[routerLink]="['/', 'guest-book']"
>
<h3 class="item-name">Guest Book</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('sales')"
[routerLink]="['/', 'sales']"
>
<h3 class="item-name">Sales</h3>
</mat-card>
</div>
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('cashier-report')"
[routerLink]="['/', 'cashier-report']"
>
<h3 class="item-name">Cashier Report</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('sale-report')"
[routerLink]="['/', 'sale-report']"
>
<h3 class="item-name">Sale Report</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('tax-report')"
[routerLink]="['/', 'tax-report']"
>
<h3 class="item-name">Tax Report</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('product-sale-report')"
[routerLink]="['/', 'product-sale-report']"
>
<h3 class="item-name">Product Sale Report</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('bill-settlement-report')"
[routerLink]="['/', 'bill-settlement-report']"
>
<h3 class="item-name">Bill Settlement Report</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('beer-sale-report')"
[routerLink]="['/', 'beer-sale-report']"
>
<h3 class="item-name">Beer Sale Report</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('discount-report')"
[routerLink]="['/', 'discount-report']"
>
<h3 class="item-name">Discount Report</h3>
</mat-card>
</div>
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('products')"
[routerLink]="['/', 'products']"
>
<h3 class="item-name">Products</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('products')"
[routerLink]="['/', 'update-product-prices']"
>
<h3 class="item-name">Update Product Prices</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('products')"
[routerLink]="['/', 'product-updates-report']"
>
<h3 class="item-name">Product Updates Report</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('modifiers')"
[routerLink]="['/', 'modifiers']"
>
<h3 class="item-name">Modifiers</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('modifiers')"
[routerLink]="['/', 'modifier-categories']"
>
<h3 class="item-name">Modifier Categories</h3>
</mat-card>
</div>
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('sections')"
[routerLink]="['/', 'tables']"
>
<h3 class="item-name">Tables</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('sections')"
[routerLink]="['/', 'sections']"
>
<h3 class="item-name">Sections</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('products')"
[routerLink]="['/', 'menu-categories']"
>
<h3 class="item-name">Menu Categories</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('products')"
[routerLink]="['/', 'sale-categories']"
>
<h3 class="item-name">Sale Categories</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('taxes')"
[routerLink]="['/', 'taxes']"
>
<h3 class="item-name">Taxes</h3>
</mat-card>
</div>
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('users')"
[routerLink]="['/', 'roles']"
>
<h3 class="item-name">Roles</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('users')"
[routerLink]="['/', 'users']"
>
<h3 class="item-name">Users</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('owner')"
[routerLink]="['/', 'header-footer']"
>
<h3 class="item-name">Header / Footer</h3>
</mat-card>
<mat-card
fxLayout="column"
class="square-button"
matRipple
*ngIf="auth.allowed('owner')"
[routerLink]="['/', 'settle-options']"
>
<h3 class="item-name">Settle Options</h3>
</mat-card>
</div>
<footer class="footer">
<p>Backend: v{{ auth.user?.ver }} / Frontend: v{{ version }}</p>
</footer>

View File

@ -3,6 +3,7 @@
<mat-icon>home</mat-icon>
Home
</a>
<a mat-button [routerLink]="['/cases']"> Cases </a>
<mat-menu #mastersMenu="matMenu">
<a mat-menu-item routerLink="/acts">Acts</a>
<a mat-menu-item routerLink="/advocates">Advocates</a>