-
Notifications
You must be signed in to change notification settings - Fork 1
TT-39 fix: comments #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
TT-39 fix: comments #588
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8cdf916
TT-39 feat: allow switching among year
scastillo-jp e839109
TT-39 fix: resolve tests
scastillo-jp da55e06
TT-39 fix: creating test
scastillo-jp e23f6e8
TT-39 fix: code coverage
scastillo-jp 5582e15
TT-39 fix: resolve comments
scastillo-jp d472a63
TT-39 fix: code coverage
scastillo-jp 42aea4b
TT-39 fix: testing increment() and decrement()
scastillo-jp fc2587a
TT-39 fix: code refactor
881c520
TT-39 fix: variable refactor
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 20 additions & 8 deletions
28
src/app/modules/shared/components/month-picker/month-picker.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
<div class="d-flex"> | ||
<div | ||
class="month w-100 text-center align-self-center d-flex flex-column" | ||
*ngFor="let month of months; let i = index" | ||
(click)="getMonth(i)" | ||
[ngClass]="{ active: activeMonth === i }" | ||
> | ||
<div class="p-2">{{ month }}</div> | ||
<div class="card-header"> | ||
<div class="d-flex align-items-center"> | ||
<button class="btn mr-auto" (click)="decrement()"> | ||
<i class="fa fa-chevron-left"></i> | ||
</button> | ||
<p> | ||
{{selectedYearText}} | ||
</p> | ||
<button class="btn ml-auto" (click)="increment()"> | ||
<i class="fa fa-chevron-right"></i> | ||
</button> | ||
</div> | ||
</div> | ||
<div class="row content-months"> | ||
<div class="spacing col-xl-1 col-lg-1 col-md-2 col-sm-2 col-xs-4" *ngFor="let month of months; let i = index"> | ||
<button class="btn btn-light btn-block" | ||
[ngClass]="{'btn-primary': isSelectedMonth(i)}" | ||
(click)="selectMonth(i)"> | ||
<small>{{ month.slice(0, 3) }}</small> | ||
</button> | ||
</div> | ||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 54 additions & 9 deletions
63
src/app/modules/shared/components/month-picker/month-picker.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,68 @@ | ||
import { Component, OnInit, Output, EventEmitter } from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
@Component({ | ||
selector: 'app-month-picker', | ||
templateUrl: './month-picker.component.html', | ||
styleUrls: ['./month-picker.component.scss'] | ||
}) | ||
export class MonthPickerComponent implements OnInit { | ||
@Output() monthSelected = new EventEmitter(); | ||
activeMonth: number; | ||
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; | ||
@Output() dateSelected = new EventEmitter<{ | ||
monthIndex: number; | ||
year: number; | ||
}>(); | ||
|
||
constructor() { } | ||
selectedMonthMoment: moment.Moment; | ||
selectedMonthIndex: number; | ||
selectedYearMoment: moment.Moment; | ||
selectedYear: number; | ||
|
||
ngOnInit(): void { | ||
this.activeMonth = new Date().getMonth(); | ||
selectedYearText: string; | ||
months: Array<string> = []; | ||
years: Array<number> = []; | ||
|
||
constructor() { | ||
this.selectedYearMoment = moment(); | ||
this.selectedMonthMoment = moment(); | ||
this.months = moment.months(); | ||
this.selectedMonthIndex = this.selectedMonthMoment.month(); | ||
this.selectedYear = this.selectedYearMoment.year(); | ||
this.updateYearText(); | ||
} | ||
|
||
ngOnInit() { | ||
this.selectDate(this.selectedMonthIndex, this.selectedYear); | ||
} | ||
|
||
updateYearText() { | ||
this.selectedYearText = moment(this.selectedYearMoment).format('YYYY'); | ||
} | ||
|
||
increment() { | ||
this.selectedYearMoment = this.selectedYearMoment.add(1, 'year'); | ||
this.updateYearText(); | ||
} | ||
|
||
getMonth(month: number) { | ||
this.monthSelected.emit(month + 1); | ||
this.activeMonth = month; | ||
decrement() { | ||
this.selectedYearMoment = this.selectedYearMoment.subtract(1, 'year'); | ||
this.updateYearText(); | ||
} | ||
|
||
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.selectedYear === this.selectedYearMoment.year() | ||
); | ||
} | ||
|
||
selectDate(monthIndex: number, year: number) { | ||
this.dateSelected.emit({ monthIndex, year }); | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.