Skip to content

Commit

Permalink
Fix - disable voice button in search box when option is off
Browse files Browse the repository at this point in the history
  • Loading branch information
support committed Jan 10, 2024
1 parent c6becfe commit eb7cef9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,25 @@
@await Component.InvokeAsync("Widget", new { widgetZone = "searchbox_before_search_button" })

<div class="input-group-append">
<button id="voiceSearchButton"
v-if="searchbox.allowed"
@@touchstart="searchbox.recording = true"
@@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@mousedown="searchbox.recording = true"
@@mouseup="searchbox.recording = false"
@@mouseleave="searchbox.recording = false"
v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-outline-secondary search-button btn-mic']">
<template v-if="searchbox.recording">
<span class="icons icon-microphone"></span>
</template>
<template v-else>
<span class="icons icon-microphone"></span>
</template>
</button>
@if (Model.VoiceNavigatioEnabled)
{
<button id="voiceSearchButton"
v-if="searchbox.allowed"
@@touchstart="searchbox.recording = true"
@@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@mousedown="searchbox.recording = true"
@@mouseup="searchbox.recording = false"
@@mouseleave="searchbox.recording = false"
v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-outline-secondary search-button btn-mic']">
<template v-if="searchbox.recording">
<span class="icons icon-microphone"></span>
</template>
<template v-else>
<span class="icons icon-microphone"></span>
</template>
</button>
}
<button type="submit" class="btn btn-outline-secondary search-box-button search-button float-sm-right d-inline-flex align-items-center">
<span class="sr-only">@Loc["Search.SearchBox.Tooltip"]</span>
<span class="icons icon-magnifier"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Stores;
using Grand.Infrastructure.Caching;
using Grand.Web.Events.Cache;
using Grand.Web.Features.Models.Catalog;
Expand All @@ -17,17 +18,19 @@ public class GetSearchBoxHandler : IRequestHandler<GetSearchBox, SearchBoxModel>
private readonly ICategoryService _categoryService;
private readonly ITranslationService _translationService;
private readonly CatalogSettings _catalogSettings;

private readonly StoreInformationSettings _storeInformationSettings;
public GetSearchBoxHandler(
ICacheBase cacheBase,
ICategoryService categoryService,
ITranslationService translationService,
CatalogSettings catalogSettings)
CatalogSettings catalogSettings,
StoreInformationSettings storeInformationSettings)
{
_cacheBase = cacheBase;
_categoryService = categoryService;
_translationService = translationService;
_catalogSettings = catalogSettings;
_storeInformationSettings = storeInformationSettings;
}

public async Task<SearchBoxModel> Handle(GetSearchBox request, CancellationToken cancellationToken)
Expand All @@ -52,7 +55,8 @@ public async Task<SearchBoxModel> Handle(GetSearchBox request, CancellationToken
AutoCompleteEnabled = _catalogSettings.ProductSearchAutoCompleteEnabled,
ShowProductImagesInSearchAutoComplete = _catalogSettings.ShowProductImagesInSearchAutoComplete,
SearchTermMinimumLength = _catalogSettings.ProductSearchTermMinimumLength,
AvailableCategories = availableCategories
AvailableCategories = availableCategories,
VoiceNavigatioEnabled = _storeInformationSettings.VoiceNavigation
};

return model;
Expand Down
2 changes: 2 additions & 0 deletions src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public SearchBoxModel()
AvailableCategories = new List<SelectListItem>();
}
public bool AutoCompleteEnabled { get; set; }

public bool VoiceNavigatioEnabled { get; set; }
public bool ShowProductImagesInSearchAutoComplete { get; set; }
public int SearchTermMinimumLength { get; set; }
public string SearchCategoryId { get; set; }
Expand Down
35 changes: 19 additions & 16 deletions src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,25 @@
@await Component.InvokeAsync("Widget", new { widgetZone = "searchbox_before_search_button" })

<div class="input-group-append">
<button id="voiceSearchButton"
v-if="searchbox.allowed"
@@touchstart="searchbox.recording = true"
@@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@mousedown="searchbox.recording = true"
@@mouseup="searchbox.recording = false"
@@mouseleave="searchbox.recording = false"
v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-link']">
<template v-if="searchbox.recording">
<b-icon icon="mic" variant="info"></b-icon>
</template>
<template v-else>
<b-icon icon="mic-mute" variant="danger"></b-icon>
</template>
</button>
@if (Model.VoiceNavigatioEnabled)
{
<button id="voiceSearchButton"
v-if="searchbox.allowed"
@@touchstart="searchbox.recording = true"
@@touchcancel="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@touchend="searchbox.recording = false; $root.$emit('bv::hide::tooltip')"
@@mousedown="searchbox.recording = true"
@@mouseup="searchbox.recording = false"
@@mouseleave="searchbox.recording = false"
v-b-tooltip.hover.bottom :title="searchbox.micMessage" ref="micBtn" type="button" v-bind:class="[{ focus: searchbox.recording }, 'btn btn-link']">
<template v-if="searchbox.recording">
<b-icon icon="mic" variant="info"></b-icon>
</template>
<template v-else>
<b-icon icon="mic-mute" variant="danger"></b-icon>
</template>
</button>
}
<button type="submit" class="btn btn-link search-box-button float-sm-right d-inline-flex align-items-center">
<span class="sr-only">@Loc["Search.SearchBox.Tooltip"]</span>
<b-icon icon="search"></b-icon>
Expand Down

0 comments on commit eb7cef9

Please sign in to comment.