mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
* Calendar: Optimize fetching participant names to reduce requests
This commit is contained in:
parent
9463a0f395
commit
7ad8e57d2e
@ -140,12 +140,22 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
|
||||
public static function ajax_owner($id = null)
|
||||
{
|
||||
// Handle a request for a single ID
|
||||
if($id)
|
||||
if($id && !is_array($id))
|
||||
{
|
||||
$label = self::get_owner_label($id);
|
||||
Api\Json\Response::get()->data($label);
|
||||
return $label;
|
||||
}
|
||||
else if($id && is_array($id))
|
||||
{
|
||||
$labels = Array();
|
||||
foreach($id as $index => $_id)
|
||||
{
|
||||
$labels[$_id] = self::get_owner_label($_id);
|
||||
}
|
||||
Api\Json\Response::get()->data($labels);
|
||||
return $labels;
|
||||
}
|
||||
|
||||
$bo = new calendar_bo();
|
||||
$query = $_REQUEST['query'];
|
||||
|
@ -100,16 +100,31 @@ var et2_calendar_owner = /** @class */ (function (_super) {
|
||||
_super.prototype.set_value.call(this, _value);
|
||||
// If parent didn't find a label, label will be the same as ID so we
|
||||
// can find them that way
|
||||
var missing_labels = [];
|
||||
for (var i = 0; i < this.options.value.length; i++) {
|
||||
var value = this.options.value[i];
|
||||
if (value.id == value.label) {
|
||||
// Proper label was not found by parent - ask directly
|
||||
egw.json('calendar_owner_etemplate_widget::ajax_owner', value.id, function (data) {
|
||||
this.widget.options.value[this.i].label = data;
|
||||
this.widget.set_value(this.widget.options.value);
|
||||
}, this, true, { widget: this, i: i }).sendRequest();
|
||||
missing_labels.push(value.id);
|
||||
}
|
||||
}
|
||||
if (Object.keys(missing_labels).length > 0) {
|
||||
// Proper label was not found by parent - ask directly
|
||||
egw.json('calendar_owner_etemplate_widget::ajax_owner', [missing_labels], function (data) {
|
||||
var _loop_1 = function (owner) {
|
||||
if (!owner || typeof owner == "undefined")
|
||||
return "continue";
|
||||
var idx = this_1.options.value.find(function (element) { return element.id == owner; });
|
||||
if (idx) {
|
||||
idx.label = data[owner];
|
||||
}
|
||||
};
|
||||
var this_1 = this;
|
||||
for (var owner in data) {
|
||||
_loop_1(owner);
|
||||
}
|
||||
this.set_value(this.options.value);
|
||||
}, this, true, this).sendRequest();
|
||||
}
|
||||
if (this.taglist) {
|
||||
this.taglist.clear(true);
|
||||
this.taglist.addToSelection(this.options.value, true);
|
||||
|
@ -120,18 +120,31 @@ export class et2_calendar_owner extends et2_taglist_email
|
||||
|
||||
// If parent didn't find a label, label will be the same as ID so we
|
||||
// can find them that way
|
||||
let missing_labels = [];
|
||||
for(var i = 0; i < this.options.value.length; i++)
|
||||
{
|
||||
var value = this.options.value[i];
|
||||
if(value.id == value.label)
|
||||
{
|
||||
// Proper label was not found by parent - ask directly
|
||||
egw.json('calendar_owner_etemplate_widget::ajax_owner',value.id,function(data) {
|
||||
this.widget.options.value[this.i].label = data;
|
||||
this.widget.set_value(this.widget.options.value);
|
||||
}, this,true,{widget: this, i: i}).sendRequest();
|
||||
missing_labels.push(value.id);
|
||||
}
|
||||
}
|
||||
if(Object.keys(missing_labels).length > 0)
|
||||
{
|
||||
// Proper label was not found by parent - ask directly
|
||||
egw.json('calendar_owner_etemplate_widget::ajax_owner',[missing_labels],function(data) {
|
||||
for(let owner in data)
|
||||
{
|
||||
if(!owner || typeof owner == "undefined") continue;
|
||||
let idx = this.options.value.find(element => element.id == owner);
|
||||
if(idx)
|
||||
{
|
||||
idx.label = data[owner];
|
||||
}
|
||||
}
|
||||
this.set_value(this.options.value);
|
||||
}, this,true,this).sendRequest();
|
||||
}
|
||||
|
||||
if(this.taglist)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user