Resource categories & distribution list expansion & fixes for planner view

This commit is contained in:
nathangray 2016-07-21 10:21:04 -06:00
parent 6108123fe7
commit 99824b5510
3 changed files with 61 additions and 5 deletions

View File

@ -918,7 +918,7 @@ et2_calendar_event.owner_check = function owner_check(event, parent, owner_too)
{
owner_too = app.calendar.state.status_filter === 'owner';
}
var options = false
var options = false;
if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner'))
{
options = app.calendar.sidebox_et2.getWidgetById('owner').taglist.getSelection();

View File

@ -363,10 +363,50 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
row_labels: function() {
var labels = [];
var already_added = [];
var options = false;
if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner'))
{
options = app.calendar.sidebox_et2.getWidgetById('owner').taglist.getSelection();
}
else
{
options = this.getArrayMgr("sel_options").getRoot().getEntry('owner');
}
for(var i = 0; i < this.options.owner.length; i++)
{
var user = this.options.owner[i];
if (user < 0) // groups
// Handle grouped resources like mailing lists - pull it from sidebox owner
// and expand to their contents
if(isNaN(user) && options && options.find)
{
var resource = options.find(function(element) {return element.id == user;}) || {};
if(resource && resource.resources)
{
for(var j = 0; j < resource.resources.length; j++)
{
var id = resource.resources[j];
if(already_added.indexOf(''+id) < 0)
{
labels.push({
id: id,
label: this._get_owner_name(id),
data: {participants:id,owner:id}
});
already_added.push(''+id);
}
}
}
else if(already_added.indexOf(''+user) < 0)
{
labels.push({
id: user,
label: this._get_owner_name(user),
data: {participants:id,owner:id}
});
already_added.push(''+user);
}
}
else if (user < 0) // groups
{
egw.accountData(user,'account_fullname',true,function(result) {
for(var id in result)

View File

@ -322,6 +322,10 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend
// 0 means current user
user = egw.user('account_id');
}
if(et2_calendar_view.owner_name_cache[user])
{
return et2_calendar_view.owner_name_cache[user];
}
if (!isNaN(user))
{
user = parseInt(user);
@ -349,16 +353,23 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend
}
if(options && options.find)
{
user = options.find(function(element) {return element.id == user;}) || {};
label = user.label;
var found = options.find(function(element) {return element.id == user;}) || {};
if(found && found.label)
{
label = found.label;
}
}
else
if(!label)
{
// No sidebox? Must be in home or sitemgr (no caching) - ask directly
label = '?';
egw.json('calendar_owner_etemplate_widget::ajax_owner',user,function(data) {label = data;}, this).sendRequest();
}
}
if(label)
{
et2_calendar_view.owner_name_cache[user] = label;
}
return label;
},
@ -592,6 +603,11 @@ jQuery.extend(et2_calendar_view,
);
},
/**
* Cache to map owner & resource IDs to names, helps cut down on server requests
*/
owner_name_cache: {},
holiday_cache: {},
/**
* Fetch and cache a list of the year's holidays