Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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

# 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,9 @@ describe('MonthPickerComponent', () => {
expect(component.selectDate).toHaveBeenCalledWith(monthSelect, yearSelect);
});

it('monthEnable sets disabled to true on futures months', () => {
const monthFuture = component.monthCurrent + 1;
expect(component.monthEnable(monthFuture)).toBeTrue();
});

});
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