Skip to content

Commit

Permalink
set and use default value in options
Browse files Browse the repository at this point in the history
  • Loading branch information
recrwplay committed Aug 5, 2024
1 parent 3210677 commit 7103f14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/js/50-cheat-sheet-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const optionMap = [...selectorOptions].map((o) => ({
text: o.dataset.label,
class: o.dataset.class,
labelType: o.dataset.labelType,
default: o.dataset.defaultValue,
labelOnly: o.hidden,
selected: o.selected,
inScope: true,
Expand All @@ -23,8 +24,9 @@ const prodMatrix = {
'neo4j-enterprise': 'neo4j-ee',
}

// if a product is not selected in the dropdown default to 'All'
const defaultProd = 'all'
// get the default product from optionMap
const defaultProdArray = optionMap.find((prod) => prod.default === 'true')
const defaultProd = defaultProdArray ? defaultProdArray.value : optionMap[0].value

const defaultClasses = ['exampleblock', 'sect2', 'sect1']

Expand Down
2 changes: 1 addition & 1 deletion src/partials/nav-selectors.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{{!-- <option value="all" data-label="all" data-class="all" data-label-type="products">All</option> --}}
{{#each page.attributes.cheatsheet-products}}
{{#if this.default}}
<option value="{{this.class}}" data-label="{{#with (or this.label this.name) }}{{{this}}}{{/with}}" data-class="{{this.class}}" data-label-type="products" selected>{{this.name}}</option>
<option value="{{this.class}}" data-label="{{#with (or this.label this.name) }}{{{this}}}{{/with}}" data-class="{{this.class}}" data-label-type="products" data-default-value="true" selected>{{this.name}}</option>
{{else}}
<option value="{{this.class}}" data-label="{{#with (or this.label this.name) }}{{{this}}}{{/with}}" data-class="{{this.class}}" data-label-type="products" {{#if this.label-only }}hidden{{/if}}>{{this.name}}</option>
{{/if}}
Expand Down

0 comments on commit 7103f14

Please sign in to comment.