Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
TT-39 fix: variable refactor
  • Loading branch information
Guido Quezada committed Dec 29, 2020
commit 881c5203fc778b96c3ecb93ed0c067884f4b0392
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MonthPickerComponent implements OnInit {
selectedMonthMoment: moment.Moment;
selectedMonthIndex: number;
selectedYearMoment: moment.Moment;
selectedMonthYear: number;
selectedYear: number;

selectedYearText: string;
months: Array<string> = [];
Expand All @@ -26,12 +26,12 @@ export class MonthPickerComponent implements OnInit {
this.selectedMonthMoment = moment();
this.months = moment.months();
this.selectedMonthIndex = this.selectedMonthMoment.month();
this.selectedMonthYear = this.selectedYearMoment.year();
this.selectedYear = this.selectedYearMoment.year();
this.updateYearText();
}

ngOnInit() {
this.selectDate(this.selectedMonthIndex, this.selectedMonthYear);
this.selectDate(this.selectedMonthIndex, this.selectedYear);
}

updateYearText() {
Expand All @@ -48,23 +48,21 @@ export class MonthPickerComponent implements OnInit {
this.updateYearText();
}

selectMonth(index: number) {
this.selectedMonthMoment = moment().month(index);
this.selectedMonthIndex = this.selectedMonthMoment.month();
this.selectedMonthYear = this.selectedYearMoment.year();
this.selectDate(this.selectedMonthIndex, this.selectedMonthYear);
selectMonth(monthIndex: number) {
this.selectedMonthIndex = monthIndex;
this.selectedYear = this.selectedYearMoment.year();
this.selectDate(this.selectedMonthIndex, this.selectedYear);
}

isSelectedMonth(monthIndex: number) {
return (
this.selectedMonthIndex === monthIndex &&
this.selectedMonthYear === this.selectedYearMoment.year()
this.selectedYear === this.selectedYearMoment.year()
);
}

selectDate(monthIndex: number, year: number) {
this.dateSelected.emit({ monthIndex: monthIndex, year: year });
this.dateSelected.emit({ monthIndex, year });
}

}