mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:05:16 +01:00
Et2Select fixes
- Fix sometimes not shown emptyLabel - Fix LinkSearch result count
This commit is contained in:
parent
2b7f4ae5ee
commit
9f46ee5e62
@ -11,7 +11,6 @@ import {css} from "lit";
|
||||
import {Et2Select} from "../Et2Select/Et2Select";
|
||||
import {Et2LinkAppSelect} from "./Et2LinkAppSelect";
|
||||
import {Et2Link} from "./Et2Link";
|
||||
import {cleanSelectOptions} from "../Et2Select/FindSelectOptions";
|
||||
|
||||
export class Et2LinkSearch extends Et2Select
|
||||
{
|
||||
@ -75,9 +74,7 @@ export class Et2LinkSearch extends Et2Select
|
||||
}
|
||||
return request.then((result) =>
|
||||
{
|
||||
const entries = cleanSelectOptions(result);
|
||||
this.processRemoteResults(entries);
|
||||
return entries;
|
||||
return this._processResultCount(result);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -419,6 +419,10 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
||||
{
|
||||
this.__value = this.__value != "" ? [this.__value] : [];
|
||||
}
|
||||
else if(!this.multiple && Array.isArray(this.__value))
|
||||
{
|
||||
this.__value = this.__value.toString();
|
||||
}
|
||||
if(this.select)
|
||||
{
|
||||
this.select.value = this.__value;
|
||||
|
@ -1252,27 +1252,40 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
||||
return this.egw().request(this.egw().link(this.egw().ajaxUrl(this.egw().decodePath(this.searchUrl)),
|
||||
{query: search, ...sendOptions}), [search, sendOptions]).then((results) =>
|
||||
{
|
||||
// If results have a total included, pull it out.
|
||||
// It will cause errors if left in the results
|
||||
if(typeof results.total !== "undefined")
|
||||
{
|
||||
this._total_result_count += results.total;
|
||||
delete results.total;
|
||||
// Make it an array, since it was probably an object, and cleanSelectOptions() treats objects differently
|
||||
results = Object.values(results);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._total_result_count += results.length;
|
||||
}
|
||||
let entries = cleanSelectOptions(results);
|
||||
let entryCount = entries.length;
|
||||
this._total_result_count -= this.processRemoteResults(entries);
|
||||
|
||||
return entries;
|
||||
return this._processResultCount(results);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update total result count, checking results for a total attribute, then further processing the results
|
||||
* into select options
|
||||
*
|
||||
* @param results
|
||||
* @returns {SelectOption[]}
|
||||
* @protected
|
||||
*/
|
||||
protected _processResultCount(results)
|
||||
{
|
||||
// If results have a total included, pull it out.
|
||||
// It will cause errors if left in the results
|
||||
if(typeof results.total !== "undefined")
|
||||
{
|
||||
this._total_result_count += results.total;
|
||||
delete results.total;
|
||||
// Make it an array, since it was probably an object, and cleanSelectOptions() treats objects differently
|
||||
results = Object.values(results);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._total_result_count += results.length;
|
||||
}
|
||||
let entries = cleanSelectOptions(results);
|
||||
let entryCount = entries.length;
|
||||
this._total_result_count -= this.processRemoteResults(entries);
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add in remote results
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user