- Send total results with link search results

- Change how "# More" is shown to wait for all searches first
This commit is contained in:
nathan 2024-01-08 11:59:24 -07:00
parent 76533722d1
commit cfc7efde15
2 changed files with 14 additions and 7 deletions

View File

@ -445,15 +445,17 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
protected async _moreResultsTemplate()
{
await this.updateComplete;
const moreCount = this._total_result_count - this.select?.querySelectorAll("sl-option.match").length;
if(this._total_result_count <= 0 || moreCount == 0 || !this.select)
if(this._total_result_count <= 0 || !this.select || !this._searchPromise)
{
return nothing;
}
return this._searchPromise.then(() =>
{
const moreCount = this._total_result_count - this.select?.querySelectorAll("sl-option.match").length;
const more = this.egw().lang("%1 more...", moreCount);
return html`<span class="more">${more}</span>`;
});
}
protected _searchInputTemplate()

View File

@ -112,7 +112,7 @@ class Link extends Etemplate\Widget
$response = Api\Json\Response::get();
// convert associative array to a real array with value attribute, to preserve the order of numeric keys
$response->data(array_values(array_map(static function($key, $value)
$result = array_values(array_map(static function ($key, $value)
{
if (is_array($value))
{
@ -122,7 +122,12 @@ class Link extends Etemplate\Widget
'value' => $key,
'label' => $value,
];
}, array_keys($links), $links)));
}, array_keys($links), $links));
if(array_key_exists('total', $options))
{
$result['total'] = $options['total'];
}
$response->data($result);
}
/**