RED-4243: Fixed dates difference
This commit is contained in:
parent
cd698f9eb6
commit
12f501a001
@ -18,6 +18,7 @@ import { TrashService } from '@services/entity-services/trash.service';
|
|||||||
import { ArchivedDossiersService } from '@services/dossiers/archived-dossiers.service';
|
import { ArchivedDossiersService } from '@services/dossiers/archived-dossiers.service';
|
||||||
import { DossierStatesMapService } from '@services/entity-services/dossier-states-map.service';
|
import { DossierStatesMapService } from '@services/entity-services/dossier-states-map.service';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import { dateWithoutTime } from '@utils/functions';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'redaction-edit-dossier-general-info',
|
selector: 'redaction-edit-dossier-general-info',
|
||||||
@ -110,7 +111,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
|||||||
async save(): EditDossierSaveResult {
|
async save(): EditDossierSaveResult {
|
||||||
let dueDate;
|
let dueDate;
|
||||||
if (this.hasDueDate) {
|
if (this.hasDueDate) {
|
||||||
dueDate = dayjs(this.form.get('dueDate').value).set('h', 0).set('m', 0).set('s', 0);
|
dueDate = dateWithoutTime(dayjs(this.form.get('dueDate').value));
|
||||||
}
|
}
|
||||||
const dossier = {
|
const dossier = {
|
||||||
...this.dossier,
|
...this.dossier,
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { DossierStats, IDossier } from '@red/domain';
|
|||||||
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
||||||
import { List } from '@iqser/common-ui';
|
import { List } from '@iqser/common-ui';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import { dateWithoutTime } from '@utils/functions';
|
||||||
|
|
||||||
const DUE_DATE_WARN_DAYS = 14;
|
const DUE_DATE_WARN_DAYS = 14;
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ export class DossierNameColumnComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get _dueDateDaysDiff(): number {
|
private get _dueDateDaysDiff(): number {
|
||||||
return dayjs(this.dossier.dueDate).get('date') - dayjs().get('date');
|
return dayjs(this.dossier.dueDate).diff(dateWithoutTime(dayjs()), 'day');
|
||||||
}
|
}
|
||||||
|
|
||||||
getDossierTemplateNameFor(dossierTemplateId: string): string {
|
getDossierTemplateNameFor(dossierTemplateId: string): string {
|
||||||
|
|||||||
@ -1,12 +1,6 @@
|
|||||||
import type { List } from '@iqser/common-ui';
|
import type { List } from '@iqser/common-ui';
|
||||||
import type { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
import type { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||||
|
import { Dayjs } from 'dayjs';
|
||||||
export function groupBy(xs: List<unknown>, key: string) {
|
|
||||||
return xs.reduce((rv, x) => {
|
|
||||||
(rv[x[key]] = rv[x[key]] || []).push(x);
|
|
||||||
return rv;
|
|
||||||
}, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hexToRgb(hex: string) {
|
export function hexToRgb(hex: string) {
|
||||||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
@ -24,7 +18,7 @@ export function getFirstRelevantTextPart(text: string, direction: 'FORWARD' | 'B
|
|||||||
let accumulator = '';
|
let accumulator = '';
|
||||||
const breakChars = [':', ' '];
|
const breakChars = [':', ' '];
|
||||||
|
|
||||||
const handle = i => {
|
const handle = (i: number) => {
|
||||||
const char = text[i];
|
const char = text[i];
|
||||||
if (breakChars.indexOf(char) >= 0) {
|
if (breakChars.indexOf(char) >= 0) {
|
||||||
spaceCount += 1;
|
spaceCount += 1;
|
||||||
@ -69,7 +63,7 @@ export function toNumber(str: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeBraces(str: any): string {
|
export function removeBraces(str: string): string {
|
||||||
return str.replace(/[{}]/g, '');
|
return str.replace(/[{}]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,3 +94,5 @@ export const byId = (id: string) => (annotation: AnnotationWrapper) => annotatio
|
|||||||
export function getLast<T>(list: List<T>) {
|
export function getLast<T>(list: List<T>) {
|
||||||
return list[list.length - 1];
|
return list[list.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const dateWithoutTime = (date: Dayjs) => date.set('h', 0).set('m', 0).set('s', 0).set('ms', 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user