Fix: Proper date handling
This commit is contained in:
parent
0233e7145b
commit
15f04b4cf1
@ -1,8 +1,8 @@
|
|||||||
import * as moment from 'moment';
|
|
||||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import * as moment from 'moment';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { distinctUntilChanged, startWith, switchMap } from 'rxjs/operators';
|
import { distinctUntilChanged, startWith, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -112,16 +112,22 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
|||||||
year: this.item.year,
|
year: this.item.year,
|
||||||
title: this.item.title,
|
title: this.item.title,
|
||||||
docketNumber: this.item.docketNumber,
|
docketNumber: this.item.docketNumber,
|
||||||
receiptDate: moment(this.item.receiptDate, 'DD-MMM-YYYY').toDate(),
|
receiptDate: this.item.receiptDate
|
||||||
limitationDate: moment(this.item.limitationDate, 'DD-MMM-YYYY').toDate(),
|
? moment(this.item.receiptDate, 'DD-MMM-YYYY').toDate()
|
||||||
filingDate: moment(this.item.filingDate, 'DD-MMM-YYYY').toDate(),
|
: '',
|
||||||
|
limitationDate: this.item.limitationDate
|
||||||
|
? moment(this.item.limitationDate, 'DD-MMM-YYYY').toDate()
|
||||||
|
: '',
|
||||||
|
filingDate: this.item.filingDate ? moment(this.item.filingDate, 'DD-MMM-YYYY').toDate() : '',
|
||||||
appearOnBehalfOf: this.item.appearOnBehalfOf,
|
appearOnBehalfOf: this.item.appearOnBehalfOf,
|
||||||
questionOfLaw: this.item.questionOfLaw,
|
questionOfLaw: this.item.questionOfLaw,
|
||||||
aorName: this.item.aorName,
|
aorName: this.item.aorName,
|
||||||
opposingCouncilAor: this.item.opposingCouncilAor,
|
opposingCouncilAor: this.item.opposingCouncilAor,
|
||||||
opposingCouncilDetail: this.item.opposingCouncilDetail,
|
opposingCouncilDetail: this.item.opposingCouncilDetail,
|
||||||
lowerCourtCaseNumber: this.item.lowerCourtCaseNumber,
|
lowerCourtCaseNumber: this.item.lowerCourtCaseNumber,
|
||||||
dateOfImpugnedJudgement: moment(this.item.dateOfImpugnedJudgement, 'DD-MMM-YYYY').toDate(),
|
dateOfImpugnedJudgement: this.item.dateOfImpugnedJudgement
|
||||||
|
? moment(this.item.dateOfImpugnedJudgement, 'DD-MMM-YYYY').toDate()
|
||||||
|
: '',
|
||||||
briefDescription: this.item.briefDescription,
|
briefDescription: this.item.briefDescription,
|
||||||
remarks: this.item.remarks,
|
remarks: this.item.remarks,
|
||||||
slpCounter: this.item.slpCounter,
|
slpCounter: this.item.slpCounter,
|
||||||
@ -197,16 +203,35 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
|
|||||||
this.item.year = formModel.year;
|
this.item.year = formModel.year;
|
||||||
this.item.title = formModel.title;
|
this.item.title = formModel.title;
|
||||||
this.item.docketNumber = formModel.docketNumber;
|
this.item.docketNumber = formModel.docketNumber;
|
||||||
this.item.receiptDate = formModel.receiptDate;
|
if (formModel.receiptDate === '') {
|
||||||
this.item.limitationDate = formModel.limitationDate;
|
this.item.receiptDate = null;
|
||||||
this.item.filingDate = formModel.filingDate;
|
} else {
|
||||||
|
this.item.receiptDate = moment(formModel.receiptDate).format('DD-MMM-YYYY');
|
||||||
|
}
|
||||||
|
if (formModel.limitationDate === '') {
|
||||||
|
this.item.limitationDate = null;
|
||||||
|
} else {
|
||||||
|
this.item.limitationDate = moment(formModel.limitationDate).format('DD-MMM-YYYY');
|
||||||
|
}
|
||||||
|
console.log(formModel.filingDate);
|
||||||
|
if (formModel.filingDate === '') {
|
||||||
|
this.item.filingDate = null;
|
||||||
|
} else {
|
||||||
|
this.item.filingDate = moment(formModel.filingDate).format('DD-MMM-YYYY');
|
||||||
|
}
|
||||||
this.item.appearOnBehalfOf = formModel.appearOnBehalfOf;
|
this.item.appearOnBehalfOf = formModel.appearOnBehalfOf;
|
||||||
this.item.questionOfLaw = formModel.questionOfLaw;
|
this.item.questionOfLaw = formModel.questionOfLaw;
|
||||||
this.item.aorName = formModel.aorName;
|
this.item.aorName = formModel.aorName;
|
||||||
this.item.opposingCouncilAor = formModel.opposingCouncilAor;
|
this.item.opposingCouncilAor = formModel.opposingCouncilAor;
|
||||||
this.item.opposingCouncilDetail = formModel.opposingCouncilDetail;
|
this.item.opposingCouncilDetail = formModel.opposingCouncilDetail;
|
||||||
this.item.lowerCourtCaseNumber = formModel.lowerCourtCaseNumber;
|
this.item.lowerCourtCaseNumber = formModel.lowerCourtCaseNumber;
|
||||||
this.item.dateOfImpugnedJudgement = formModel.dateOfImpugnedJudgement;
|
if (formModel.dateOfImpugnedJudgement === '') {
|
||||||
|
this.item.dateOfImpugnedJudgement = null;
|
||||||
|
} else {
|
||||||
|
this.item.dateOfImpugnedJudgement = moment(formModel.dateOfImpugnedJudgement).format(
|
||||||
|
'DD-MMM-YYYY',
|
||||||
|
);
|
||||||
|
}
|
||||||
this.item.briefDescription = formModel.briefDescription;
|
this.item.briefDescription = formModel.briefDescription;
|
||||||
this.item.remarks = formModel.remarks;
|
this.item.remarks = formModel.remarks;
|
||||||
this.item.slpCounter = formModel.slpCounter;
|
this.item.slpCounter = formModel.slpCounter;
|
||||||
|
@ -24,7 +24,6 @@ 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';
|
||||||
|
|
||||||
|
|
||||||
export const MY_FORMATS = {
|
export const MY_FORMATS = {
|
||||||
parse: {
|
parse: {
|
||||||
dateInput: 'DD-MMM-YYYY',
|
dateInput: 'DD-MMM-YYYY',
|
||||||
|
@ -14,16 +14,16 @@ export class Case {
|
|||||||
year: string;
|
year: string;
|
||||||
title: string;
|
title: string;
|
||||||
docketNumber: string;
|
docketNumber: string;
|
||||||
receiptDate: string;
|
receiptDate: string | null;
|
||||||
limitationDate: string;
|
limitationDate: string | null;
|
||||||
filingDate: string;
|
filingDate: string | null;
|
||||||
appearOnBehalfOf: string;
|
appearOnBehalfOf: string;
|
||||||
questionOfLaw: string;
|
questionOfLaw: string;
|
||||||
aorName: string;
|
aorName: string;
|
||||||
opposingCouncilAor: string;
|
opposingCouncilAor: string;
|
||||||
opposingCouncilDetail: string;
|
opposingCouncilDetail: string;
|
||||||
lowerCourtCaseNumber: string;
|
lowerCourtCaseNumber: string;
|
||||||
dateOfImpugnedJudgement: string;
|
dateOfImpugnedJudgement: string | null;
|
||||||
briefDescription: string;
|
briefDescription: string;
|
||||||
remarks: string;
|
remarks: string;
|
||||||
slpCounter: string;
|
slpCounter: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user