summaryrefslogtreecommitdiff
path: root/addons/website_mail/static/src
diff options
context:
space:
mode:
authorJérome Maes <jem@openerp.com>2017-01-03 14:48:41 +0100
committerJérome Maes <jem@openerp.com>2017-06-30 11:07:00 +0200
commitccf869a83e061a9bddbe17cb201721bebdd63926 (patch)
treec440a7a13c7239c64be4fbc9fb7d489d21399b51 /addons/website_mail/static/src
parentf447e9679f62d8e62e8fbace92d4dd661309c185 (diff)
[ADD] website_rating: generic rating management on chatter frontend
Extend new dynamic chatter to manage rating when posting comment. The model should inherit of rating.mixin and its frontend chatter should allow rating to enjoy star widget and rating card. This is more generic : stats, rating, ... are manage in one place (this module) for all document.
Diffstat (limited to 'addons/website_mail/static/src')
-rw-r--r--addons/website_mail/static/src/js/website_mail.js33
-rw-r--r--addons/website_mail/static/src/xml/website_mail.xml2
2 files changed, 20 insertions, 15 deletions
diff --git a/addons/website_mail/static/src/js/website_mail.js b/addons/website_mail/static/src/js/website_mail.js
index ef43190c529..dca4733b38a 100644
--- a/addons/website_mail/static/src/js/website_mail.js
+++ b/addons/website_mail/static/src/js/website_mail.js
@@ -39,9 +39,9 @@ odoo.define('website_mail.thread', function(require) {
});
this.set('messages', []);
this.set('message_count', this.options['message_count']);
- this.set('current_page', this.options['pager_start']);
this.set('pager', {});
this.set('domain', this.options['domain']);
+ this._current_page = this.options['pager_start'];
},
willStart: function(){
var self = this;
@@ -56,15 +56,15 @@ odoo.define('website_mail.thread', function(require) {
self.on("change:messages", self, self._renderMessages);
self.on("change:message_count", self, function(){
self._renderMessageCount();
- self.set('pager', self._pager(self.get('current_page')));
+ self.set('pager', self._pager(self._current_page));
});
self.on("change:pager", self, self._renderPager);
self.on("change:domain", self, self._onChangeDomain);
- self.on("change:current_page", self, self._onChangeCurrentPage);
// set options and parameters
self.options = _.extend(self.options, result['options'] || {});
self.set('message_count', self.options['message_count']);
self.set('messages', self.preprocessMessages(result['messages']));
+ return result;
});
},
@@ -108,6 +108,18 @@ odoo.define('website_mail.thread', function(require) {
//--------------------------------------------------------------------------
/**
+ * Change the current page by refreshing current domain
+ *
+ * @private
+ * @param {Number} page
+ * @param {Array} domain
+ */
+ _changeCurrentPage: function(page, domain){
+ this._current_page = page;
+ var d = domain ? domain : _.clone(this.get('domain'));
+ this.set('domain', d); // trigger fetch message
+ },
+ /**
* @private
* @returns {Deferred}
*/
@@ -120,7 +132,7 @@ odoo.define('website_mail.thread', function(require) {
'res_model': this.options['res_model'],
'res_id': this.options['res_id'],
'limit': this.options['pager_step'],
- 'offset': (this.get('current_page')-1) * this.options['pager_step'],
+ 'offset': (this._current_page-1) * this.options['pager_step'],
'allow_composer': this.options['allow_composer'],
};
// add fields to allow to post comment without being logged
@@ -133,10 +145,7 @@ odoo.define('website_mail.thread', function(require) {
if(this.get('domain')){
data['domain'] = this.get('domain');
}
- return ajax.jsonRpc('/website_mail/fetch', 'call', data).then(function(result){
- self.set('messages', self.preprocessMessages(result['messages']));
- self.set('message_count', result['message_count']);
- });
+ return data;
},
/**
* Generate the pager data for the given page number
@@ -196,16 +205,13 @@ odoo.define('website_mail.thread', function(require) {
// Handlers
//--------------------------------------------------------------------------
- _onChangeCurrentPage: function(){
+ _onChangeDomain: function(){
var self = this;
this.messageFetch().then(function(){
var p = self.get('current_page');
self.set('pager', self._pager(p));
});
},
- _onChangeDomain: function(){
- this.set('current_page', 1);
- },
/**
* @private
* @param {MouseEvent} event
@@ -213,9 +219,8 @@ odoo.define('website_mail.thread', function(require) {
_onClickPager: function(ev){
ev.preventDefault();
var page = $(ev.currentTarget).data('page');
- this.set('current_page', page);
+ this._changeCurrentPage(page);
},
-
});
web_editor_base.ready().then(function(){
diff --git a/addons/website_mail/static/src/xml/website_mail.xml b/addons/website_mail/static/src/xml/website_mail.xml
index 0e26c7e56ab..01eefeb5d8b 100644
--- a/addons/website_mail/static/src/xml/website_mail.xml
+++ b/addons/website_mail/static/src/xml/website_mail.xml
@@ -38,7 +38,7 @@
<form class="o_website_mail_composer_form" t-attf-action="/website_mail/post/post" method="POST">
<input type="hidden" name="csrf_token" t-att-value="widget.options['csrf_token']"/>
<div class="mb32">
- <textarea rows="4" name="message" class="form-control" placeholder="Write a message..." style="width: 75%"></textarea>
+ <textarea rows="4" name="message" class="form-control" placeholder="Write a message..."></textarea>
<input type='hidden' name="res_model" t-att-value="widget.options['res_model']"/>
<input type='hidden' name="res_id" t-att-value="widget.options['res_id']"/>
<input type='hidden' name="token" t-att-value="widget.options['token']" t-if="widget.options['token']"/>