Skip to content
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

Pad month numbers #1177

Merged
merged 2 commits into from
May 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class AddConsortiumMemberComponent implements OnInit {
routeData: any
currentMonth: number | undefined
currentYear: number | undefined
monthList: [number, string][] | undefined
monthList: [string, string][] | undefined
yearList: number[] | undefined
editForm: FormGroup = this.fb.group({
orgName: [null, [Validators.required, Validators.maxLength(41)]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class RemoveConsortiumMemberComponent implements OnInit, OnDestroy {
consortiumMemberId: string | undefined
currentMonth: number | undefined
currentYear: number | undefined
monthList: [number, string][] | undefined
monthList: [string, string][] | undefined
yearList: number[] | undefined
editForm: FormGroup = this.fb.group({
terminationMonth: [null, [Validators.required]],
Expand All @@ -55,6 +55,7 @@ export class RemoveConsortiumMemberComponent implements OnInit, OnDestroy {
this.currentMonth = this.dateUtilService.getCurrentMonthNumber()
this.currentYear = this.dateUtilService.getCurrentYear()
this.monthList = this.dateUtilService.getMonthsList()

this.yearList = this.dateUtilService.getFutureYearsIncludingCurrent(1)

this.accountService.getAccountData().subscribe((account) => {
Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/shared/service/date-util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ export class DateUtilService {
return years
}

getMonthsList(): [number, string][] {
getMonthsList(): [string, string][] {
const months = moment.months()
const monthsArray = []
for (let _i = 1; _i <= months.length; _i++) {
const res: [number, string] = [parseInt(('0' + _i.toString()).slice(-2)), months[_i - 1]]
const res: [string, string] = [('0' + _i.toString()).slice(-2), months[_i - 1]]
monthsArray.push(res)
}
return monthsArray
}

getFutureMonthsList(): [number, string][] {
getFutureMonthsList(): [string, string][] {
const months = moment.months()
const monthsArray = []
for (let _i = 1; _i <= months.length; _i++) {
if (_i > this.getCurrentMonthNumber()) {
const res: [number, string] = [parseInt(('0' + _i.toString()).slice(-2)), months[_i - 1]]
const res: [string, string] = [('0' + _i.toString()).slice(-2), months[_i - 1]]
monthsArray.push(res)
}
}
Expand Down
Loading