From d02a1d31a640d130c8a151d79652212f045165bf Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 4 Apr 2016 21:36:44 +0000 Subject: [PATCH] Fix missing calendar owner labels when they weren't in the default options --- calendar/js/et2_widget_planner.js | 45 ++++--------------------------- calendar/js/et2_widget_view.js | 32 +++++++++------------- 2 files changed, 18 insertions(+), 59 deletions(-) diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index fdc05fa0c9..eb1502ae82 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -324,42 +324,11 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e // Labels for the rows row_labels: function() { var labels = []; - var accounts = egw.accounts(); var already_added = []; for(var i = 0; i < this.options.owner.length; i++) { var user = this.options.owner[i]; - if(parseInt(user) === 0) - { - // 0 means current user - user = egw.user('account_id'); - } - if (isNaN(user)) // resources - { - var planner = this; - var label = egw.link_title('resources',user.match(/\d+/)[0],function(name) { - for(var j = 0; j < labels.length; j++) - { - if(labels[j].id == this) - { - labels[j].label = name; - break; - } - } - var row = planner.getWidgetById('planner_row_'+this); - if(row && row.set_label) - { - row.set_label(name); - } - },user); - if(!label) label = user; - if(already_added.indexOf(user) < 0) - { - labels.push({id: user, label: label, data: {participants:user,owner:''}}); - already_added.push(''+user); - } - } - else if (user < 0) // groups + if (user < 0) // groups { egw.accountData(user,'account_fullname',true,function(result) { for(var id in result) @@ -374,15 +343,11 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e } else // users { - user = parseInt(user); - for(var j = 0; j < accounts.length && already_added.indexOf(''+user) < 0; j++) + var label = this._get_owner_name(user); + if(already_added.indexOf(user) < 0) { - if(accounts[j].value === user) - { - labels.push({id: user, label: accounts[j].label, data: {participants:user,owner:user}}); - already_added.push(''+user); - break; - } + labels.push({id: user, label: label, data: {participants:user,owner:''}}); + already_added.push(''+user); } } } diff --git a/calendar/js/et2_widget_view.js b/calendar/js/et2_widget_view.js index 262f1373bb..ec779a86ce 100644 --- a/calendar/js/et2_widget_view.js +++ b/calendar/js/et2_widget_view.js @@ -308,28 +308,13 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend * @memberOf et2_calendar_view */ _get_owner_name: function _get_owner_name(user) { + var label = undefined; if(parseInt(user) === 0) { // 0 means current user user = egw.user('account_id'); } - if (isNaN(user)) // resources or contact - { - var application = 'home-accounts'; - switch(user[0]) - { - case 'c': - application = 'addressbook'; - break; - case 'r': - application = 'resources'; - break; - } - // This might not have a value right away - // send an empty function or it won't ask the server - user = egw.link_title(application,user.match(/\d+/)[0], function() {}, this); - } - else // users + if (!isNaN(user)) { user = parseInt(user); var accounts = egw.accounts('both'); @@ -337,12 +322,21 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend { if(accounts[j].value === user) { - user = accounts[j].label; + label = accounts[j].label; break; } } } - return user; + if(typeof label === 'undefined') + { + // Not found? Ask the sidebox owner widget, it gets updated + if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner')) + { + user = app.calendar.sidebox_et2.getWidgetById('owner').options.select_options.find(function(element) {return element.id == user;}) || {}; + label = user.label; + } + } + return label; }, /**