[REF] mail: lint the js code
remove unused imports, add missing semicolons, ...
This commit is contained in:
committed by
Aaron Bohy
parent
e700c802dd
commit
7ab686ffa4
@@ -1,7 +1,6 @@
|
||||
odoo.define('mail.chat_backend', function (require) {
|
||||
"use strict";
|
||||
|
||||
var bus = require('bus.bus');
|
||||
var core = require('web.core');
|
||||
var data = require('web.data');
|
||||
var Model = require('web.Model');
|
||||
@@ -14,10 +13,8 @@ var SearchView = require('web.SearchView');
|
||||
var WebClient = require('web.WebClient');
|
||||
|
||||
var session = require('web.session');
|
||||
var utils = require('web.utils');
|
||||
var web_client = require('web.web_client');
|
||||
|
||||
var mail_utils = require('mail.utils');
|
||||
var mail_chat_common = require('mail.chat_common');
|
||||
var mail_thread = require('mail.thread');
|
||||
|
||||
@@ -37,21 +34,21 @@ var ConversationManagerBackend = mail_chat_common.ConversationManager.extend({
|
||||
_setup: function(init_data){
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
_.each(init_data['notifications'], function(n){
|
||||
_.each(init_data.notifications, function(n){
|
||||
self.on_notification(n);
|
||||
});
|
||||
},
|
||||
// window title
|
||||
window_title_change: function() {
|
||||
this._super.apply(this, arguments);
|
||||
var title = undefined;
|
||||
var title;
|
||||
if (this.get("waiting_messages") !== 0) {
|
||||
title = _.str.sprintf(_t("%d Messages"), this.get("waiting_messages"));
|
||||
}
|
||||
web_client.set_title_part("im_messages", title);
|
||||
},
|
||||
// sessions and messages
|
||||
session_apply: function(active_session, options){
|
||||
session_apply: function(active_session){
|
||||
// for chat windows
|
||||
if(active_session.is_minimized || (!active_session.is_minimized && active_session.state === 'closed')){
|
||||
this._super.apply(this, arguments);
|
||||
@@ -126,7 +123,7 @@ var NotificationTopButton = Widget.extend({
|
||||
events: {
|
||||
"click": "on_click",
|
||||
},
|
||||
init: function(parent){
|
||||
init: function(){
|
||||
this._super.apply(this, arguments);
|
||||
this.set('counter', 0);
|
||||
},
|
||||
@@ -137,7 +134,6 @@ var NotificationTopButton = Widget.extend({
|
||||
});
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
this.on("change:counter", this, this.on_change_counter);
|
||||
// events
|
||||
internal_bus.on('mail_needaction_new', this, this.counter_increment);
|
||||
@@ -193,7 +189,6 @@ var AbstractAddMoreSearch = Widget.extend({
|
||||
this.label = options.label;
|
||||
},
|
||||
start: function(){
|
||||
var self = this;
|
||||
this.last_search_val = false;
|
||||
this.$input = this.$('.o_mail_chat_search_input');
|
||||
this._bind_events();
|
||||
@@ -218,7 +213,7 @@ var AbstractAddMoreSearch = Widget.extend({
|
||||
select: function(event, ui) {
|
||||
self.on_click_item(ui.item);
|
||||
},
|
||||
focus: function(event, ui) {
|
||||
focus: function(event) {
|
||||
event.preventDefault();
|
||||
},
|
||||
html: true,
|
||||
@@ -236,7 +231,7 @@ var AbstractAddMoreSearch = Widget.extend({
|
||||
this._toggle_elements();
|
||||
},
|
||||
// to be redefined
|
||||
do_search: function(search_val){
|
||||
do_search: function(){
|
||||
return $.when();
|
||||
},
|
||||
on_click_item: function(item){
|
||||
@@ -250,13 +245,12 @@ var AbstractAddMoreSearch = Widget.extend({
|
||||
},
|
||||
});
|
||||
|
||||
var PartnerAddMoreSeach = AbstractAddMoreSearch.extend({
|
||||
var PartnerAddMoreSearch = AbstractAddMoreSearch.extend({
|
||||
/**
|
||||
* Do the search call
|
||||
* @override
|
||||
*/
|
||||
do_search: function(search_val){
|
||||
var self = this;
|
||||
var Partner = new Model("res.partner");
|
||||
return Partner.call('im_search', [search_val, this.limit]).then(function(result){
|
||||
var values = [];
|
||||
@@ -277,7 +271,6 @@ var ChannelAddMoreSearch = AbstractAddMoreSearch.extend({
|
||||
* @override
|
||||
*/
|
||||
do_search: function(search_val){
|
||||
var self = this;
|
||||
var Channel = new Model("mail.channel");
|
||||
return Channel.call('channel_search_to_join', [search_val]).then(function(result){
|
||||
var values = [];
|
||||
@@ -347,7 +340,7 @@ var PartnerInviteDialog = Dialog.extend({
|
||||
self.PartnersModel.call('im_search', [query.term, self.limit]).then(function(result){
|
||||
var data = [];
|
||||
_.each(result, function(partner){
|
||||
partner['text'] = partner.name;
|
||||
partner.text = partner.name;
|
||||
data.push(partner);
|
||||
});
|
||||
query.callback({results: data});
|
||||
@@ -405,7 +398,7 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
this.conv_manager = web_client.mail_conversation_manager;
|
||||
this.channel_search_widget = new ChannelAddMoreSearch(this, {'label': _t('+ Subscribe'), 'can_create': true});
|
||||
this.group_search_widget = new PrivateGroupAddMoreSearch(this, {'label': _t('+ New private group'), 'can_create': true});
|
||||
this.partner_search_widget = new PartnerAddMoreSeach(this);
|
||||
this.partner_search_widget = new PartnerAddMoreSearch(this);
|
||||
// options (update the default of MailThreadMixin)
|
||||
this.options = _.extend(this.options, {
|
||||
'display_document_link': true,
|
||||
@@ -433,11 +426,11 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
willStart: function(){
|
||||
var self = this;
|
||||
return session.rpc('/mail/client_action').then(function(result){
|
||||
self.chatter_needaction_auto = result['chatter_needaction_auto'];
|
||||
self.set('needaction_inbox_counter', result['needaction_inbox_counter']);
|
||||
self.set('partners', result['channel_slots']['partners']);
|
||||
self.mapping = result['channel_slots']['mapping'];
|
||||
self._channel_slot(_.omit(result['channel_slots'], 'partners', 'mapping'));
|
||||
self.chatter_needaction_auto = result.chatter_needaction_auto;
|
||||
self.set('needaction_inbox_counter', result.needaction_inbox_counter);
|
||||
self.set('partners', result.channel_slots.partners);
|
||||
self.mapping = result.channel_slots.mapping;
|
||||
self._channel_slot(_.omit(result.channel_slots, 'partners', 'mapping'));
|
||||
});
|
||||
},
|
||||
start: function(){
|
||||
@@ -490,11 +483,11 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
// needaction inbox counter
|
||||
this.on('change:needaction_inbox_counter', this, this.needaction_inbox_change);
|
||||
|
||||
return $.when(this._super.apply(this, arguments), this.cp_render_searchview()).then(function(res){
|
||||
return $.when(this._super.apply(this, arguments), this.cp_render_searchview()).then(function(){
|
||||
// update control panel
|
||||
self.cp_render_buttons();
|
||||
// apply default channel
|
||||
var channel_id = self.context.active_id || self.action.params['default_active_id'] || 'channel_inbox';
|
||||
var channel_id = self.context.active_id || self.action.params.default_active_id || 'channel_inbox';
|
||||
if(!_.isString(channel_id)){
|
||||
if(_.contains(_.keys(self.channels), channel_id)){
|
||||
self.set('current_channel_id', channel_id);
|
||||
@@ -561,23 +554,23 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
}
|
||||
return $.Deferred.reject();
|
||||
},
|
||||
on_click_button_invite: function(event){
|
||||
var dialog = new PartnerInviteDialog(this, {
|
||||
on_click_button_invite: function(){
|
||||
new PartnerInviteDialog(this, {
|
||||
title: _.str.sprintf(_t('Invite people to %s.'), this.get_current_channel_name()),
|
||||
channel: this.channels[this.get('current_channel_id')],
|
||||
}).open();
|
||||
},
|
||||
on_click_button_unsubscribe: function(event){
|
||||
on_click_button_unsubscribe: function(){
|
||||
var self = this;
|
||||
this.ChannelModel.call('action_unfollow', [[this.get('current_channel_id')]]).then(function(){
|
||||
var channel = self.channels[self.get('current_channel_id')]
|
||||
var channel = self.channels[self.get('current_channel_id')];
|
||||
var slot = self.get_channel_slot(channel);
|
||||
self.set(slot, _.filter(self.get(slot), function(c){ return c.id !== channel.id; }));
|
||||
self.do_notify(_t('Unsubscribe'), _.str.sprintf(_t('You unsubscribe from <b>%s</b>.'), self.get_current_channel_name()));
|
||||
self.set('current_channel_id', 'channel_inbox'); // jump to inbox
|
||||
});
|
||||
},
|
||||
on_click_button_settings: function(event){
|
||||
on_click_button_settings: function(){
|
||||
this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: "mail.channel",
|
||||
@@ -630,7 +623,6 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
this.update_control_panel(status, {clear: false});
|
||||
},
|
||||
cp_render_buttons: function() {
|
||||
var self = this;
|
||||
this.control_elements.$buttons = $(QWeb.render("mail.chat.ControlButtons", {}));
|
||||
this.control_elements.$buttons.on('click', '.o_mail_chat_button_minimize', _.bind(this.on_click_button_minimize, this));
|
||||
this.control_elements.$buttons.on('click', '.o_mail_chat_button_invite', _.bind(this.on_click_button_invite, this));
|
||||
@@ -761,7 +753,6 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
});
|
||||
},
|
||||
channel_info: function(channel_id){
|
||||
var self = this;
|
||||
return this.ChannelModel.call('channel_info', [[channel_id]]).then(function(channels){
|
||||
return channels[0];
|
||||
});
|
||||
@@ -775,9 +766,10 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
channel_change: function(){
|
||||
var self = this;
|
||||
var current_channel_id = this.get('current_channel_id');
|
||||
var current_channel = this.channels[current_channel_id];
|
||||
// mail chat compose message (destroy and replace it)
|
||||
this.mail_chat_compose_message && this.mail_chat_compose_message.destroy();
|
||||
if (this.mail_chat_compose_message) {
|
||||
this.mail_chat_compose_message.destroy();
|
||||
}
|
||||
this.mail_chat_compose_message = new mail_thread.MailComposeMessage(this, new data.DataSetSearch(this, 'mail.channel', this.context), {
|
||||
'emoji_list': this.options.emoji_list,
|
||||
'context': _.extend(this.context, {
|
||||
@@ -795,8 +787,8 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
|
||||
// push state (the action is referred by action_manager, and no reloaded when jumping
|
||||
// channel, so update context is requried)
|
||||
this.action.context['active_id'] = current_channel_id;
|
||||
this.action.context['active_ids'] = [current_channel_id];
|
||||
this.action.context.active_id = current_channel_id;
|
||||
this.action.context.active_ids = [current_channel_id];
|
||||
web_client.action_manager.do_push_state({
|
||||
action: this.action.id,
|
||||
active_id: current_channel_id,
|
||||
@@ -806,7 +798,7 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
this.cp_update();
|
||||
|
||||
// fetch the messages
|
||||
return this.message_load_new().then(function(raw_messages){
|
||||
return this.message_load_new().then(function(){
|
||||
// allow loading history
|
||||
self.loading_history = true;
|
||||
// if normal channel, update last message id, and unbold
|
||||
@@ -879,7 +871,7 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
}
|
||||
});
|
||||
},
|
||||
needaction_inbox_change: function(inc){
|
||||
needaction_inbox_change: function(){
|
||||
var count = this.get('needaction_inbox_counter');
|
||||
var $elem = this.$('.o_mail_chat_needaction[data-channel-id="channel_inbox"]');
|
||||
$elem.html(count);
|
||||
@@ -896,11 +888,11 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
|
||||
message_receive: function(message){
|
||||
var self = this;
|
||||
// if current channel should reveice message, give it to it
|
||||
if(_.contains(message['channel_ids'], this.get('current_channel_id'))){
|
||||
if(_.contains(message.channel_ids, this.get('current_channel_id'))){
|
||||
this.message_insert([message]);
|
||||
}
|
||||
// for other message channel, get the channel if not loaded yet, and bolded them
|
||||
var other_message_channel_ids = _.without(message['channel_ids'], this.get('current_channel_id'));
|
||||
var other_message_channel_ids = _.without(message.channel_ids, this.get('current_channel_id'));
|
||||
var active_channel_ids = _.map(_.keys(this.channels), function(cid){
|
||||
return parseInt(cid);
|
||||
}); // integer as key of a dict is cast as string in javascript
|
||||
|
||||
@@ -22,7 +22,6 @@ var NBR_LIMIT_HISTORY = 20;
|
||||
**/
|
||||
var ConversationManager = Widget.extend({
|
||||
init: function(parent, options) {
|
||||
var self = this;
|
||||
this._super(parent);
|
||||
this.options = _.clone(options) || {};
|
||||
_.defaults(this.options, {
|
||||
@@ -56,8 +55,8 @@ var ConversationManager = Widget.extend({
|
||||
});
|
||||
},
|
||||
_setup: function(init_data){
|
||||
this.emoji_list = init_data['emoji'];
|
||||
this.options['emoji'] = mail_utils.shortcode_substitution(init_data['emoji']);
|
||||
this.emoji_list = init_data.emoji;
|
||||
this.options.emoji = mail_utils.shortcode_substitution(init_data.emoji);
|
||||
},
|
||||
on_notification: function(notification, options) {
|
||||
var self = this;
|
||||
@@ -89,7 +88,6 @@ var ConversationManager = Widget.extend({
|
||||
mail_utils.beep(session);
|
||||
},
|
||||
window_title_change: function() {
|
||||
var title = undefined;
|
||||
if (this.get("waiting_messages") !== 0) {
|
||||
this.window_beep();
|
||||
}
|
||||
@@ -350,14 +348,13 @@ var Conversation = Widget.extend({
|
||||
this.set("messages", _.sortBy(this.get("messages").concat(messages), function(m){ return m.id; }));
|
||||
},
|
||||
message_render: function(){
|
||||
var self = this;
|
||||
var message_html = $(QWeb.render("mail.chat.im.Conversation.messages", {"widget": this}));
|
||||
this.$('.o_mail_chat_im_window_content').html(message_html);
|
||||
},
|
||||
message_am_i_author: function(message){
|
||||
return message.author_id && message.author_id[0] === session.partner_id;
|
||||
},
|
||||
message_pending_change: function(event){
|
||||
message_pending_change: function(){
|
||||
if (this.get("pending") === 0) {
|
||||
this.$(".o_mail_chat_im_window_header_counter").text("");
|
||||
} else {
|
||||
@@ -393,7 +390,7 @@ var Conversation = Widget.extend({
|
||||
this.$("input").val("");
|
||||
this.message_send(mes);
|
||||
},
|
||||
on_click_header: function(event){
|
||||
on_click_header: function(){
|
||||
this.session_fold();
|
||||
},
|
||||
on_click_close: function(event) {
|
||||
|
||||
@@ -2,10 +2,7 @@ odoo.define('mail.chatter', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var data = require('web.data');
|
||||
var session = require('web.session');
|
||||
var web_client = require('web.web_client');
|
||||
var Model = require('web.Model');
|
||||
var Widget = require('web.Widget');
|
||||
var form_common = require('web.form_common');
|
||||
var SystrayMenu = require('web.SystrayMenu');
|
||||
@@ -47,7 +44,7 @@ var ChatterMailComposeMessage = mail_thread.MailComposeMessage.extend({
|
||||
this.$input = this.$('.o_mail_compose_message_input');
|
||||
this.$input.focus();
|
||||
// add mail compose message full button
|
||||
this.$('.o_mail_compose_message_button_group').append('<button class="btn btn-default o_mail_compose_message_button_full_message" type="button" data-toggle="popover"><i class="fa fa-pencil-square-o"/></button>')
|
||||
this.$('.o_mail_compose_message_button_group').append('<button class="btn btn-default o_mail_compose_message_button_full_message" type="button" data-toggle="popover"><i class="fa fa-pencil-square-o"/></button>');
|
||||
this.$('.o_mail_compose_message_button_full_message').on('click', this, this.on_compose_message);
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
@@ -78,7 +75,7 @@ var ChatterMailComposeMessage = mail_thread.MailComposeMessage.extend({
|
||||
get_checked_suggested_partners: function(){
|
||||
var self = this;
|
||||
var checked_partners = [];
|
||||
this.$('.o_mail_chatter_compose_message_suggested_partners input:checked').each(function(index){
|
||||
this.$('.o_mail_chatter_compose_message_suggested_partners input:checked').each(function(){
|
||||
var $input = $(this);
|
||||
var full_name = $input.data('fullname');
|
||||
checked_partners = checked_partners.concat(_.filter(self.suggested_partners, function(item){
|
||||
@@ -185,12 +182,12 @@ var ChatterMailComposeMessage = mail_thread.MailComposeMessage.extend({
|
||||
if(this.options.is_log) {
|
||||
var subtype_id = parseInt(this.$('.o_mail_chatter_compose_message_subtype_select').val());
|
||||
if(_.indexOf(_.pluck(this.internal_subtypes, 'id'), subtype_id) == -1) {
|
||||
values['subtype'] = 'mail.mt_note'
|
||||
values.subtype = 'mail.mt_note';
|
||||
}else{
|
||||
values['subtype_id'] = subtype_id;
|
||||
values.subtype_id = subtype_id;
|
||||
}
|
||||
}else{
|
||||
values['subtype'] = 'mail.mt_comment';
|
||||
values.subtype = 'mail.mt_comment';
|
||||
}
|
||||
// update partner_ids
|
||||
var def = $.when();
|
||||
@@ -202,20 +199,20 @@ var ChatterMailComposeMessage = mail_thread.MailComposeMessage.extend({
|
||||
var checked_suggested_partners = this.get_checked_suggested_partners();
|
||||
this.check_suggested_partners(checked_suggested_partners).done(function(partner_ids){
|
||||
// update context
|
||||
values['partner_ids'] = partner_ids;
|
||||
values['context'] = _.defaults(self.context, {
|
||||
values.partner_ids = partner_ids;
|
||||
values.context = _.defaults(self.context, {
|
||||
'mail_post_autofollow': true,
|
||||
'mail_post_autofollow_partner_ids': partner_ids,
|
||||
});
|
||||
def = _.bind(_super, self)(body, attachment_ids, values);
|
||||
});
|
||||
}
|
||||
return def
|
||||
return def;
|
||||
},
|
||||
is_empty: function(){
|
||||
return this.$input.val() === '';
|
||||
},
|
||||
on_compose_message: function(event){
|
||||
on_compose_message: function(){
|
||||
var self = this;
|
||||
if (!this.do_check_attachment_upload()){
|
||||
return false;
|
||||
@@ -280,17 +277,17 @@ var ChatterMailThread = form_common.AbstractField.extend(mail_thread.MailThreadM
|
||||
"click .o_mail_chatter_button_new_message": "on_open_composer",
|
||||
"click .o_mail_chatter_button_log_note": "on_open_composer",
|
||||
"blur .o_mail_compose_message_input": "on_close_composer",
|
||||
"mousedown .o_mail_chatter_compose_message": function(event) {
|
||||
"mousedown .o_mail_chatter_compose_message": function() {
|
||||
this.stay_open = true;
|
||||
},
|
||||
"focus .o_mail_compose_message_input": function(event) {
|
||||
"focus .o_mail_compose_message_input": function() {
|
||||
this.stay_open = false;
|
||||
},
|
||||
"keydown .o_mail_compose_message_input": function(event) {
|
||||
"keydown .o_mail_compose_message_input": function() {
|
||||
this.stay_open = false;
|
||||
},
|
||||
},
|
||||
init: function (parent, node){
|
||||
init: function (){
|
||||
this._super.apply(this, arguments);
|
||||
mail_thread.MailThreadMixin.init.call(this);
|
||||
this.message_composer = undefined;
|
||||
@@ -309,7 +306,7 @@ var ChatterMailThread = form_common.AbstractField.extend(mail_thread.MailThreadM
|
||||
mail_thread.MailThreadMixin.start.call(this);
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
on_message_show_more: function(event){
|
||||
on_message_show_more: function(){
|
||||
var self = this;
|
||||
this.message_load_history().then(function(messages){
|
||||
if(messages.length < mail_thread.LIMIT_MESSAGE){
|
||||
@@ -378,12 +375,12 @@ var ChatterMailThread = form_common.AbstractField.extend(mail_thread.MailThreadM
|
||||
});
|
||||
this.message_composer.appendTo(this.$('.o_mail_chatter_compose_message_wrap'));
|
||||
this.message_composer.on('message_sent', this, this.on_message_post);
|
||||
this.message_composer.on('need_refresh', this, function(e){
|
||||
this.message_composer.on('need_refresh', this, function(){
|
||||
self.message_refresh();
|
||||
self.on_close_composer();
|
||||
});
|
||||
},
|
||||
on_close_composer: function(event){
|
||||
on_close_composer: function(){
|
||||
if(this.message_composer && this.message_composer.is_empty() && !this.stay_open){
|
||||
this.$('.o_mail_chatter_compose_buttons').show();
|
||||
this.$('.o_mail_chatter_compose_message_wrap').hide();
|
||||
@@ -410,7 +407,7 @@ var ChatterMailThread = form_common.AbstractField.extend(mail_thread.MailThreadM
|
||||
* @override
|
||||
*/
|
||||
_message_order: function(messages){
|
||||
var messages = mail_thread.MailThreadMixin._message_order.call(this, messages);
|
||||
messages = mail_thread.MailThreadMixin._message_order.call(this, messages);
|
||||
return messages.reverse();
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
|
||||
reinit: function() {
|
||||
this.data_subtype = {};
|
||||
this.message_is_follower == undefined;
|
||||
this.message_is_follower = undefined;
|
||||
this.display_buttons();
|
||||
},
|
||||
|
||||
@@ -72,7 +72,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
var self = this;
|
||||
|
||||
// event: click on '(Un)Follow' button, that toggles the follow for uid
|
||||
this.$('.o_timeline_follower').on('click', function (event) {
|
||||
this.$('.o_timeline_follower').on('click', function () {
|
||||
if($(this).hasClass('o_timeline_notfollow')) {
|
||||
self.do_follow();
|
||||
}
|
||||
@@ -122,7 +122,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
return self.fetch_subtypes(user_pid);
|
||||
},
|
||||
|
||||
on_invite_follower: function (event) {
|
||||
on_invite_follower: function () {
|
||||
var self = this;
|
||||
var action = {
|
||||
type: 'ir.actions.act_window',
|
||||
@@ -196,7 +196,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
/** Read on res.partner failed: fall back on a generic case
|
||||
- fetch current user partner_id (call because no other smart solution currently) FIXME
|
||||
- then display a generic message about followers */
|
||||
fetch_generic: function (error, event) {
|
||||
fetch_generic: function () {
|
||||
var self = this;
|
||||
|
||||
return this.ds_users.call('read', [[session.uid], ['partner_id']])
|
||||
@@ -221,7 +221,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
|
||||
/* Display generic info about follower, for people not having access to res_partner */
|
||||
display_generic: function () {
|
||||
var node_user_list = this.$('.o_timeline_follower_list').empty();
|
||||
this.$('.o_timeline_follower_list').empty();
|
||||
this.$('.o_timeline_follower_title').html(this._format_followers(this.value.length));
|
||||
},
|
||||
|
||||
@@ -233,7 +233,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
// clean and display title
|
||||
var node_user_list = this.$('.o_timeline_follower_list').empty();
|
||||
this.$('.o_timeline_follower_title').html(this._format_followers(this.followers.length));
|
||||
var user_follower = _.filter(this.followers, function (rec) { return rec['is_uid'];});
|
||||
var user_follower = _.filter(this.followers, function (rec) { return rec.is_uid;});
|
||||
this.message_is_follower = user_follower.length >= 1;
|
||||
this.follower_id = this.message_is_follower ? user_follower[0]['id'] : undefined;
|
||||
$(qweb.render('mail.Followers.add_more', {'widget': self})).appendTo(node_user_list);
|
||||
@@ -241,7 +241,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
// truncate number of displayed followers
|
||||
_(this.followers).each(function (record) {
|
||||
$(qweb.render('mail.Followers.partner', {
|
||||
'record': _.extend(record, {'avatar_url': '/web/image/' + record['res_model'] + '/' + record['res_id'] + '/image_small'}),
|
||||
'record': _.extend(record, {'avatar_url': '/web/image/' + record.res_model + '/' + record.res_id + '/image_small'}),
|
||||
'widget': self})
|
||||
).appendTo(node_user_list);
|
||||
// On mouse-enter it will show the edit_subtype pencil.
|
||||
@@ -281,7 +281,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
dialog = true;
|
||||
}
|
||||
else {
|
||||
var subtype_list_ul = this.$('.o_timeline_subtype_list ul').empty();
|
||||
this.$('.o_timeline_subtype_list ul').empty();
|
||||
if (! this.message_is_follower) {
|
||||
this.$('.o_timeline_subtype_list > .dropdown-toggle').attr('disabled', true);
|
||||
return;
|
||||
@@ -310,7 +310,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
$list = this.$dialog.$el;
|
||||
}
|
||||
|
||||
var old_parent_model = undefined;
|
||||
var old_parent_model;
|
||||
this.records_length = $.map(data, function(value, index) { return index; }).length;
|
||||
|
||||
if (this.records_length > 1) {
|
||||
@@ -391,7 +391,7 @@ var Followers = form_common.AbstractField.extend({
|
||||
oe_action = $('.oe_edit_actions input[type="checkbox"]');
|
||||
}
|
||||
|
||||
var checklist = new Array();
|
||||
var checklist = [];
|
||||
_(oe_action).each(function (record) {
|
||||
if ($(record).is(':checked')) {
|
||||
checklist.push(parseInt($(record).data('id')));
|
||||
|
||||
@@ -186,7 +186,7 @@ var MailComposeMessage = Widget.extend({
|
||||
values = _.extend(values, {
|
||||
'body': this.mention_preprocess_message(body),
|
||||
'attachment_ids': attachment_ids || [],
|
||||
'partner_ids': _.pluck(this.get('mention_selected_partners'), 'id').concat(values['partner_ids']),
|
||||
'partner_ids': _.pluck(this.get('mention_selected_partners'), 'id').concat(values.partner_ids),
|
||||
});
|
||||
return this.thread_dataset._model.call('message_post', [this.context.default_res_id], values).then(function(message_id){
|
||||
self.reset(); // empty attachment, mention partners, ...
|
||||
@@ -324,7 +324,7 @@ var MailComposeMessage = Widget.extend({
|
||||
$active.click();
|
||||
}
|
||||
}else{ // navigation in propositions
|
||||
var $to = undefined;
|
||||
var $to;
|
||||
if(keycode === $.ui.keyCode.DOWN){
|
||||
$to = $active.next('.o_mail_mention_proposition:not(.active)');
|
||||
}else{
|
||||
@@ -374,7 +374,7 @@ var MailComposeMessage = Widget.extend({
|
||||
clearTimeout(this.mention_fetch_timer);
|
||||
}
|
||||
},
|
||||
mention_fetch_partner: function(event){
|
||||
mention_fetch_partner: function(){
|
||||
var self = this;
|
||||
var search_str = this.get('mention_word');
|
||||
this.PartnerModel.query(['id', 'name', 'email'])
|
||||
@@ -388,10 +388,11 @@ var MailComposeMessage = Widget.extend({
|
||||
var mention_selected_partners = this.get('mention_selected_partners');
|
||||
var cursor = this.get_cursor_position();
|
||||
var input_text = this.$input.val();
|
||||
var matches;
|
||||
switch(keycode) {
|
||||
// Remove a mention when a character belonging to a mention word is removed from the input text
|
||||
case $.ui.keyCode.BACKSPACE:
|
||||
var matches = this.mention_get_match(this.$input.val());
|
||||
matches = this.mention_get_match(this.$input.val());
|
||||
for(var i=0 ; i< matches.length ; i++){
|
||||
var m = matches[i];
|
||||
if(m.index <= cursor && cursor <= m.index+m[0].length){
|
||||
@@ -409,7 +410,7 @@ var MailComposeMessage = Widget.extend({
|
||||
var deleted_binf = left_text.length;
|
||||
var deleted_bsup = left_text.length + deleted_text.length;
|
||||
|
||||
var matches = this.mention_get_match(this.input_buffer);
|
||||
matches = this.mention_get_match(this.input_buffer);
|
||||
for(var i=0 ; i< matches.length ; i++){
|
||||
var m = matches[i];
|
||||
var m1 = m.index;
|
||||
@@ -432,7 +433,7 @@ var MailComposeMessage = Widget.extend({
|
||||
var match = matches[i];
|
||||
var end_index = match.index+match[0].length;
|
||||
var subtext = body.substring(start_index, end_index);
|
||||
subtext = subtext.replace(match[0], _.str.sprintf("<span data-oe-model='res.partner' data-oe-id='%s'>%s</span>", partners[i].id, match[0]))
|
||||
subtext = subtext.replace(match[0], _.str.sprintf("<span data-oe-model='res.partner' data-oe-id='%s'>%s</span>", partners[i].id, match[0]));
|
||||
substrings.push(subtext);
|
||||
start_index = end_index;
|
||||
}
|
||||
@@ -470,7 +471,7 @@ var MailComposeMessage = Widget.extend({
|
||||
if(regex_str.length){
|
||||
var myRegexp = new RegExp(regex_str, 'g');
|
||||
var match = myRegexp.exec(input_text);
|
||||
while (match != null) {
|
||||
while (match !== null) {
|
||||
result.push(match);
|
||||
match = myRegexp.exec(input_text);
|
||||
}
|
||||
@@ -598,7 +599,7 @@ var MailThreadMixin = {
|
||||
var $source = this.$(event.currentTarget);
|
||||
var mid = $source.data('message-id');
|
||||
var is_starred = !$source.hasClass('o_mail_message_starred');
|
||||
return this.MessageDatasetSearch.call('set_message_starred', [[mid], is_starred]).then(function(res){
|
||||
return this.MessageDatasetSearch.call('set_message_starred', [[mid], is_starred]).then(function(){
|
||||
$source.toggleClass('o_mail_message_starred');
|
||||
return mid;
|
||||
});
|
||||
@@ -606,7 +607,7 @@ var MailThreadMixin = {
|
||||
on_message_needaction: function(event){
|
||||
var $source = this.$(event.currentTarget);
|
||||
var mid = $source.data('message-id');
|
||||
return this.MessageDatasetSearch.call('set_message_done', [[mid]]).then(function(res){
|
||||
return this.MessageDatasetSearch.call('set_message_done', [[mid]]).then(function(){
|
||||
$source.remove();
|
||||
return mid;
|
||||
});
|
||||
@@ -659,7 +660,7 @@ var MailThreadMixin = {
|
||||
var self = this;
|
||||
return this.message_fetch(this.get_message_domain_history()).then(function(raw_messages){
|
||||
self.message_insert(raw_messages);
|
||||
return raw_messages
|
||||
return raw_messages;
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -672,7 +673,7 @@ var MailThreadMixin = {
|
||||
var self = this;
|
||||
return this.message_fetch(this.get_message_domain()).then(function(raw_messages){
|
||||
self._message_replace(self._message_preprocess(raw_messages));
|
||||
return raw_messages
|
||||
return raw_messages;
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -741,7 +742,7 @@ return {
|
||||
MailComposeMessage: MailComposeMessage,
|
||||
MailThreadMixin: MailThreadMixin,
|
||||
LIMIT_MESSAGE: LIMIT_MESSAGE,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ function attachment_filetype_to_fa_class(file_type){
|
||||
'spreadsheet': 'fa fa-file-excel-o',
|
||||
'print': 'fa fa-file-pdf-o',
|
||||
'presentation': 'fa fa-file-powerpoint-o',
|
||||
}
|
||||
};
|
||||
if(_.contains(_.keys(mapping), file_type)){
|
||||
return mapping[file_type];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user