mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
Stop using hardcoded default of 100 for search
Now using max of maxmatches preference and 100
This commit is contained in:
parent
f4cb19bea6
commit
91f70e354d
@ -242,13 +242,6 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
|||||||
*/
|
*/
|
||||||
protected static MIN_CHARS = 2;
|
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
|
// Hold the original option data from earlier search results, since we discard on subsequent search
|
||||||
private _selected_remote = <SelectOption[]>[];
|
private _selected_remote = <SelectOption[]>[];
|
||||||
|
|
||||||
@ -1223,6 +1216,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
|||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const signal = controller.signal;
|
const signal = controller.signal;
|
||||||
let response_ok = false;
|
let response_ok = false;
|
||||||
|
let resultLimit = Math.max(parseInt(this.egw().preference('maxmatchs', 'common')), 100);
|
||||||
return StaticOptions.cached_from_file(this, this.searchUrl)
|
return StaticOptions.cached_from_file(this, this.searchUrl)
|
||||||
.then(options =>
|
.then(options =>
|
||||||
{
|
{
|
||||||
@ -1234,9 +1228,9 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
|||||||
});
|
});
|
||||||
// Limit results
|
// Limit results
|
||||||
this._total_result_count += filtered.length;
|
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
|
// Add the matches
|
||||||
this._total_result_count -= this.processRemoteResults(filtered);
|
this._total_result_count -= this.processRemoteResults(filtered);
|
||||||
@ -1269,7 +1263,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
|||||||
{
|
{
|
||||||
// Include a limit, even if options don't, to avoid massive lists breaking the UI
|
// Include a limit, even if options don't, to avoid massive lists breaking the UI
|
||||||
let sendOptions = {
|
let sendOptions = {
|
||||||
num_rows: Et2WidgetWithSearch.RESULT_LIMIT,
|
num_rows: parseInt(this.egw().preference('maxmatchs', 'common')) ?? 100,
|
||||||
...options
|
...options
|
||||||
}
|
}
|
||||||
return this.egw().request(this.egw().link(this.egw().ajaxUrl(this.egw().decodePath(this.searchUrl)),
|
return this.egw().request(this.egw().link(this.egw().ajaxUrl(this.egw().decodePath(this.searchUrl)),
|
||||||
|
@ -41,11 +41,6 @@ export type TreeItemData = SelectOption & {
|
|||||||
*/
|
*/
|
||||||
export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
|
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
|
//does not work because it would need to be run on the shadow root
|
||||||
//@query("sl-tree-item[selected]") selected: SlTreeItem;
|
//@query("sl-tree-item[selected]") selected: SlTreeItem;
|
||||||
|
|
||||||
|
@ -106,7 +106,10 @@ class Link extends Etemplate\Widget
|
|||||||
public static function ajax_link_search($app, $type, $pattern, $options=array())
|
public static function ajax_link_search($app, $type, $pattern, $options=array())
|
||||||
{
|
{
|
||||||
$options['type'] = $type ?: $options['type'];
|
$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);
|
$links = Api\Link::query($app, $pattern, $options);
|
||||||
|
|
||||||
|
@ -807,7 +807,10 @@ class Link extends Link\Storage
|
|||||||
echo "Options: "; _debug_array($options);
|
echo "Options: "; _debug_array($options);
|
||||||
}
|
}
|
||||||
// limit number of returned rows by default to 100, if no limit is set
|
// 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));
|
$result = self::exec($method, array($pattern, &$options));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user