Skip to content
Permalink
Browse files

wip

```
/|\ [IMP] base: update rsjmin to support ES6
 |  [IMP] mail: convert inlineTemplate to xml template
 |  [IMP] owl and xml templates
```
  • Loading branch information...
alexkuhn committed Feb 12, 2019
1 parent 4ae4aed commit 1edd45773de5a133c6410f7c273eec223b79b55b
Showing with 11,464 additions and 29 deletions.
  1. +18 −0 addons/mail/__manifest__.py
  2. +1 −0 addons/mail/static/src/js/discuss.js
  3. +40 −0 addons/mail/static/src/js/wip/model/mail_failure.js
  4. +97 −0 addons/mail/static/src/js/wip/model/message.js
  5. +30 −0 addons/mail/static/src/js/wip/model/model.js
  6. +23 −0 addons/mail/static/src/js/wip/model/partner.js
  7. +52 −0 addons/mail/static/src/js/wip/model/thread.js
  8. +39 −0 addons/mail/static/src/js/wip/model/thread_cache.js
  9. +277 −0 addons/mail/static/src/js/wip/old_widget/discuss.js
  10. +113 −0 addons/mail/static/src/js/wip/old_widget/discuss_invite_partner_dialog.js
  11. +20 −0 addons/mail/static/src/js/wip/old_widget/store_mixin.js
  12. +42 −0 addons/mail/static/src/js/wip/service/chat_window_service.js
  13. +99 −0 addons/mail/static/src/js/wip/service/store_service.js
  14. +892 −0 addons/mail/static/src/js/wip/store/actions.js
  15. +23 −0 addons/mail/static/src/js/wip/store/getters.js
  16. +932 −0 addons/mail/static/src/js/wip/store/mutations.js
  17. +34 −0 addons/mail/static/src/js/wip/utils.js
  18. +67 −0 addons/mail/static/src/js/wip/widget/autocomplete_input.js
  19. +689 −0 addons/mail/static/src/js/wip/widget/chat_window_manager.js
  20. +87 −0 addons/mail/static/src/js/wip/widget/composer.js
  21. +72 −0 addons/mail/static/src/js/wip/widget/discuss_mobile_mailbox_selection.js
  22. +41 −0 addons/mail/static/src/js/wip/widget/discuss_mobile_navbar.js
  23. +288 −0 addons/mail/static/src/js/wip/widget/discuss_root.js
  24. +301 −0 addons/mail/static/src/js/wip/widget/discuss_sidebar.js
  25. +201 −0 addons/mail/static/src/js/wip/widget/discuss_sidebar_item.js
  26. +61 −0 addons/mail/static/src/js/wip/widget/editable_text.js
  27. +83 −0 addons/mail/static/src/js/wip/widget/emojis_button.js
  28. +32 −0 addons/mail/static/src/js/wip/widget/emojis_popover.js
  29. +291 −0 addons/mail/static/src/js/wip/widget/message.js
  30. +386 −0 addons/mail/static/src/js/wip/widget/message_list.js
  31. +145 −0 addons/mail/static/src/js/wip/widget/thread.js
  32. +123 −0 addons/mail/static/src/js/wip/widget/thread_preview_list.js
  33. +65 −0 addons/mail/static/src/scss/wip/composer.scss
  34. +27 −0 addons/mail/static/src/scss/wip/discuss.scss
  35. +20 −0 addons/mail/static/src/scss/wip/discuss_mobile_mailbox_selection.scss
  36. +19 −0 addons/mail/static/src/scss/wip/discuss_mobile_navbar.scss
  37. +59 −0 addons/mail/static/src/scss/wip/discuss_root.scss
  38. +95 −0 addons/mail/static/src/scss/wip/discuss_sidebar.scss
  39. +171 −0 addons/mail/static/src/scss/wip/discuss_sidebar_item.scss
  40. +21 −0 addons/mail/static/src/scss/wip/emojis_popover.scss
  41. +180 −0 addons/mail/static/src/scss/wip/message.scss
  42. +73 −0 addons/mail/static/src/scss/wip/message_list.scss
  43. +41 −0 addons/mail/static/src/scss/wip/thread.scss
  44. +30 −0 addons/mail/static/src/xml/wip/old_widget/common.xml
  45. +28 −0 addons/mail/static/src/xml/wip/old_widget/discuss.xml
  46. +11 −0 addons/mail/static/src/xml/wip/old_widget/discuss_invite_partner_dialog.xml
  47. +9 −0 addons/mail/static/src/xml/wip/widget/autocomplete_input.xml
  48. +33 −0 addons/mail/static/src/xml/wip/widget/composer.xml
  49. +18 −0 addons/mail/static/src/xml/wip/widget/discuss_mobile_mailbox_selection.xml
  50. +26 −0 addons/mail/static/src/xml/wip/widget/discuss_mobile_navbar.xml
  51. +63 −0 addons/mail/static/src/xml/wip/widget/discuss_root.xml
  52. +78 −0 addons/mail/static/src/xml/wip/widget/discuss_sidebar.xml
  53. +81 −0 addons/mail/static/src/xml/wip/widget/discuss_sidebar_item.xml
  54. +11 −0 addons/mail/static/src/xml/wip/widget/editable_text.xml
  55. +12 −0 addons/mail/static/src/xml/wip/widget/emojis_button.xml
  56. +18 −0 addons/mail/static/src/xml/wip/widget/emojis_popover.xml
  57. +65 −0 addons/mail/static/src/xml/wip/widget/message.xml
  58. +52 −0 addons/mail/static/src/xml/wip/widget/message_list.xml
  59. +20 −0 addons/mail/static/src/xml/wip/widget/thread.xml
  60. +14 −0 addons/mail/static/src/xml/wip/widget/thread_preview_list.xml
  61. +1,675 −0 addons/mail/static/tests/wip/discuss_tests.js
  62. +17 −0 addons/mail/views/mail_channel_views.xml
  63. +47 −0 addons/mail/views/mail_templates.xml
  64. +2,723 −0 addons/web/static/lib/owl/owl.js
  65. +6 −0 addons/web/static/lib/qweb/qweb2.js
  66. +12 −1 addons/web/static/src/js/core/session.js
  67. +1 −1 addons/web/static/src/js/services/core.js
  68. +1 −1 addons/web/static/tests/helpers/qunit_config.js
  69. +1 −0 addons/web/views/webclient_templates.xml
  70. +42 −26 odoo/addons/base/models/assetsbundle.py
