[FIX] Allow to use attendee_people without use_contact. Allow to use an avatar in each event distinct from sidebar. Allow False to hide avatar in sidebar.

bzr revid: jke@openerp.com-20140429150038-zkf2dwxu15tp04qd
This commit is contained in:
Kersten Jeremy 2014-04-29 17:00:38 +02:00
parent 23f36f03ce
commit 0853de32fb
1 changed files with 28 additions and 20 deletions

View File

@ -197,6 +197,13 @@ openerp.web_calendar = function(instance) {
} else { } else {
this.avatar_title = attrs.avatar_title; this.avatar_title = attrs.avatar_title;
} }
if (isNullOrUndef(attrs.avatar_filter)) {
this.avatar_filter = this.avatar_model;
} else {
this.avatar_filter = attrs.avatar_filter;
}
this.color_field = attrs.color; this.color_field = attrs.color;
if (this.color_field && this.selected_filters.length === 0) { if (this.color_field && this.selected_filters.length === 0) {
@ -578,7 +585,7 @@ openerp.web_calendar = function(instance) {
if (!self.colorIsAttendee || the_attendee_people != temp_ret[self.color_field]) { if (!self.colorIsAttendee || the_attendee_people != temp_ret[self.color_field]) {
tempColor = (self.all_filters[the_attendee_people] !== undefined) tempColor = (self.all_filters[the_attendee_people] !== undefined)
? self.all_filters[the_attendee_people].color ? self.all_filters[the_attendee_people].color
: self.all_filters[-1].color; : (self.all_filters[-1] ? self.all_filters[-1].color : 1);
the_title_avatar += '<i class="fa fa-user attendee_head color_'+tempColor+'" title="' + self.all_attendees[the_attendee_people] + '" ></i>'; the_title_avatar += '<i class="fa fa-user attendee_head color_'+tempColor+'" title="' + self.all_attendees[the_attendee_people] + '" ></i>';
}//else don't add myself }//else don't add myself
} }
@ -701,7 +708,6 @@ openerp.web_calendar = function(instance) {
} }
if (!self.useContacts) { // If we use all peoples displayed in the current month as filter in sidebars if (!self.useContacts) { // If we use all peoples displayed in the current month as filter in sidebars
var filter_value; var filter_value;
var filter_item; var filter_item;
@ -714,7 +720,7 @@ openerp.web_calendar = function(instance) {
value: filter_value, value: filter_value,
label: e[self.color_field][1], label: e[self.color_field][1],
color: self.get_color(filter_value), color: self.get_color(filter_value),
avatar_model: self.avatar_model, avatar_model: (_.str.toBoolElse(self.avatar_filter, true) ? self.avatar_filter : false ),
is_checked: true is_checked: true
}; };
self.all_filters[e[self.color_field][0]] = filter_item; self.all_filters[e[self.color_field][0]] = filter_item;
@ -735,7 +741,7 @@ openerp.web_calendar = function(instance) {
return null; return null;
}); });
} }
return self.perform_necessary_name_gets(events).then(callback);
} }
else { //WE USE CONTACT else { //WE USE CONTACT
if (self.attendee_people !== undefined) { if (self.attendee_people !== undefined) {
@ -752,25 +758,27 @@ openerp.web_calendar = function(instance) {
} }
} }
var all_attendees = $.map(events, function (e) { return e[self.attendee_people]; });
all_attendees = _.chain(all_attendees).flatten().uniq().value(); }
self.all_attendees = {}; var all_attendees = $.map(events, function (e) { return e[self.attendee_people]; });
if (self.avatar_title !== null) { all_attendees = _.chain(all_attendees).flatten().uniq().value();
new instance.web.Model(self.avatar_title).query(["name"]).filter([["id", "in", all_attendees]]).all().then(function(result) {
_.each(result, function(item) { self.all_attendees = {};
self.all_attendees[item.id] = item.name; if (self.avatar_title !== null) {
}); new instance.web.Model(self.avatar_title).query(["name"]).filter([["id", "in", all_attendees]]).all().then(function(result) {
}).done(function() { _.each(result, function(item) {
return self.perform_necessary_name_gets(events).then(callback); self.all_attendees[item.id] = item.name;
});
}
else {
_.each(all_attendees,function(item){
self.all_attendees[item] = '';
}); });
}).done(function() {
return self.perform_necessary_name_gets(events).then(callback); return self.perform_necessary_name_gets(events).then(callback);
} });
}
else {
_.each(all_attendees,function(item){
self.all_attendees[item] = '';
});
return self.perform_necessary_name_gets(events).then(callback);
} }
}); });
}, },