Skip to content

Commit 1bd04fa

Browse files
committed
fix: TT-205 In safari browser don t work the date picker
1 parent 05fce31 commit 1bd04fa

File tree

8 files changed

+74
-23
lines changed

8 files changed

+74
-23
lines changed

angular.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"src/assets"
2525
],
2626
"styles": [
27+
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
2728
"node_modules/datatables.net-dt/css/jquery.dataTables.css",
2829
"node_modules/datatables.net-responsive-dt/css/responsive.dataTables.css",
2930
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
@@ -106,6 +107,7 @@
106107
"src/assets"
107108
],
108109
"styles": [
110+
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
109111
"src/styles.scss"
110112
],
111113
"scripts": []

package-lock.json

Lines changed: 45 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"@angular/compiler": "~10.2.2",
2121
"@angular/core": "~10.2.2",
2222
"@angular/forms": "~10.2.2",
23+
"@angular/material": "^11.2.3",
24+
"@angular/material-moment-adapter": "^11.2.9",
2325
"@angular/platform-browser": "~10.2.2",
2426
"@angular/platform-browser-dynamic": "~10.2.2",
2527
"@angular/router": "~10.2.2",

src/app/app.module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { StoreModule } from '@ngrx/store';
1111
import { EffectsModule } from '@ngrx/effects';
1212
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
1313
import { DragDropModule } from '@angular/cdk/drag-drop';
14-
14+
import { MatDatepickerModule } from '@angular/material/datepicker';
15+
import { MatInputModule } from '@angular/material/input';
16+
import { MatMomentDateModule } from '@angular/material-moment-adapter';
1517
import { NgxPaginationModule } from 'ngx-pagination';
1618
import { AutocompleteLibModule } from 'angular-ng-autocomplete';
1719

@@ -134,6 +136,9 @@ const maskConfig: Partial<IConfig> = {
134136
],
135137
imports: [
136138
NgxMaskModule.forRoot(maskConfig),
139+
MatInputModule,
140+
MatDatepickerModule,
141+
MatMomentDateModule,
137142
CommonModule,
138143
BrowserModule,
139144
BrowserAnimationsModule,

src/app/modules/shared/components/details-fields/details-fields.component.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
<label class="col-12 col-sm-2">Date in:</label>
8383
<div class="col-12 col-sm-4">
8484
<input
85+
matInput
8586
formControlName="start_date"
8687
id="start_date"
87-
type="date"
8888
class="form-control"
8989
aria-label="Small"
9090
aria-describedby="inputGroup-sizing-sm"
@@ -93,7 +93,11 @@
9393
(ngModelChange)="onStartDateChange($event)"
9494
[max]="getCurrentDate()"
9595
onkeydown="return false"
96+
(click)="datepickerStartDate.opened? datepickerStartDate.close() : datepickerStartDate.open()"
97+
(dateInput)="start_date.setValue($event.value.format('YYYY-MM-DD')) "
98+
[matDatepicker]="datepickerStartDate"
9699
/>
100+
<mat-datepicker #datepickerStartDate></mat-datepicker>
97101
</div>
98102

99103
<label class="col-12 col-sm-2">Time in:</label>
@@ -112,17 +116,21 @@
112116
<label class="col-12 col-sm-2">Date out:</label>
113117
<div class="col-12 col-sm-4">
114118
<input
119+
matInput
115120
formControlName="end_date"
116121
id="end_date"
117-
type="date"
118122
class="form-control"
119123
aria-label="Small"
120124
aria-describedby="inputGroup-sizing-sm"
121125
[class.is-invalid]="end_date.invalid && end_date.touched"
122126
required
123127
[max]="getCurrentDate()"
124128
onkeydown="return false"
129+
(click)="datepickerEndDate.opened? datepickerEndDate.close() : datepickerEndDate.open()"
130+
(dateInput)="end_date.setValue($event.value.format('YYYY-MM-DD')) "
131+
[matDatepicker]="datepickerEndDate"
125132
/>
133+
<mat-datepicker #datepickerEndDate></mat-datepicker>
126134
</div>
127135

128136
<label class="col-12 col-sm-2">Time out:</label>

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,14 @@ describe('DetailsFieldsComponent', () => {
489489
});
490490

491491
it('on get current date should return expected date', () => {
492-
const expectedDate = new Date().toISOString().split('T')[0];
492+
const expectedDate = moment(new Date()).format('YYYY-MM-DD');
493493

494494
expect(component.getCurrentDate()).toEqual(expectedDate);
495495
});
496496

497497
it('on the input with id #start_date we could get the id and max value', () => {
498498
fixture.detectChanges();
499-
const expectedDate = new Date().toISOString().split('T')[0];
499+
const expectedDate = moment(new Date()).format('YYYY-MM-DD');
500500
const startDateInput: HTMLInputElement = fixture.debugElement.
501501
nativeElement.querySelector(`input[id="start_date"],input[max="${component.getCurrentDate()}"]`);
502502

@@ -506,7 +506,7 @@ describe('DetailsFieldsComponent', () => {
506506

507507
it('on the input with id #end_date we could get the current Date ', () => {
508508
fixture.detectChanges();
509-
const expectedDate = new Date().toISOString().split('T')[0];
509+
const expectedDate = moment(new Date()).format('YYYY-MM-DD');
510510
const endDateInput = fixture.debugElement.nativeElement.querySelector('[id=end_date]');
511511

512512
expect(endDateInput.id).toEqual('end_date');

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
192192
}
193193

194194
getCurrentDate(): string {
195-
return new Date().toISOString().split('T')[0];
195+
return moment(new Date()).format('YYYY-MM-DD');
196196
}
197197

198198
get project_id() {

src/styles.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ body {
3030

3131
.timepicker-backdrop-overlay {
3232
z-index: 1100 !important;
33-
}
33+
}
34+
35+
.cdk-overlay-container {
36+
z-index: 1100 !important;
37+
}

0 commit comments

Comments
 (0)