Adds form task, token to search form. Adds url updater to search area.
This commit is contained in:
parent
461edf5c3f
commit
7759738938
@ -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**
|
||||
|
@ -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**
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 <b>%s</b> 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 <b>Show in All List Views</b> 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 <b>single filter</b> 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 <b>%s</b> has been added for the <b>first time</b>. Please <i>investigate</i> to ensure the correct code/string was used! <b>Should you not know about this NEW external code/string being added, then this is a serious danger! and requires immediate attention!</b> Do not ignore this warning as it will only show <b>once</b>."
|
||||
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 <b>%s</b> has been <b>changed</b> since the last compilation. Please investigate to ensure the changes are safe! <b>Should you not expect this change to the external code/string being added, then this is a serious issue! and requires immediate attention!</b> Do not ignore this warning as it will only show <b>once</b>."
|
||||
COM_COMPONENTBUILDER_THE_COMPONENT="The Component"
|
||||
|
@ -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))
|
||||
|
@ -42,10 +42,6 @@ $search_value = $this->form->getField('search_value');
|
||||
</script>
|
||||
<?php $urlId = (isset($this->item->id)) ? '&id='. (int) $this->item->id : ''; ?>
|
||||
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<?php echo JText::_('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'); ?>
|
||||
</div>
|
||||
<hr />
|
||||
<?php if(!empty( $this->sidebar)): ?>
|
||||
<div id="j-sidebar-container" class="span2">
|
||||
<?php echo $this->sidebar; ?>
|
||||
@ -143,6 +139,8 @@ $search_value = $this->form->getField('search_value');
|
||||
<?php echo $this->form->getInput('item_code'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
@ -257,7 +257,7 @@ class ComponentbuilderViewSearch extends HtmlView
|
||||
'class' => 'list_class',
|
||||
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_TABLE_TO_SEARCH',
|
||||
'required' => 'true',
|
||||
'default' => -1];
|
||||
'default' => $this->urlvalues['table_name']];
|
||||
// start the component options
|
||||
$options = [];
|
||||
$options['-1'] = 'COM_COMPONENTBUILDER__SEARCH_ALL_';
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="4" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>8th November, 2022</creationDate>
|
||||
<creationDate>12th November, 2022</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>https://dev.vdm.io</authorUrl>
|
||||
|
@ -102,10 +102,10 @@ class Config extends BaseConfig
|
||||
/**
|
||||
* get posted area/table
|
||||
*
|
||||
* @return string Table name
|
||||
* @return string|null Table name
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getTablename(): string
|
||||
protected function getTablename(): ?string
|
||||
{
|
||||
return $this->input->get('table_name', null, 'word');
|
||||
}
|
||||
@ -113,10 +113,10 @@ class Config extends BaseConfig
|
||||
/**
|
||||
* get posted field
|
||||
*
|
||||
* @return string Field name
|
||||
* @return string|null Field name
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getFieldname(): string
|
||||
protected function getFieldname(): ?string
|
||||
{
|
||||
return $this->input->get('field_name', null, 'word');
|
||||
}
|
||||
@ -138,7 +138,7 @@ class Config extends BaseConfig
|
||||
* @return int we start at 0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getFieldcounter(): ?int
|
||||
protected function getFieldcounter(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -149,7 +149,7 @@ class Config extends BaseConfig
|
||||
* @return int we start at 0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getLinecounter(): ?int
|
||||
protected function getLinecounter(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user