diff --git a/README.md b/README.md index 0be143219..2a5bdfdb0 100644 --- a/README.md +++ b/README.md @@ -140,11 +140,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 8th November, 2022 ++ *Last Build*: 12th November, 2022 + *Version*: 3.1.11 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **334294** ++ *Line count*: **334324** + *Field count*: **2004** + *File count*: **2183** + *Folder count*: **381** diff --git a/admin/README.txt b/admin/README.txt index 0be143219..2a5bdfdb0 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -140,11 +140,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 8th November, 2022 ++ *Last Build*: 12th November, 2022 + *Version*: 3.1.11 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **334294** ++ *Line count*: **334324** + *Field count*: **2004** + *File count*: **2183** + *Folder count*: **381** diff --git a/admin/assets/js/search.js b/admin/assets/js/search.js index b228251b3..e22ca075c 100644 --- a/admin/assets/js/search.js +++ b/admin/assets/js/search.js @@ -26,15 +26,21 @@ const doSearch = async (signal, tables) => { // set some search values let searchValue = searchObject.value; let replaceValue = replaceObject.value; + let matchValue = matchObject.checked ? 1 : 0; + let wholeValue = wholeObject.checked ? 1 : 0; + let regexValue = regexObject.checked ? 1 : 0; // add the form data formData.append('table_name', ''); formData.append('type_search', typeSearch); formData.append('search_value', searchValue); formData.append('replace_value', replaceValue); - formData.append('match_case', matchObject.checked ? 1 : 0); - formData.append('whole_word', wholeObject.checked ? 1 : 0); - formData.append('regex_search', regexObject.checked ? 1 : 0); + formData.append('match_case', matchValue); + formData.append('whole_word', wholeValue); + formData.append('regex_search', regexValue); + + // update the URL + updateUrlQuery(searchValue, replaceValue, matchValue, wholeValue, regexValue, typeSearch); let abort_this_search_values = false; @@ -338,7 +344,7 @@ const replaceAll = async (signal, tables) => { if (regexValue == 0) { // set the replace value as the search value UIkit.modal.confirm(Joomla.JText._('COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_DO_A_REVERSE_SEARCH'), function(){ - setSearch(replaceValue, searchValue, matchValue, wholeValue, regexValue, 2); + startNewSearch(replaceValue, searchValue, matchValue, wholeValue, regexValue, 2); }, function () { UIkit.modal.confirm(Joomla.JText._('COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_REPEAT_THE_SAME_SEARCH'), function(){ startSearch(); @@ -484,6 +490,9 @@ const clearSelectedItem = async () => { */ const clearTableItems = async () => { let table = new DataTable('#search_results_table'); + // clear search + table.search('').columns().search( '' ); + // clear items table.clear().draw( true ); // hide the update all items @@ -512,22 +521,45 @@ const clearSearch = async () => { /** * JS Function to set the search and replace values */ -const setSearch = async (search, replace = '', match = 0, whole = 0, regex = 0, mode = 1) => { +const startNewSearch = async (search, replace = '', match = 0, whole = 0, regex = 0, mode = 1) => { + // redirect to a new search + window.location.href = getSearchURL(search, replace, match, whole, regex, mode); +}; + +/** + * JS Function to update the URL of the browser with the search query + */ +const updateUrlQuery = async (search, replace = '', match = 0, whole = 0, regex = 0, mode = 1) => { + // update the url query + window.history.pushState({}, '', getSearchURL(search, replace, match, whole, regex, mode)); +}; + +/** + * JS Function to get the current search URL + */ +const getSearchURL = (search, replace = '', match = 0, whole = 0, regex = 0, mode = 1) => { + // check if its a single table search + let table = tableObject.value; + let table_name = ''; + if (table != -1) { + table_name = '&table_name=' + urlencode(table); + } // update the type of search if (mode == 1) { - window.location.href = UrlSearch + + return UrlSearch + table_name + '&search_value=' + urlencode(search) + '&type_search=1&match_case=' + match + '&whole_word=' + whole + '®ex_search=' + regex; } else if (mode == 2) { - window.location.href = UrlSearch + + return UrlSearch + table_name + '&search_value=' + urlencode(search) + '&replace_value=' + urlencode(replace) + '&type_search=2&match_case=' + match + '&whole_word=' + whole + '®ex_search=' + regex; } + return UrlSearch + table_name; }; /** @@ -591,7 +623,7 @@ const startSearch = (field, forced = false) => { } // get search value const searchValue = searchObject.value; - if (searchValue.length > 3 || (searchValue.length > 0 && forced)) { + if (searchValue.length > 2 || (searchValue.length > 0 && forced)) { // Cancel any ongoing requests if (controller) controller.abort(); diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 535f2324a..695c3856b 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -9191,7 +9191,6 @@ COM_COMPONENTBUILDER_THE_BSB_LIBRARY_CAN_NOT_BE_DELETED_OR_THINGS_WILL_BREAK="Th COM_COMPONENTBUILDER_THE_BSB_RETURNED_AN_INVALID_STRING="The %s returned an invalid string!" COM_COMPONENTBUILDER_THE_BSHOW_IN_ALL_LIST_VIEWSB_OPTION_WILL_ADD_THIS_FIELD_TO_ALL_LIST_VIEWS_ADMIN_AMP_LINKED="The Show in All List Views option will Add this field to all list views, admin & linked." COM_COMPONENTBUILDER_THE_BSINGLE_FILTERB_SELECTION_OPTION_ALLOWS_THE_USER_TO_SELECT_JUST_ONE_VALUE_IN_THIS_FILTERFIELD="The single filter selection option allows the user to select just one value in this filter/field." -COM_COMPONENTBUILDER_THE_CHANGES_YOU_MAKE_HERE_CAN_NOT_BE_UNDONE_THEREFORE_YOU_MUST_ALWAYS_USE_THE_UPDATE_AND_REPLACE_FEATURES_WITH_GREAT_CAUTION_SEARCH_FEATURE_IS_IN_BETA_STAGE="The changes you make here can not be undone, therefore you must always use the update and replace features with great caution. Search feature is in BETA stage." COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_ADDED_FOR_THE_BFIRST_TIMEB_PLEASE_IINVESTIGATEI_TO_ENSURE_THE_CORRECT_CODESTRING_WAS_USED_BSHOULD_YOU_NOT_KNOW_ABOUT_THIS_NEW_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_DANGER_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from %s has been added for the first time. Please investigate to ensure the correct code/string was used! Should you not know about this NEW external code/string being added, then this is a serious danger! and requires immediate attention! Do not ignore this warning as it will only show once." COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_BCHANGEDB_SINCE_THE_LAST_COMPILATION_PLEASE_INVESTIGATE_TO_ENSURE_THE_CHANGES_ARE_SAFE_BSHOULD_YOU_NOT_EXPECT_THIS_CHANGE_TO_THE_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_ISSUE_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from %s has been changed since the last compilation. Please investigate to ensure the changes are safe! Should you not expect this change to the external code/string being added, then this is a serious issue! and requires immediate attention! Do not ignore this warning as it will only show once." COM_COMPONENTBUILDER_THE_COMPONENT="The Component" diff --git a/admin/models/search.php b/admin/models/search.php index 78c11147c..792896e36 100644 --- a/admin/models/search.php +++ b/admin/models/search.php @@ -180,7 +180,8 @@ class ComponentbuilderModelSearch extends ItemModel 'replace_value' => SearchFactory::_('Config')->get('replace_value', ''), 'match_case' => SearchFactory::_('Config')->get('match_case', 0), 'whole_word' => SearchFactory::_('Config')->get('whole_word', 0), - 'regex_search' => SearchFactory::_('Config')->get('regex_search', 0) + 'regex_search' => SearchFactory::_('Config')->get('regex_search', 0), + 'table_name' => SearchFactory::_('Config')->get('table_name', -1) ]; if (empty($data)) diff --git a/admin/views/search/tmpl/default.php b/admin/views/search/tmpl/default.php index 3861bc6d4..7fde608d7 100644 --- a/admin/views/search/tmpl/default.php +++ b/admin/views/search/tmpl/default.php @@ -42,10 +42,6 @@ $search_value = $this->form->getField('search_value'); item->id)) ? '&id='. (int) $this->item->id : ''; ?> -