@@ -59,5 +59,23 @@
'static/src/xml/announcement.xml',
'static/src/xml/user_menu.xml',
'static/src/xml/web_kanban_activity.xml',

'static/src/xml/wip/old_widget/common.xml',
'static/src/xml/wip/old_widget/discuss.xml',
'static/src/xml/wip/old_widget/discuss_invite_partner_dialog.xml',
'static/src/xml/wip/widget/autocomplete_input.xml',
'static/src/xml/wip/widget/composer.xml',
'static/src/xml/wip/widget/discuss_mobile_mailbox_selection.xml',
'static/src/xml/wip/widget/discuss_mobile_navbar.xml',
'static/src/xml/wip/widget/discuss_root.xml',
'static/src/xml/wip/widget/discuss_sidebar.xml',
'static/src/xml/wip/widget/discuss_sidebar_item.xml',
'static/src/xml/wip/widget/editable_text.xml',
'static/src/xml/wip/widget/emojis_button.xml',
'static/src/xml/wip/widget/emojis_popover.xml',
'static/src/xml/wip/widget/message.xml',
'static/src/xml/wip/widget/message_list.xml',
'static/src/xml/wip/widget/thread.xml',
'static/src/xml/wip/widget/thread_preview_list.xml',
],
}
@@ -1617,6 +1617,7 @@ var Discuss = AbstractAction.extend({

core.action_registry.add('mail.discuss', Discuss);


return Discuss;

});
@@ -0,0 +1,40 @@
odoo.define('mail.wip.model.MailFailure', function (require) {
'use strict';

const Model = require('mail.wip.model.Model');

class MailFailure extends Model {
/**
* @override {mail.wip.model.Model}
* @private
*/
_compute() {
const { message_id } = this;
Object.assign(this, {
_model: 'mail.failure',
localID: `mail.failure_${message_id}`,
});
}
}

// /**
// * Get a valid object for the 'mail.preview' template
// *
// * @returns {Object}
// */
// getPreview: function () {
// var preview = {
// body: _t("An error occured when sending an email"),
// date: this._lastMessageDate,
// documentID: this.documentID,
// documentModel: this.documentModel,
// id: 'mail_failure',
// imageSRC: this._moduleIcon,
// title: this._modelName,
// };
// return preview;
// },

return MailFailure;

});
@@ -0,0 +1,97 @@
odoo.define('mail.wip.model.Message', function (require) {
'use strict';

const emojis = require('mail.emojis');
const mailUtils = require('mail.utils');
const Model = require('mail.wip.model.Model');

const session = require('web.session');
const time = require('web.time');

class Message extends Model {
/**
* @override {mail.wip.model.Model}
* @private
*/
_compute() {
const {
author_id,
date,
id,
model,
res_id,
} = this;

Object.assign(this, {
_body: this._computeBody(),
_date: date ? moment(time.str_to_datetime(date)) : moment(),
_model: 'mail.message',
$author: author_id ? `res.partner_${author_id[0]}` : undefined,
$origin: res_id && model ? `${model}_${res_id}` : undefined,
$threads: this._computeThreads(),
localID: `mail.message_${id}`,
});
}

/**
* @private
* @return {string}
*/
_computeBody() {
let body = this.body;
for (let emoji of emojis) {
const { unicode } = emoji;
let regexp = new RegExp(
`(?:^|\\s|<[a-z]*>)(${unicode})(?=\\s|$|</[a-z]*>)`,
"g"
);
let originalBody = body;
body = body.replace(
regexp,
` <span class="o_mail_emoji">${unicode}</span> `
);
// Idiot-proof limit. If the user had the amazing idea of
// copy-pasting thousands of emojis, the image rendering can lead
// to memory overflow errors on some browsers (e.g. Chrome). Set an
// arbitrary limit to 200 from which we simply don't replace them
// (anyway, they are already replaced by the unicode counterpart).
if (_.str.count(body, "o_mail_emoji") > 200) {
body = originalBody;
}
}
// add anchor tags to urls
return mailUtils.parseAndTransform(body, mailUtils.addLink);
}

/**
* @private
* @return {mail.wip.model.Thread[]}
*/
_computeThreads() {
const {
channel_ids=[],
model,
needaction_partner_ids=[],
res_id,
starred_partner_ids=[],
} = this;
let threads = channel_ids.map(id => `mail.channel_${id}`);
if (needaction_partner_ids.includes(session.partner_id)) {
threads.push('mail.box_inbox');
}
if (starred_partner_ids.includes(session.partner_id)) {
threads.push('mail.box_starred');
}
if (model && res_id) {
const $origin = `${model}_${res_id}`;
if ($origin && !threads.includes($origin)) {
threads.push($origin);
}
}
return threads;
}
}

return Message;

});
@@ -0,0 +1,30 @@
odoo.define('mail.wip.model.Model', function () {
'use strict';

class Model {
/**
* @param {Object} data
*/
constructor(data) {
Object.assign(this, data);
this._compute();
}

/**
* @param {Object} data
*/
update(data) {
Object.assign(this, data);
this._compute();
}

/**
* @abstract
* @private
*/
_compute() {}
}

return Model;

});
@@ -0,0 +1,23 @@
odoo.define('mail.wip.model.Partner', function (require) {
'use strict';

const Model = require('mail.wip.model.Model');

class Partner extends Model {
/**
* @override {mail.wip.model.Model}
* @private
*/
_compute() {
const { id, $messages=[] } = this;
Object.assign(this, {
_model: 'res.partner',
$messages,
localID: `res.partner_${id}`,
});
}
}

return Partner;

});
@@ -0,0 +1,52 @@
odoo.define('mail.wip.model.Thread', function (require) {
'use strict';

const Model = require('mail.wip.model.Model');

class Thread extends Model {
/**
* @override {mail.wip.model.Model}
* @private
*/
_compute() {
let {
_model,
$caches=[],
$typingMembers=[],
channel_type,
direct_partner: [{
id: directPartnerID,
im_status: directPartnerImStatus,
email: directPartnerEmail,
name: directPartnerName,
}={}]=[],
id,
members=[],
pin=true,
} = this;

if (!_model && channel_type) {
_model = 'mail.channel';
}
if (!_model || !id) {
throw new Error('thread must always have `model` and `id`');
}

if (directPartnerID) {
this.$directPartner = `res.partner_${directPartnerID}`;
}

Object.assign(this, {
_model,
$caches,
$members: members.map(member => `res.partner_${member.id}`),
$typingMembers,
localID: `${_model}_${id}`,
pin,
});
}
}

return Thread;

});
@@ -0,0 +1,39 @@
odoo.define('mail.wip.model.ThreadCache', function (require) {
"use strict";

const Model = require('mail.wip.model.Model');

class ThreadCache extends Model {
/**
* @override {mail.wip.model.Model}
* @private
*/
_compute() {
let {
$messages=[],
$thread,
allHistoryLoaded=false,
loaded=false,
loading=false,
loadingMore=false,
stringifiedDomain,
} = this;

if (loaded) {
loading = false;
}

Object.assign(this, {
allHistoryLoaded,
loaded,
loading,
loadingMore,
localID: `${$thread}_${stringifiedDomain}`,
$messages,
});
}
}

return ThreadCache;

});
Oops, something went wrong.

0 comments on commit 1edd457

Please sign in to comment.
You can’t perform that action at this time.