[ADD] option to globally stop showing group suggestions

bzr revid: mat@openerp.com-20130403151056-4vjno2k9n77drm6y
This commit is contained in:
Martin Trigaux
2013-04-03 17:10:56 +02:00
parent 788501fd78
commit 46110fbf29
7 changed files with 47 additions and 12 deletions
-2
View File
@@ -37,8 +37,6 @@ openerp.hr = function(session) {
self.$el.find('.oe_suggestions_employees').html( QWeb.render("hr.suggestions.employee", {'widget': self}) );
if (self.suggestions.length === 0) {
self.$(".oe_sidebar_employee").hide();
} else {
// self.renderFollowButtons();
}
});
},
+7 -2
View File
@@ -8,8 +8,13 @@
</t>
<!-- Suggested employees -->
<div t-name="hr.suggestions.employee" class="oe_sidebar_employee">
<p class="oe_suggestion_display">Suggested Employees</p>
<div t-name="hr.suggestions.employee" class="oe_sidebar_suggestion oe_sidebar_employee">
<p class="oe_suggestion_display">
Suggested Employees
<a class="oe_remove_suggestion oe_remove_suggestion_employees" rol="button">
<span class="oe_kanban_action oe_kanban_action_a">X</span>
</a>
</p>
<div class="oe_suggest_employees">
<t t-foreach="widget.suggestions" t-as="result">
<div class="oe_suggested_item">
+9
View File
@@ -200,3 +200,12 @@ class mail_group(osv.Model):
""" Wrapper because message_unsubscribe_users take a user_ids=None
that receive the context without the wrapper. """
return self.message_unsubscribe_users(cr, uid, ids, context=context)
def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None):
"""Show the suggestion of users if display_groups_suggestions if the
user perference allows it display_groups_suggestions"""
user = self.pool.get('res.users').browse(cr, uid, uid, context)
if not user.display_groups_suggestions:
return []
else:
return super(mail_group, self).get_suggested_thread(cr, uid, removed_suggested_threads, context)
+10 -2
View File
@@ -28,6 +28,7 @@ class res_users(osv.Model):
- add a preference about sending emails about notifications
- make a new user follow itself
- add a welcome message
- add suggestion preference
"""
_name = 'res.users'
_inherit = ['res.users']
@@ -37,10 +38,12 @@ class res_users(osv.Model):
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="cascade", required=True,
help="Email address internally associated with this user. Incoming "\
"emails will appear in the user's notifications."),
'display_groups_suggestions': fields.boolean("Display Group Suggestions"),
}
_defaults = {
'alias_domain': False, # always hide alias during creation
'display_groups_suggestions': True,
}
def __init__(self, pool, cr):
@@ -51,10 +54,10 @@ class res_users(osv.Model):
init_res = super(res_users, self).__init__(pool, cr)
# duplicate list to avoid modifying the original reference
self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
self.SELF_WRITEABLE_FIELDS.append('notification_email_send')
self.SELF_WRITEABLE_FIELDS.extend(['notification_email_send', 'display_groups_suggestions'])
# duplicate list to avoid modifying the original reference
self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
self.SELF_READABLE_FIELDS.extend(['notification_email_send', 'alias_domain', 'alias_name'])
self.SELF_READABLE_FIELDS.extend(['notification_email_send', 'alias_domain', 'alias_name', 'display_groups_suggestions'])
return init_res
def _auto_init(self, cr, context=None):
@@ -156,6 +159,11 @@ class res_users(osv.Model):
def message_create_partners_from_emails(self, cr, uid, emails, context=None):
return self.pool.get('res.partner').message_create_partners_from_emails(cr, uid, emails, context=context)
def stop_showing_group_suggestions(self, cr, uid, user_id, context=None):
"""Update display_groups_suggestions value to False"""
if context is None: context = {}
self.write(cr, uid, user_id, {"display_groups_suggestions": False}, context)
class res_users_mail_group(osv.Model):
""" Update of res.users class
+6 -4
View File
@@ -683,7 +683,7 @@
width: 300px;
}
.openerp .oe_mail_wall_aside > div {
.openerp .oe_mail_wall_aside .oe_sidebar_suggestion {
background-color: #EDEDF6;
border-radius: 2px;
padding: 10px;
@@ -710,16 +710,18 @@
.openerp .oe_mail_wall_aside .oe_suggestion_action {
margin-top: 10px;
}
.openerp .oe_mail_wall_aside .oe_remove_suggested_item {
.openerp .oe_mail_wall_aside .oe_remove_suggested_item,
.openerp .oe_mail_wall_aside .oe_remove_suggestion {
visibility:hidden;
width:3%;
float:right;
margin-right:20px;
}
.openerp .oe_mail_wall_aside .oe_suggested_item:hover .oe_remove_suggested_item > span {
.openerp .oe_mail_wall_aside .oe_suggested_item:hover .oe_remove_suggested_item > span,
.openerp .oe_mail_wall_aside .oe_suggestion_display:hover .oe_remove_suggestion > span {
visibility: visible;
}
.openerp .oe_mail_wall_aside .oe_item {
.openerp .oe_mail_wall_aside .oe_item,.oe_suggestion_display {
width: 90%;
}
.openerp .oe_mail_wall_aside .oe_item .oe_item_name {
+8
View File
@@ -16,6 +16,7 @@ openerp.mail.suggestions = function(session, mail) {
var removed_suggested_group = session.removed_suggested_group = [];
suggestions.Groups = session.web.Widget.extend({
events: {
'click .oe_remove_suggestion_employees': "remove_employee_suggestions",
'click .oe_remove_suggested_group': "remove_suggested_group",
'click .oe_join_group': "join_group",
'click .oe_open_group': "open_group"
@@ -25,6 +26,7 @@ openerp.mail.suggestions = function(session, mail) {
this._super(parent, action);
this.deferred = $.Deferred();
this.mail_group = new session.web.DataSetSearch(this, 'mail.group');
this.res_users = new session.web.DataSetSearch(this, 'res.users');
this.suggestions = [];
},
start: function() {
@@ -70,6 +72,12 @@ openerp.mail.suggestions = function(session, mail) {
var self = this;
removed_suggested_group.push($(event.currentTarget).attr('id'));
self.get_suggested_group();
},
remove_employee_suggestions: function(event) {
var self = this;
return this.res_users.call('stop_showing_group_suggestions', [this.session.uid]).then(function(res) {
self.$(".oe_sidebar_group").hide();
});
}
});
+7 -2
View File
@@ -6,8 +6,13 @@
</t>
<!-- Suggested groups -->
<div t-name="mail.suggestions.groups" class="oe_sidebar_group">
<p class="oe_suggestion_display">Suggested Groups</p>
<div t-name="mail.suggestions.groups" class="oe_sidebar_suggestion oe_sidebar_group">
<p class="oe_suggestion_display">
Suggested Groups
<a class="oe_remove_suggestion oe_remove_suggestion_employees" rol="button">
<span class="oe_kanban_action oe_kanban_action_a">X</span>
</a>
</p>
<div class="oe_suggest_groups">
<t t-foreach="widget.suggestions" t-as="result">
<div class="oe_suggested_item">