From 91f70e354d0aeb509899faa6110da66a8dd3850b Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 20 Mar 2024 16:50:52 -0600 Subject: [PATCH] Stop using hardcoded default of 100 for search Now using max of maxmatches preference and 100 --- api/js/etemplate/Et2Select/SearchMixin.ts | 14 ++++---------- api/js/etemplate/Et2Tree/Et2Tree.ts | 5 ----- api/src/Etemplate/Widget/Link.php | 5 ++++- api/src/Link.php | 5 ++++- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index 5b4e5cdbbe..e5d9d21880 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -242,13 +242,6 @@ export const Et2WithSearchMixin = dedupeMixin( */ protected static MIN_CHARS = 2; - /** - * Limit server searches to 100 results, matches Link::DEFAULT_NUM_ROWS - * @type {number} - */ - static RESULT_LIMIT : number = 100; - - // Hold the original option data from earlier search results, since we discard on subsequent search private _selected_remote = []; @@ -1223,6 +1216,7 @@ export const Et2WithSearchMixin = dedupeMixin( const controller = new AbortController(); const signal = controller.signal; let response_ok = false; + let resultLimit = Math.max(parseInt(this.egw().preference('maxmatchs', 'common')), 100); return StaticOptions.cached_from_file(this, this.searchUrl) .then(options => { @@ -1234,9 +1228,9 @@ export const Et2WithSearchMixin = dedupeMixin( }); // Limit results this._total_result_count += filtered.length; - if(filtered.length > Et2WidgetWithSearch.RESULT_LIMIT) + if(filtered.length > resultLimit) { - filtered.splice(Et2WidgetWithSearch.RESULT_LIMIT); + filtered.splice(resultLimit); } // Add the matches this._total_result_count -= this.processRemoteResults(filtered); @@ -1269,7 +1263,7 @@ export const Et2WithSearchMixin = dedupeMixin( { // Include a limit, even if options don't, to avoid massive lists breaking the UI let sendOptions = { - num_rows: Et2WidgetWithSearch.RESULT_LIMIT, + num_rows: parseInt(this.egw().preference('maxmatchs', 'common')) ?? 100, ...options } return this.egw().request(this.egw().link(this.egw().ajaxUrl(this.egw().decodePath(this.searchUrl)), diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index 6f2973c402..8c2b6df0f6 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -41,11 +41,6 @@ export type TreeItemData = SelectOption & { */ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) { - /** - * Limit server searches to 100 results, matches Link::DEFAULT_NUM_ROWS - * @type {number} - */ - static RESULT_LIMIT: number = 100; //does not work because it would need to be run on the shadow root //@query("sl-tree-item[selected]") selected: SlTreeItem; diff --git a/api/src/Etemplate/Widget/Link.php b/api/src/Etemplate/Widget/Link.php index aac98fa108..8321c3e76e 100644 --- a/api/src/Etemplate/Widget/Link.php +++ b/api/src/Etemplate/Widget/Link.php @@ -106,7 +106,10 @@ class Link extends Etemplate\Widget public static function ajax_link_search($app, $type, $pattern, $options=array()) { $options['type'] = $type ?: $options['type']; - if(!$options['num_rows']) $options['num_rows'] = 100; + if(!$options['num_rows']) + { + $options['num_rows'] = max((int)$GLOBALS['egw_info']['user']['preference']['common']['maxmatchs'], 100); + } $links = Api\Link::query($app, $pattern, $options); diff --git a/api/src/Link.php b/api/src/Link.php index 5ee5bb8d62..3e1c0b738d 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -807,7 +807,10 @@ class Link extends Link\Storage echo "Options: "; _debug_array($options); } // limit number of returned rows by default to 100, if no limit is set - if (!isset($options['num_rows'])) $options['num_rows'] = self::DEFAULT_NUM_ROWS; + if(!isset($options['num_rows'])) + { + $options['num_rows'] = max((int)$GLOBALS['egw_info']['user']['preference']['common']['maxmatchs'], self::DEFAULT_NUM_ROWS); + } $result = self::exec($method, array($pattern, &$options));