Skip to content

Commit

Permalink
Merge pull request #403 from NUM-Forschungsdatenplattform/name_transl…
Browse files Browse the repository at this point in the history
…ation_fix

lang fix
  • Loading branch information
adriandumavitagroup authored Jan 25, 2023
2 parents bf46f1e + 6aa019b commit 0c755b4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/app/core/services/aql/aql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export class AqlService {
size: number,
sort: string = null,
sortBy: string = null,
filters: any
filters: any,
lang: string
): Observable<any> {
let queryS = ''
if (page !== null && size !== null) {
Expand All @@ -101,6 +102,10 @@ export class AqlService {
queryS = queryS + '&filter%5B' + key + '%5D=' + value
}
}

if (lang) {
queryS = queryS + '&language=' + lang
}
}
return this.httpClient.get<any>(this.baseUrl + '/all' + queryS).pipe(
tap((data) => {
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/services/aql/test/aql.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ describe('AqlService', () => {
describe('When a call to getAllPag method comes in', () => {
it('should call the api - with success', () => {
jest.spyOn(httpClient, 'get').mockImplementation(() => of(mockAqls))
service.getAllPag(0, 2, 'ASC', 'name', { type: 'OWNED' }).subscribe()
service.getAllPag(0, 2, 'ASC', 'name', { type: 'OWNED' }, 'en').subscribe()
expect(httpClient.get).toHaveBeenCalled()
})
it('should call the api - with error', () => {
jest.spyOn(httpClient, 'get').mockImplementation(() => throwError('Error'))
jest.spyOn(service, 'handleError')
service
.getAllPag(0, 2, 'ASC', 'name', { type: 'OWNED' })
.getAllPag(0, 2, 'ASC', 'name', { type: 'OWNED' }, 'en')
.toPromise()
.then((_) => {})
.catch((_) => {})
expect(httpClient.get).toHaveBeenCalledWith(
'localhost/api/aql/all?page=0&size=2&sort=ASC&sortBy=name&filter%5Btype%5D=OWNED'
'localhost/api/aql/all?page=0&size=2&sort=ASC&sortBy=name&filter%5Btype%5D=OWNED&language=en'
)
expect(service.handleError).toHaveBeenCalled()
})
Expand Down
13 changes: 12 additions & 1 deletion src/app/modules/aqls/components/aql-table/aql-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export class AqlTableComponent extends SortableTable<IAqlApi> implements OnDestr
this.sortBy = 'createDate'
}

if (this.lang === 'en' && this.sortBy === 'name') {
this.sortBy = 'nameTranslated'
}

this.getAll()
}

Expand All @@ -144,7 +148,14 @@ export class AqlTableComponent extends SortableTable<IAqlApi> implements OnDestr
getAll() {
this.subscriptions.add(
this.aqlService
.getAllPag(this.pageIndex, this.pageSize, this.sortDir, this.sortBy, this.filters)
.getAllPag(
this.pageIndex,
this.pageSize,
this.sortDir,
this.sortBy,
this.filters,
this.lang
)
.subscribe((data) => {
this.handleData(data)
})
Expand Down

0 comments on commit 0c755b4

Please sign in to comment.