Skip to content

Commit

Permalink
fix: display year in descending order and remove code that will be ne…
Browse files Browse the repository at this point in the history
…ed it to update every year

see the issue for details

fixes issue #1095
  • Loading branch information
DanielPalafox committed Sep 13, 2021
1 parent eaef617 commit a7d3eac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 195 deletions.
18 changes: 9 additions & 9 deletions src/app/record/components/work-modal/work-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@
>
<mat-option i18n="@@shared.year" [value]="">Year</mat-option>
<mat-option
*ngFor="let year of yearOptions | keyvalue"
[value]="year.key"
*ngFor="let year of yearOptions"
[value]="year"
>
{{ year.value }}
{{ year}}
</mat-option>
</mat-select>
</mat-form-field>
Expand All @@ -324,10 +324,10 @@
>
<mat-option i18n="@@shared.month" [value]="">Month</mat-option>
<mat-option
*ngFor="let month of monthOptions | keyvalue"
[value]="month.key"
*ngFor="let month of monthOptions"
[value]="month"
>
{{ month.value }}
{{ month }}
</mat-option>
</mat-select>
</mat-form-field>
Expand All @@ -344,10 +344,10 @@
>
<mat-option i18n="@@shared.day" [value]="">Day</mat-option>
<mat-option
*ngFor="let day of dayOptions | keyvalue"
[value]="day.key"
*ngFor="let day of dayOptions"
[value]="day"
>
{{ day.value }}
{{ day }}
</mat-option>
</mat-select>
</mat-form-field>
Expand Down
33 changes: 17 additions & 16 deletions src/app/record/components/work-modal/work-modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Component, Inject, OnInit } from '@angular/core'
import {
AbstractControl,
AsyncValidatorFn,
FormArray,
FormBuilder,
FormGroup,
Validators,
} from '@angular/forms'
import { AbstractControl, AsyncValidatorFn, FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'
import { first, map, startWith } from 'rxjs/operators'
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'
import { Observable } from 'rxjs'
import { ModalComponent } from 'src/app/cdk/modal/modal/modal.component'
import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'
Expand All @@ -23,20 +16,17 @@ import { Work } from 'src/app/types/record-works.endpoint'
import { UserRecord } from 'src/app/types/record.local'
import {
CitationTypes,
DayOption,
LanguageMap,
MonthOption,
WorkCategories,
WorksTitleName,
WorkConferenceTypes,
WorkIdType,
WorkIntellectualPropertyTypes,
WorkOtherOutputTypes,
WorkPublicationTypes,
WorkRelationships,
WorksTitleName,
WorkTypesByCategory,
WorkTypesTitle,
YearOption,
} from 'src/app/types/works.endpoint'

@Component({
Expand All @@ -57,9 +47,20 @@ export class WorkModalComponent implements OnInit {

languageMap = LanguageMap
workCategories = WorkCategories
yearOptions = YearOption
monthOptions = MonthOption
dayOptions = DayOption
yearOptions = Array(110)
.fill(0)
.map((i, idx) => idx + new Date().getFullYear() - 109)
.reverse()
yearsEndDate = Array(120)
.fill(0)
.map((i, idx) => idx + new Date().getFullYear() - 109)
.reverse()
monthOptions = Array(12)
.fill(0)
.map((i, idx) => idx + 1)
dayOptions = Array(31)
.fill(0)
.map((i, idx) => idx + 1)
citationTypes = CitationTypes

workRelationships: WorkRelationships[] = Object.keys(
Expand Down
170 changes: 0 additions & 170 deletions src/app/types/works.endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,176 +407,6 @@ export const LanguageMap = {
Yoruba: 'yo',
}

export const YearOption = {
2031: '2031',
2030: '2030',
2029: '2029',
2028: '2028',
2027: '2027',
2026: '2026',
2025: '2025',
2024: '2024',
2023: '2023',
2022: '2022',
2021: '2021',
2020: '2020',
2019: '2019',
2018: '2018',
2017: '2017',
2016: '2016',
2015: '2015',
2014: '2014',
2013: '2013',
2012: '2012',
2011: '2011',
2010: '2010',
2009: '2009',
2008: '2008',
2007: '2007',
2006: '2006',
2005: '2005',
2004: '2004',
2003: '2003',
2002: '2002',
2001: '2001',
2000: '2000',
1999: '1999',
1998: '1998',
1997: '1997',
1996: '1996',
1995: '1995',
1994: '1994',
1993: '1993',
1992: '1992',
1991: '1991',
1990: '1990',
1989: '1989',
1988: '1988',
1987: '1987',
1986: '1986',
1985: '1985',
1984: '1984',
1983: '1983',
1982: '1982',
1981: '1981',
1980: '1980',
1979: '1979',
1978: '1978',
1977: '1977',
1976: '1976',
1975: '1975',
1974: '1974',
1973: '1973',
1972: '1972',
1971: '1971',
1970: '1970',
1969: '1969',
1968: '1968',
1967: '1967',
1966: '1966',
1965: '1965',
1964: '1964',
1963: '1963',
1962: '1962',
1961: '1961',
1960: '1960',
1959: '1959',
1958: '1958',
1957: '1957',
1956: '1956',
1955: '1955',
1954: '1954',
1953: '1953',
1952: '1952',
1951: '1951',
1950: '1950',
1949: '1949',
1948: '1948',
1947: '1947',
1946: '1946',
1945: '1945',
1944: '1944',
1943: '1943',
1942: '1942',
1941: '1941',
1940: '1940',
1939: '1939',
1938: '1938',
1937: '1937',
1936: '1936',
1935: '1935',
1934: '1934',
1933: '1933',
1932: '1932',
1931: '1931',
1930: '1930',
1929: '1929',
1928: '1928',
1927: '1927',
1926: '1926',
1925: '1925',
1924: '1924',
1923: '1923',
1922: '1922',
1921: '1921',
1920: '1920',
1919: '1919',
1918: '1918',
1917: '1917',
1916: '1916',
1915: '1915',
1914: '1914',
1913: '1913',
}
export const MonthOption = {
'01': '01',
'02': '02',
'03': '03',
'04': '04',
'05': '05',
'06': '06',
'07': '07',
'08': '08',
'09': '09',
10: '10',
11: '11',
12: '12',
}

export const DayOption = {
'01': '01',
'02': '02',
'03': '03',
'04': '04',
'05': '05',
'06': '06',
'07': '07',
'08': '08',
'09': '09',
10: '10',
11: '11',
12: '12',
13: '13',
14: '14',
15: '15',
16: '16',
17: '17',
18: '18',
19: '19',
20: '20',
21: '21',
22: '22',
23: '23',
24: '24',
25: '25',
26: '26',
27: '27',
28: '28',
29: '29',
30: '30',
31: '31',
}

export const CitationTypes = {
'formatted-apa': 'APA',
bibtex: 'BIBTEX',
Expand Down

0 comments on commit a7d3eac

Please sign in to comment.