Skip to content

Commit

Permalink
NEW: Advanced Search: Option: Match diacritics (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Jul 28, 2024
1 parent 85d7ce3 commit ba2c993
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
9 changes: 7 additions & 2 deletions pages/Search/Search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
</div>

<div class=checkbox-field>
<input {{#if query.diacritics }} checked {{/if}} id=diacritics-box name=diacritics type=checkbox>
<label for=diacritics-box>Match diacritics</label>
<input {{#if query.diacritics }} checked {{/if}} id=quick-diacritics-box name=diacritics type=checkbox>
<label for=quick-diacritics-box>Match diacritics</label>
</div>

<div class=checkbox-field>
Expand Down Expand Up @@ -138,6 +138,11 @@
<label for=advanced-case-sensitive-box>Match case</label>
</div>

<div class=checkbox-field>
<input {{#if query.diacritics }} checked {{/if}} id=advanced-diacritics-box name=diacritics type=checkbox>
<label for=advanced-diacritics-box>Match diacritics</label>
</div>

</fieldset>

<div class=search-controls>
Expand Down
18 changes: 14 additions & 4 deletions pages/Search/Search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe(`Search`, function() {

it(`Option: Match Diacritics (checked)`, function() {
cy.visit(`/search`)
cy.get(`#diacritics-box`).check()
cy.get(`#quick-diacritics-box`).check()
cy.get(`#search-box`).type(`aštimw`)
cy.get(`#quick-search-form`).submit()
cy.get(`.num-results`).should(`include.text`, `of 2`)
Expand Down Expand Up @@ -152,12 +152,12 @@ describe(`Search`, function() {
it(`Settings`, function() {
cy.visit(`/search`)
cy.get(`#quick-case-sensitive-box`).check()
cy.get(`#diacritics-box`).check()
cy.get(`#quick-diacritics-box`).check()
cy.get(`#regex-box`).check()
cy.get(`#quick-language-select`).select(`Cree_East`)
cy.reload()
cy.get(`#quick-case-sensitive-box`).should(`be.checked`)
cy.get(`#diacritics-box`).should(`be.checked`)
cy.get(`#quick-diacritics-box`).should(`be.checked`)
cy.get(`#regex-box`).should(`be.checked`)
cy.get(`#quick-language-select`).should(`have.value`, `Cree_East`)
})
Expand Down Expand Up @@ -207,14 +207,24 @@ describe(`Search`, function() {
cy.get(`#advanced-case-sensitive-box`).should(`be.checked`)
})

it(`Option: Match Diacritics`, function() {
cy.visit(`/search`)
cy.contains(`label`, `Advanced Search`).click()
cy.get(`#advanced-diacritics-box`).check()
cy.get(`#form-box`).type(`aštimw`)
cy.get(`#advanced-search-form`).submit()
cy.get(`.num-results`).should(`include.text`, `of 2`)
})

it(`Settings`, function() {
cy.visit(`/search`)
cy.contains(`label`, `Advanced Search`).click()
cy.get(`#advanced-language-select`).select(`Cree_East`)
cy.get(`#advanced-case-sensitive-box`).check()
cy.get(`#advanced-diacritics-box`).check()
cy.reload()
cy.get(`#advanced-language-select`).should(`have.value`, `Cree_East`)
cy.get(`#advanced-case-sensitive-box`).should(`be.checked`)
cy.get(`#advanced-diacritics-box`).should(`be.checked`)
})

})
Expand Down
4 changes: 4 additions & 0 deletions pages/Search/scripts/AdvancedSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class AdvancedSearch {
*/
constructor() {
this.caseSensitive = document.getElementById(`advanced-case-sensitive-box`)
this.diacritics = document.getElementById(`advanced-diacritics-box`)
this.language = document.getElementById(`advanced-language-select`)
}

Expand All @@ -15,6 +16,7 @@ export default class AdvancedSearch {
*/
listen() {
this.caseSensitive.addEventListener(`input`, this.save.bind(this))
this.diacritics.addEventListener(`input`, this.save.bind(this))
this.language.addEventListener(`input`, this.save.bind(this))
}

Expand All @@ -27,6 +29,7 @@ export default class AdvancedSearch {

// Restore search settings
this.caseSensitive.checked = localStorage.getItem(`caseSensitive`) === `true`
this.diacritics.checked = localStorage.getItem(`diacritics`) === `true`
this.language.value = localStorage.getItem(`language`)

}
Expand All @@ -36,6 +39,7 @@ export default class AdvancedSearch {
*/
save() {
localStorage.setItem(`caseSensitive`, this.caseSensitive.checked)
localStorage.setItem(`diacritics`, this.diacritics.checked)
localStorage.setItem(`language`, this.language.value)
}

Expand Down
2 changes: 1 addition & 1 deletion pages/Search/scripts/QuickSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class QuickSearch {
*/
constructor() {
this.caseSensitive = document.getElementById(`quick-case-sensitive-box`)
this.diacritics = document.getElementById(`diacritics-box`)
this.diacritics = document.getElementById(`quick-diacritics-box`)
this.form = document.getElementById(`quick-search-form`)
this.language = document.getElementById(`quick-language-select`)
this.regex = document.getElementById(`regex-box`)
Expand Down

0 comments on commit ba2c993

Please sign in to comment.