Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ testem.log
keys.ts
src/environments/keys.ts
debug.log
/.vscode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this part you can use *.vscode


# System Files
.DS_Store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ export class TimeRangeFormComponent implements OnInit {
setInitialDataOnScreen() {
this.reportForm.setValue({
startDate: formatDate(moment().startOf('week').format('l'), DATE_FORMAT, 'en'),
endDate: formatDate(moment().endOf('week').format('l'), DATE_FORMAT, 'en')
endDate: formatDate(moment().format('l'), DATE_FORMAT, 'en')
});
this.onSubmit();
}

onSubmit() {
const endDate = moment(this.endDate.value).endOf('day');
const startDate = moment(this.startDate.value).startOf('day');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
required="required"
[matDatepicker]="datepicker"
(click)="openOrCloseDatePicker(datepicker)"
[max]="getCurrentDate()"
/>
<mat-datepicker #datepicker ></mat-datepicker>
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ export class InputDateComponent implements ControlValueAccessor {
openOrCloseDatePicker(datepicker: MatDatepicker<Date>): void {
return datepicker.opened ? datepicker.close() : datepicker.open();
}
getCurrentDate(): string {
return moment(new Date()).format(DATE_FORMAT_YEAR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
<div class="spacing col-xl-1 col-lg-1 col-md-2 col-2" *ngFor="let month of months; let i = index">
<button class="btn btn-light btn-block"
[ngClass]="{'btn-primary': isSelectedMonth(i)}"
(click)="selectMonth(i)">
(click)="selectMonth(i)"
[disabled]="monthEnable(i)">
<small>{{ month.slice(0, 3) }}</small>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { MonthPickerComponent } from './month-picker.component';
describe('MonthPickerComponent', () => {
let component: MonthPickerComponent;
let fixture: ComponentFixture<MonthPickerComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ MonthPickerComponent ]
Expand Down Expand Up @@ -69,4 +68,14 @@ describe('MonthPickerComponent', () => {
expect(component.selectDate).toHaveBeenCalledWith(monthSelect, yearSelect);
});

it('monthEnable set disable true in the buttoms futures', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace this name:
monthEnable sets disabled to true on futures months

const monthFuture = component.monthCurrent + 1;
expect(component.monthEnable(monthFuture)).toBeTrue();
});

it('monthEnable set disable false in the buttoms presents and past', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this description is not very clear:

I Understand this.
monthEnable set disabled to false in the months presents and past

I Think is no necessary disable the past months only future months

const monthFuture = component.monthCurrent;
expect(component.monthEnable(monthFuture)).toBeFalse();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class MonthPickerComponent implements OnInit {
months: Array<string> = [];
currentYear = new Date().getFullYear();
showArrowNext = false;

monthCurrent = moment().month();
constructor() {
this.selectedYearMoment = moment();
this.selectedMonthMoment = moment();
Expand Down Expand Up @@ -49,7 +49,12 @@ export class MonthPickerComponent implements OnInit {
this.selectedMonthIndex = monthIndex;
this.selectDate(this.selectedMonthIndex, this.selectedYear);
}

monthEnable(monthIndex: number){
return(
this.monthCurrent < monthIndex &&
this.selectedYear === this.currentYear
);
}
isSelectedMonth(monthIndex: number) {
return (
this.selectedMonthIndex === monthIndex &&
Expand Down