Skip to content

Commit

Permalink
Merge pull request NatLibFi#1630 from NatLibFi/alphabetical-index-con…
Browse files Browse the repository at this point in the history
…tent-lang

Fetch letters and concepts based on content language
  • Loading branch information
UnniKohonen committed Apr 25, 2024
2 parents ee292dc + 199305d commit 3c5250d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions resource/js/tab-alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const tabAlphaApp = Vue.createApp({
this.loadingLetters = true
// Remove scrolling event listener while letters are loaded
this.$refs.tabAlpha.$refs.list.removeEventListener('scroll', this.handleScrollEvent)
fetch('rest/v1/' + window.SKOSMOS.vocab + '/index/?lang=' + window.SKOSMOS.lang)
fetch('rest/v1/' + window.SKOSMOS.vocab + '/index/?lang=' + window.SKOSMOS.content_lang)
.then(data => {
return data.json()
})
Expand All @@ -58,7 +58,7 @@ const tabAlphaApp = Vue.createApp({
this.currentOffset = 0
// Remove scrolling event listener while concepts are loaded
this.$refs.tabAlpha.$refs.list.removeEventListener('scroll', this.handleScrollEvent)
const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + letter + '?lang=' + window.SKOSMOS.lang + '&limit=250'
const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + letter + '?lang=' + window.SKOSMOS.content_lang + '&limit=250'
fetchWithAbort(url, 'alpha')
.then(data => {
return data.json()
Expand All @@ -83,7 +83,7 @@ const tabAlphaApp = Vue.createApp({
this.loadingMoreConcepts = true
// Remove scrolling event listener while new concepts are loaded
this.$refs.tabAlpha.$refs.list.removeEventListener('scroll', this.handleScrollEvent)
const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + this.selectedLetter + '?lang=' + window.SKOSMOS.lang + '&limit=250&offset=' + this.currentOffset
const url = 'rest/v1/' + window.SKOSMOS.vocab + '/index/' + this.selectedLetter + '?lang=' + window.SKOSMOS.content_lang + '&limit=250&offset=' + this.currentOffset
fetchWithAbort(url, 'alpha')
.then(data => {
return data.json()
Expand Down
8 changes: 8 additions & 0 deletions tests/cypress/template/sidebar.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ describe('Sidebar', () => {
cy.get('#sidebar-tabs').find('.active').should('have.length', 1)
cy.get('.tab-content').find('.active').should('have.length', 1)
})
it('Concepts and letters in alphabetical index are displayed in the correct language', () => {
// go to YSO vocab from page with UI language set to English and content language set to Finnish
cy.visit('/yso/en/?clang=fi')
// check that the first item in the list is in the correct language
cy.get('#tab-alphabetical .sidebar-list a').first().invoke('text').should('contain', 'aarrelöydöt')
// check that letters contain Y and not C
cy.get('#tab-alphabetical .pagination a').invoke('text').should('contain', 'Y').should('not.contain', 'C')
})
})

0 comments on commit 3c5250d

Please sign in to comment.