mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +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 {Et2Select} from "../Et2Select/Et2Select";
|
||||||
import {Et2LinkAppSelect} from "./Et2LinkAppSelect";
|
import {Et2LinkAppSelect} from "./Et2LinkAppSelect";
|
||||||
import {Et2Link} from "./Et2Link";
|
import {Et2Link} from "./Et2Link";
|
||||||
import {cleanSelectOptions} from "../Et2Select/FindSelectOptions";
|
|
||||||
|
|
||||||
export class Et2LinkSearch extends Et2Select
|
export class Et2LinkSearch extends Et2Select
|
||||||
{
|
{
|
||||||
@ -75,9 +74,7 @@ export class Et2LinkSearch extends Et2Select
|
|||||||
}
|
}
|
||||||
return request.then((result) =>
|
return request.then((result) =>
|
||||||
{
|
{
|
||||||
const entries = cleanSelectOptions(result);
|
return this._processResultCount(result);
|
||||||
this.processRemoteResults(entries);
|
|
||||||
return entries;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,6 +419,10 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
|||||||
{
|
{
|
||||||
this.__value = this.__value != "" ? [this.__value] : [];
|
this.__value = this.__value != "" ? [this.__value] : [];
|
||||||
}
|
}
|
||||||
|
else if(!this.multiple && Array.isArray(this.__value))
|
||||||
|
{
|
||||||
|
this.__value = this.__value.toString();
|
||||||
|
}
|
||||||
if(this.select)
|
if(this.select)
|
||||||
{
|
{
|
||||||
this.select.value = this.__value;
|
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)),
|
return this.egw().request(this.egw().link(this.egw().ajaxUrl(this.egw().decodePath(this.searchUrl)),
|
||||||
{query: search, ...sendOptions}), [search, sendOptions]).then((results) =>
|
{query: search, ...sendOptions}), [search, sendOptions]).then((results) =>
|
||||||
{
|
{
|
||||||
// If results have a total included, pull it out.
|
return this._processResultCount(results);
|
||||||
// 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;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Add in remote results
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user