Skip to content

Commit

Permalink
Revert default min term length and remove new limit parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
HLeithner committed Dec 1, 2020
1 parent f21fd46 commit 46db2d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
10 changes: 1 addition & 9 deletions administrator/components/com_tags/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,7 @@
first="1"
last="3"
step="1"
default="1"
/>

<field
name="prefill_limit"
type="number"
label="COM_TAGS_CONFIG_TAG_PREFILL_LIMIT_LABEL"
default="30"
filter="integer"
default="3"
/>

<field
Expand Down
1 change: 0 additions & 1 deletion administrator/language/en-GB/com_tags.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ COM_TAGS_CONFIG_SELECTION_SETTINGS_LABEL="Item Selection"
COM_TAGS_CONFIG_SHARED_SETTINGS_DESC="These settings apply to all tag layouts unless they are changed for a specific menu item."
COM_TAGS_CONFIG_SHARED_SETTINGS_LABEL="Shared Layout"
COM_TAGS_CONFIG_TAG_MIN_LENGTH_LABEL="Minimum Search Length"
COM_TAGS_CONFIG_TAG_PREFILL_LIMIT_LABEL="Initial number of shown tags"
COM_TAGS_CONFIG_TAG_SETTINGS_DESC="These settings apply for a Tagged Items List or Compact List of Tagged Items unless they are changed for a specific menu item."
COM_TAGS_CONFIG_TAG_SETTINGS_LABEL="Tagged Items"
COM_TAGS_CONFIG_TAGGED_ITEMS_FIELD_LAYOUT_LABEL="Default Tagged Items Layout"
Expand Down
16 changes: 8 additions & 8 deletions libraries/src/Form/Field/TagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function getInput()
$data['options'] = $this->getOptions();
$data['isNested'] = $this->isNested();
$data['allowCustom'] = $this->allowCustom();
$data['minTermLength'] = (int) $this->comParams->get('min_term_length', 1);
$data['minTermLength'] = (int) $this->comParams->get('min_term_length', 3);

return $this->getRenderer($this->layout)->render($data);
}
Expand All @@ -133,7 +133,7 @@ protected function getOptions()
$options = [];

// This limit is only used with isRemoteSearch
$limit = (int) $this->comParams->get('prefill_limit', 30);
$prefillLimit = 30;
$isRemoteSearch = $this->isRemoteSearch();

$db = Factory::getDbo();
Expand Down Expand Up @@ -201,13 +201,13 @@ protected function getOptions()
// Preload only active values and 30 most used tags or fill up
if ($isRemoteSearch)
{
// Load the most $limit used tags
// Load the most $prefillLimit used tags
$topQuery = $db->getQuery(true)
->select($db->quoteName('tag_id'))
->from($db->quoteName('#__contentitem_tag_map'))
->group($db->quoteName('tag_id'))
->order('count(*)')
->setLimit($limit);
->setLimit($prefillLimit);

$db->setQuery($topQuery);
$topIds = $db->loadColumn();
Expand All @@ -220,7 +220,7 @@ protected function getOptions()
}

// Set the default limit for the main query
$query->setLimit($limit);
$query->setLimit($prefillLimit);

if (!empty($topIds))
{
Expand All @@ -241,8 +241,8 @@ protected function getOptions()

// Limit the main query to the missing amount of tags
$count = count($options);
$limit = $limit - $count;
$query->setLimit($limit);
$prefillLimit = $prefillLimit - $count;
$query->setLimit($prefillLimit);

// Exclude the already loaded tags from the main query
if ($count > 0)
Expand All @@ -253,7 +253,7 @@ protected function getOptions()
}

// Only execute the query if we need more tags not already loaded by the $preQuery query
if (!$isRemoteSearch || $limit > 0)
if (!$isRemoteSearch || $prefillLimit > 0)
{
// Get the options.
$db->setQuery($query);
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/HTML/Helpers/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function ajaxfield($selector = '#jform_tags', $allowCustom = true)
{
// Get the component parameters
$params = ComponentHelper::getParams('com_tags');
$minTermLength = (int) $params->get('min_term_length', 1);
$minTermLength = (int) $params->get('min_term_length', 3);

Text::script('JGLOBAL_KEEP_TYPING');
Text::script('JGLOBAL_LOOKING_FOR');
Expand Down

0 comments on commit 46db2d9

Please sign in to comment.