Skip to content

Commit

Permalink
FIX: Render dropdown values on initial load (#187)
Browse files Browse the repository at this point in the history
closes #187
  • Loading branch information
dwhieb committed Jul 29, 2024
1 parent 858cd44 commit 7e3b7db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
14 changes: 7 additions & 7 deletions pages/Search/Search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<label>
<span>Advanced Search</span>
<input {{#if advanced }} checked {{/if}} id=advanced-option name=search type=radio value=advanced>
<input {{#if advanced }}checked{{/if}} id=advanced-option name=search type=radio value=advanced>
</label>

</fieldset>
Expand All @@ -22,9 +22,9 @@
<div>
<label for=quick-language-select>Language</label>
<select class='language-select text-box' id=quick-language-select name=language>
<option {{#if (is query.language 'all') }} selected {{/if}} value=all>All languages</option>
<option {{#unless query.language }}selected{{else if (is query.language 'all') }}selected{{/unless}} value=all>All languages</option>
{{#each languages as |lang| }}
<option {{#if (is ../query.language key) }} selected {{/if}} value='{{ key }}'>{{ name }} {{#if autonyms }}({{#each autonyms }}{{ this }}{{#unless @last }}, {{/unless}}{{/each}}){{/if}}</option>
<option {{#if (is ../query.language key) }} selected {{/if}} value='{{ key }}'>{{ name }}{{#if autonyms }}({{#each autonyms }}{{ this }}{{#unless @last }}, {{/unless}}{{/each}}){{/if}}</option>
{{/each}}
</select>
</div>
Expand Down Expand Up @@ -88,9 +88,9 @@
<div>
<label for=advanced-language-select>Language</label>
<select class='language-select text-box' id=advanced-language-select name=language>
<option {{#if (is query.language 'all') }} selected {{/if}} value=all>All languages</option>
<option {{#unless query.language }}selected{{else if (is query.language 'all') }}selected{{/unless}} value=all>All languages</option>
{{#each languages as |lang| }}
<option {{#if (is ../query.language key) }} selected {{/if}} value='{{ key }}'>{{ name }} {{#if autonyms }}({{#each autonyms }}{{ this }}{{#unless @last }}, {{/unless}}{{/each}}){{/if}}</option>
<option {{#if (is ../query.language key) }} selected {{/if}} value='{{ key }}'>{{ name }}{{#if autonyms }}({{#each autonyms }}{{ this }}{{#unless @last }}, {{/unless}}{{/each}}){{/if}}</option>
{{/each}}
</select>
</div>
Expand Down Expand Up @@ -155,8 +155,8 @@
<div class=logic-field>
<label for=logic-select>Search logic:</label>
<select class=text-box id=logic-select name=logic>
<option {{#unless (is query.logic 'any') }} selected {{/unless}} value=all>match all criteria</option>
<option {{#if (is query.logic 'any' ) }} selected {{/if}} value=any>match any criteria</option>
<option {{#unless query.logic }}selected{{else if (is query.logic 'all') }}selected{{/unless}} value=all>Match all criteria</option>
<option {{#if (is query.logic 'any') }}{{/if}} value=any>Match any criteria</option>
</select>
</div>

Expand Down
8 changes: 6 additions & 2 deletions pages/Search/scripts/AdvancedSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ 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`)
this.logic.value = localStorage.getItem(`logic`)
this.regex.checked = localStorage.getItem(`regex`) === `true`

const language = localStorage.getItem(`language`)
const logic = localStorage.getItem(`logic`)

if (language) this.language.value = language
if (logic) this.logic.value = logic

}

resetValidity() {
Expand Down
5 changes: 4 additions & 1 deletion pages/Search/scripts/QuickSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ export default class QuickSearch {
// Restore search settings
this.caseSensitive.checked = localStorage.getItem(`caseSensitive`) === `true`
this.diacritics.checked = localStorage.getItem(`diacritics`) === `true`
this.language.value = localStorage.getItem(`language`)
this.regex.checked = localStorage.getItem(`regex`) === `true`

const language = localStorage.getItem(`language`)

if (language) this.language.value = language

this.search.focus()

}
Expand Down

0 comments on commit 7e3b7db

Please sign in to comment.