Skip to content

Commit e656905

Browse files
committed
TT-107 feat: Limit the year selector in UI to the current year
1 parent 9c6fefd commit e656905

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/app/modules/shared/components/month-picker/month-picker.component.html

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
<div class="card-header">
2-
<div class="d-flex align-items-center">
3-
<button class="btn mr-auto" (click)="changeYear('subtract')">
4-
<i class="fa fa-chevron-left"></i>
5-
</button>
6-
<p>
7-
{{selectedYearText}}
8-
</p>
9-
<button class="btn ml-auto" (click)="changeYear('add')">
10-
<i class="fa fa-chevron-right"></i>
11-
</button>
2+
<div class="row align-items-center">
3+
<div class="col-sm-4">
4+
<button class="btn mr-auto" (click)="changeYear('subtract')">
5+
<i class="fa fa-chevron-left"></i>
6+
</button>
7+
</div>
8+
<div class="col-sm-4">
9+
<p class="text-center year-text">
10+
{{selectedYearText}}
11+
</p>
12+
</div>
13+
14+
<div class="col-sm-4 text-right">
15+
<button *ngIf="selectedYear < currentYear" class="btn ml-auto" (click)="changeYear('add')">
16+
<i class="fa fa-chevron-right"></i>
17+
</button>
18+
</div>
1219
</div>
1320
</div>
1421
<div class="row content-months">

src/app/modules/shared/components/month-picker/month-picker.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
margin: 0;
1010
}
1111

12+
.year-text {
13+
margin-bottom: 0;
14+
}
15+
1216
.month {
1317
background: $primary;
1418
color: white;

src/app/modules/shared/components/month-picker/month-picker.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export class MonthPickerComponent implements OnInit {
1616
selectedMonthIndex: number;
1717
selectedYearMoment: moment.Moment;
1818
selectedYear: number;
19-
2019
selectedYearText: string;
2120
months: Array<string> = [];
2221

22+
currentYear = new Date().getFullYear();
23+
2324
constructor() {
2425
this.selectedYearMoment = moment();
2526
this.selectedMonthMoment = moment();

0 commit comments

Comments
 (0)