Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this article you will find:

Table of Contents

Overview

The Hawksearch box using Vue.js provides framework specific integration of the search field and enables optimized and efficient way of using the widgetwidget comes with a ReactJS powered front end which has the latest features exposed to the Hawksearch service.

Goal

This document provides information on setting up the Hawksearch box widget using VueReact. js. Basic usage is covered in Selecting React or Vue Getting started and any additional information may be found here.

Prerequisite

Info

Configured Hawksearch box widget.

https://hawksearch.atlassian.net/wiki/spaces/CON/pages/605618600/Configuring%2BHawksearch%2Bbox%2BWidget

Steps for setup

  1. Open the selected widget template file

  2. Uncomment, if necessary, the part of the markup designated as Vue React template. This should include a div element with attribute data-component="vuereact-appsearch-searchbox". In it, there should be a Vue component named search-boxbox" or data-component="react-search-box-bootstrap". It should be an empty div element. Comment the part marked as Vue template.
    The React template . Only this step is required for enabling the component, the rest of the steps are optional.

  3. Modify the data-client-guid attribute to set the Hawksearch client ID.

  4. Modify the should look like this:

    Code Block
    // React template
    
        if (!SystemManager.IsDesignMode)
        {
            @Html.Script(Url.WidgetContent("assets/build/js/vendor.bundle.js"), "bottom", false)
            @Html.Script(Url.WidgetContent("assets/build/js/main.js"), "bottom", false)
    
            @Html.StyleSheet(Url.WidgetContent("assets/build/css/vendor.css"), "head")
            @Html.StyleSheet(Url.WidgetContent("assets/build/css/main.css"), "head")
            @Html.StyleSheet(Url.WidgetContent("assets/dist/react-hawksearch.css"), "head")
            @Html.StyleSheet(Url.WidgetContent("assets/dist/react-hawksearch-override.css"), "head")
        }
    
        <div data-component="react-search-box-bootstrap"
             data-client-guid="@Model.ClientId"
             data-hawksearch-tracking-api="@Model.TrackingUrl"
             data-hawksearch-base-api
    attribute to set the Base API URL.Modify the
    ="@Model.HawksearchBaseAPI"
             data-hawksearch-search-api
    attribute to set the Search API URL
  5. Modify the data-json-params attribute (JSON object, param_name: param_value) to set additional search parameters, specific for the widget instance.

  6. Modify the data-index-name attribute to set index for the widget search requests.

  7. Edit the HTML structure around <search-box> to set the desired layout. The existing classes are used for the built-in theme.

  8. Modify the search-page attribute in <search-box> to set the redirect page.
    ="@Model.HawksearchSearchingAPI"
             data-hawksearch-autocomplete-api="@Model.AutocompleteUrl"
             data-json-params="@Model.Data"
             data-search-page="@Model.ResultsUrl"
             data-index-name="@Model.Index"
             data-current-culture="@Model.CurrentCulture">
        </div>
    
        <script data-translations="react-translations" type="application/json">
            {
            "Narrow Results": "@Html.HtmlSanitize(Html.Resource("NarrowResults", "HawkWidgetsResources"))",
            "Search Results": "@Html.HtmlSanitize(Html.Resource("SearchResults", "HawkWidgetsResources"))",
            "Search Results for": "@Html.HtmlSanitize(Html.Resource("SearchResultsFor", "HawkWidgetsResources"))",
            "Sort By": "@Html.HtmlSanitize(Html.Resource("SortBy", "HawkWidgetsResources"))",
            "Enter a search term": "@Html.HtmlSanitize(Html.Resource("EnterKeyword", "HawkWidgetsResources"))",
            "Quick Lookup": "@Html.HtmlSanitize(Html.Resource("QuickLookup", "HawkWidgetsResources"))",
            "Clear All": "@Html.HtmlSanitize(Html.Resource("ClearAll", "HawkWidgetsResources"))",
            "Clear": "@Html.HtmlSanitize(Html.Resource("Clear", "HawkWidgetsResources"))",
            "No Results": "@Html.HtmlSanitize(Html.Resource("NoResults", "HawkWidgetsResources"))",
            "Loading": "@Html.HtmlSanitize(Html.Resource("Loading", "HawkWidgetsResources"))",
            "You've Selected": "@Html.HtmlSanitize(Html.Resource("YouSelected", "HawkWidgetsResources"))"
            }
        </script>
  9. Save, re-build and refresh the page.

...