Skip to content

Commit d389c96

Browse files
committed
fix for 384
1 parent 19c8b82 commit d389c96

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/app/date-picker/date-picker.component.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ export class DatePickerComponent implements OnChanges,
116116
hideStateHelper: boolean = false;
117117
_selected: Moment[] = [];
118118
inputValue: CalendarValue;
119-
inputValueType: ECalendarValue;
120119
isFocusedTrigger: boolean = false;
121120
_currentDateView: Moment;
122121
inputElementValue: string;
@@ -137,7 +136,7 @@ export class DatePickerComponent implements OnChanges,
137136
set selected(selected: Moment[]) {
138137
this._selected = selected;
139138
this.inputElementValue = (<string[]>this.utilsService
140-
.convertFromMomentArray(this.componentConfig.format, selected, ECalendarValue.StringArr))
139+
.convertFromMomentArray(this.componentConfig.format, selected, ECalendarValue.StringArr))
141140
.join(' | ');
142141
const val = this.processOnChangeCallback(selected);
143142
this.onChangeCallback(val, false);
@@ -250,7 +249,7 @@ export class DatePickerComponent implements OnChanges,
250249

251250
if (value || value === '') {
252251
this.selected = this.utilsService
253-
.convertToMomentArray(value, this.componentConfig.format, this.componentConfig.allowMultiSelect);
252+
.convertToMomentArray(value, this.componentConfig.format, this.componentConfig.allowMultiSelect);
254253
this.init();
255254
} else {
256255
this.selected = [];
@@ -264,7 +263,7 @@ export class DatePickerComponent implements OnChanges,
264263
}
265264

266265
onChangeCallback(_: any, changedByInput: boolean) {
267-
};
266+
}
268267

269268
registerOnTouched(fn: any): void {
270269
}
@@ -280,12 +279,12 @@ export class DatePickerComponent implements OnChanges,
280279
return this.utilsService.convertFromMomentArray(
281280
this.componentConfig.format,
282281
selected,
283-
this.componentConfig.returnedValueType || this.inputValueType
282+
this.componentConfig.returnedValueType || this.utilsService.getInputType(this.inputValue, this.componentConfig.allowMultiSelect)
284283
);
285284
}
286285
}
287286

288-
initValidators() {
287+
initValidators(): void {
289288
this.validateFn = this.utilsService.createValidator(
290289
{
291290
minDate: this.minDate,
@@ -296,13 +295,13 @@ export class DatePickerComponent implements OnChanges,
296295
this.onChangeCallback(this.processOnChangeCallback(this.selected), false);
297296
}
298297

299-
ngOnInit() {
298+
ngOnInit(): void {
300299
this.isInitialized = true;
301300
this.init();
302301
this.initValidators();
303302
}
304303

305-
ngOnChanges(changes: SimpleChanges) {
304+
ngOnChanges(changes: SimpleChanges): void {
306305
if (this.isInitialized) {
307306
const {minDate, maxDate, minTime, maxTime} = changes;
308307

@@ -314,15 +313,15 @@ export class DatePickerComponent implements OnChanges,
314313
}
315314
}
316315

317-
ngAfterViewInit() {
316+
ngAfterViewInit(): void {
318317
this.setElementPositionInDom();
319318
}
320319

321-
setDisabledState(isDisabled: boolean) {
320+
setDisabledState(isDisabled: boolean): void {
322321
this.disabled = isDisabled;
323322
}
324323

325-
setElementPositionInDom() {
324+
setElementPositionInDom(): void {
326325
this.calendarWrapper = <HTMLElement> this.calendarContainer.nativeElement;
327326
this.setInputElementContainer();
328327
this.popupElem = this.elemRef.nativeElement.querySelector('.dp-popup');
@@ -361,13 +360,12 @@ export class DatePickerComponent implements OnChanges,
361360
this.currentDateView = this.displayDate
362361
? this.utilsService.convertToMoment(this.displayDate, this.componentConfig.format).clone()
363362
: this.utilsService
364-
.getDefaultDisplayDate(
365-
this.currentDateView,
366-
this.selected,
367-
this.componentConfig.allowMultiSelect,
368-
this.componentConfig.min
369-
);
370-
this.inputValueType = this.utilsService.getInputType(this.inputValue, this.componentConfig.allowMultiSelect);
363+
.getDefaultDisplayDate(
364+
this.currentDateView,
365+
this.selected,
366+
this.componentConfig.allowMultiSelect,
367+
this.componentConfig.min
368+
);
371369
this.dayCalendarConfig = this.dayPickerService.getDayConfigService(this.componentConfig);
372370
this.dayTimeCalendarConfig = this.dayPickerService.getDayTimeConfigService(this.componentConfig);
373371
this.timeSelectConfig = this.dayPickerService.getTimeConfigService(this.componentConfig);
@@ -434,14 +432,14 @@ export class DatePickerComponent implements OnChanges,
434432
})
435433
} else {
436434
this._selected = this.utilsService
437-
.getValidMomentArray(strVal, this.componentConfig.format);
435+
.getValidMomentArray(strVal, this.componentConfig.format);
438436
this.onChangeCallback(this.processOnChangeCallback(strVal), true);
439437
}
440438
}
441439

442440
dateSelected(date: IDate, granularity: unitOfTime.Base, type: SelectEvent, ignoreClose?: boolean) {
443441
this.selected = this.utilsService
444-
.updateSelected(this.componentConfig.allowMultiSelect, this.selected, date, granularity);
442+
.updateSelected(this.componentConfig.allowMultiSelect, this.selected, date, granularity);
445443
if (!ignoreClose) {
446444
this.onDateClick();
447445
}

0 commit comments

Comments
 (0)