forked from OCA/social
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by jbeficent
- Loading branch information
Showing
14 changed files
with
259 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from . import mail_activity_team | ||
from . import mail_activity | ||
from . import res_users | ||
from . import mail_activity_mixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2018 Eficent Business and IT Consulting Services, S.L. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from odoo import api, models, fields | ||
|
||
|
||
class MailActivityMixin(models.AbstractModel): | ||
_inherit = 'mail.activity.mixin' | ||
|
||
activity_team_user_ids = fields.Many2many( | ||
comodel_name='res.users', string='test field', | ||
compute="_compute_activity_team_user_ids", | ||
search="_search_activity_team_user_ids", | ||
) | ||
|
||
@api.depends("activity_ids") | ||
def _compute_activity_team_user_ids(self): | ||
for rec in self: | ||
rec.activity_team_user_ids = rec.activity_ids.mapped( | ||
"team_id.member_ids") | ||
|
||
@api.model | ||
def _search_activity_team_user_ids(self, operator, operand): | ||
return [('activity_ids.team_id.member_ids', operator, operand)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
odoo.define('mail_activity_team.systray', function (require) { | ||
"use strict"; | ||
|
||
var systray = require('mail.systray'); | ||
var session = require("web.session"); | ||
|
||
systray.ActivityMenu.include({ | ||
events: _.extend({}, systray.ActivityMenu.prototype.events, { | ||
'click .o_filter_button': 'on_click_filter_button', | ||
}), | ||
start: function () { | ||
this._super.apply(this, arguments); | ||
this.$filter_buttons = this.$('.o_filter_button'); | ||
this.$my_activities = this.$filter_buttons.first(); | ||
this.filter = 'my'; | ||
session.user_context = _.extend({}, session.user_context, { | ||
'team_activities': false | ||
}); | ||
}, | ||
|
||
_updateCounter: function (data) { | ||
this._super.apply(this, arguments); | ||
this.$('.o_new_notification_counter').text(this.activityCounter); | ||
}, | ||
|
||
on_click_filter_button: function (event) { | ||
var self = this; | ||
|
||
event.stopPropagation(); | ||
self.$filter_buttons.removeClass('active'); | ||
var $target = $(event.currentTarget); | ||
$target.addClass('active'); | ||
self.filter = $target.data('filter'); | ||
|
||
session.user_context = _.extend({}, session.user_context, { | ||
'team_activities': self.filter === 'team' | ||
}); | ||
|
||
self._updateActivityPreview(); | ||
|
||
}, | ||
_onActivityFilterClick: function (event) { | ||
if (this.filter === 'my') { | ||
this._super.apply(this, arguments); | ||
} | ||
if (this.filter === 'team') { | ||
var data = _.extend( | ||
{}, | ||
$(event.currentTarget).data(), | ||
$(event.target).data() | ||
); | ||
var context = {}; | ||
if (data.filter === 'my') { | ||
context.search_default_activities_overdue = 1; | ||
context.search_default_activities_today = 1; | ||
} else { | ||
context['search_default_activities_' + data.filter] = 1; | ||
} | ||
this.do_action({ | ||
type: 'ir.actions.act_window', | ||
name: data.model_name, | ||
res_model: data.res_model, | ||
views: [[false, 'kanban'], [false, 'form']], | ||
search_view_id: [false], | ||
domain: [ | ||
['activity_team_user_ids', 'in', session.uid] | ||
], | ||
context:context, | ||
}); | ||
} | ||
}, | ||
_getActivityData: function(){ | ||
var self = this; | ||
return self._super.apply(self, arguments).then(function (data) { | ||
session.user_context = _.extend({}, session.user_context, { | ||
'team_activities': !session.user_context['team_activities'], | ||
}); | ||
|
||
self._rpc({ | ||
model: 'res.users', | ||
method: 'activity_user_count', | ||
kwargs: { | ||
context: session.user_context, | ||
}, | ||
}).then(function (data) { | ||
self.activityCounter += _.reduce(data, function( | ||
total_count, p_data | ||
){ return total_count + p_data.total_count; }, 0); | ||
self.$('.o_new_notification_counter').text(self.activityCounter); | ||
self.$el.toggleClass('o_no_notification', !self.activityCounter); | ||
session.user_context = _.extend({}, session.user_context, { | ||
'team_activities': !session.user_context['team_activities'], | ||
}); | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.o_new_notification_counter { | ||
.o-position-absolute(@top: 20%, @right: 1px); | ||
background: @odoo-brand-optional; | ||
color: white; | ||
padding: 0em 0.3em; | ||
font-size: 0.7em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates> | ||
|
||
<t t-extend="mail.chat.ActivityMenu"> | ||
<t t-jquery=".o_mail_navbar_dropdown_channels" t-operation="before"> | ||
<li class="o_mail_navbar_dropdown_top"> | ||
<div> | ||
<button type="button" class="btn btn-sm o_filter_button active" data-filter='my'> My Activities </button> | ||
<button type="button" class="btn btn-sm o_filter_button" data-filter='team'> Team Activities </button> | ||
</div> | ||
</li> | ||
</t> | ||
<t t-jquery=".o_notification_counter" t-operation="replace"> | ||
<span class="o_new_notification_counter badge"/> | ||
</t> | ||
</t> | ||
|
||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<template id="assets_backend" name="mail assets" | ||
inherit_id="web.assets_backend"> | ||
<xpath expr="." position="inside"> | ||
<script type="text/javascript" src="/mail_activity_team/static/src/js/systray.js"/> | ||
<link rel="stylesheet" href="/mail_activity_team/static/src/less/systray.less" type="text/less"/> | ||
</xpath> | ||
</template> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,5 @@ | |
<filter name='team' string="Team" context="{'group_by': 'team_id'}"/> | ||
</group> | ||
</field> | ||
|
||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters