MDL-69454 core_search: consistent content bank search
authorBas Brands <bas@moodle.com>
Mon, 31 Aug 2020 14:19:18 +0000 (16:19 +0200)
committerBas Brands <bas@moodle.com>
Mon, 21 Sep 2020 09:54:53 +0000 (11:54 +0200)
contentbank/amd/build/search.min.js
contentbank/amd/build/search.min.js.map
contentbank/amd/build/selectors.min.js
contentbank/amd/build/selectors.min.js.map
contentbank/amd/src/search.js
contentbank/amd/src/selectors.js
contentbank/templates/bankcontent/search.mustache

index 16c80b0..8309c24 100644 (file)
Binary files a/contentbank/amd/build/search.min.js and b/contentbank/amd/build/search.min.js differ
index 0e06258..ae3bad7 100644 (file)
Binary files a/contentbank/amd/build/search.min.js.map and b/contentbank/amd/build/search.min.js.map differ
index 26786ec..5aba987 100644 (file)
Binary files a/contentbank/amd/build/selectors.min.js and b/contentbank/amd/build/selectors.min.js differ
index 2efa6a5..62be444 100644 (file)
Binary files a/contentbank/amd/build/selectors.min.js.map and b/contentbank/amd/build/selectors.min.js.map differ
index e604abc..40a99a5 100644 (file)
@@ -80,8 +80,7 @@ const registerListenerEvents = (root) => {
  * @param {String} searchQuery The search query.
  */
 const toggleSearchResultsView = async(body, searchQuery) => {
-    const clearSearchButton = body.find(selectors.elements.clearsearch)[0];
-    const searchIcon = body.find(selectors.elements.searchicon)[0];
+    const clearSearchButton = body.find(selectors.actions.clearSearch)[0];
 
     const navbarBreadcrumb = body.find(selectors.elements.cbnavbarbreadcrumb)[0];
     const navbarTotal = body.find(selectors.elements.cbnavbartotalsearch)[0];
@@ -91,7 +90,6 @@ const toggleSearchResultsView = async(body, searchQuery) => {
         // As the search query is present, search results should be displayed.
 
         // Display the "clear" search button in the activity chooser search bar.
-        searchIcon.classList.add('d-none');
         clearSearchButton.classList.remove('d-none');
 
         // Change the cb-navbar to display total items found.
@@ -103,7 +101,6 @@ const toggleSearchResultsView = async(body, searchQuery) => {
 
         // Hide the "clear" search button in the activity chooser search bar.
         clearSearchButton.classList.add('d-none');
-        searchIcon.classList.remove('d-none');
 
         // Display again the breadcrumb in the navbar.
         navbarBreadcrumb.classList.remove('d-none');
index 60fe955..f6de1b2 100644 (file)
@@ -42,7 +42,7 @@ export default {
     },
     actions: {
         search: getDataSelector('action', 'searchcontent'),
-        clearSearch: getDataSelector('action', 'clearsearchcontent'),
+        clearSearch: getDataSelector('action', 'clearsearch'),
         viewgrid: getDataSelector('action', 'viewgrid'),
         viewlist: getDataSelector('action', 'viewlist'),
         sortname: getDataSelector('action', 'sortname'),
@@ -55,8 +55,6 @@ export default {
         listitem: '.cb-listitem',
         cbnavbarbreadcrumb: '.cb-navbar-breadbrumb',
         cbnavbartotalsearch: '.cb-navbar-totalsearch',
-        clearsearch: '.input-group-append .clear-icon',
-        searchicon: '.input-group-append .search-icon',
         searchinput: '#searchinput',
         sortbutton: '.cb-btnsort'
     },
index 8d02863..6fc2e58 100644 (file)
     @template core_contentbank/bankcontent/search
 
     Example context (json):
-    {}
+    {
+    }
 
 }}
-<div class="searchbar input-group" role="search">
-    <label for="searchinput">
-        <span class="sr-only">{{#str}} searchcontentbankbyname, contentbank {{/str}}</span>
-    </label>
-    <input type="text"
-           id="searchinput"
-           class="form-control searchinput border-right-0"
-           placeholder="{{#str}} search, core {{/str}}"
-           name="search"
-           autocomplete="off"
-    >
-    <div class="input-group-append">
-        <div class="input-group-text bg-transparent">
-            <div class="search-icon">
-                <button class="btn p-0 align-baseline icon-no-margin" data-action="searchcontent"
-                    aria-label="{{#str}} search, core {{/str}}">
-                    <span class="d-flex" aria-hidden="true">{{#pix}} a/search, core {{/pix}}</span>
-                </button>
-            </div>
-            <div class="clear-icon d-none">
-                <button class="btn p-0 align-baseline icon-no-margin" data-action="clearsearchcontent"
-                    aria-label="{{#str}} clearsearch, core {{/str}}">
-                    <span class="d-flex" aria-hidden="true">{{#pix}} e/cancel_solid_circle, core {{/pix}}</span>
-                </button>
-            </div>
-        </div>
-    </div>
-</div>
\ No newline at end of file
+
+{{< core/search_input_auto }}
+    {{$label}}{{#str}}
+        searchcontentbankbyname, contentbank
+    {{/str}}{{/label}}
+    {{$placeholder}}{{#str}}
+        search, core
+    {{/str}}{{/placeholder}}
+{{/ core/search_input_auto }}