summaryrefslogtreecommitdiff
path: root/addons/website_forum/static/src/js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-08-06 18:29:20 +0200
committerChristophe Simonis <chs@odoo.com>2019-08-06 18:48:24 +0200
commit7d04dc1c7c51dfd18951912628b14bee446a2b01 (patch)
treee89601e493bea092239df55a5ef406b2e05d7d7b /addons/website_forum/static/src/js
parentb091014686d86ad793e2d1cbf0e7ffea8fbde361 (diff)
parent9e74730a26b09fa4e516bc0d76550f7c7c502fac (diff)
[MERGE] forward port branch saas-12.2 up to 9e74730a26b
Diffstat (limited to 'addons/website_forum/static/src/js')
-rw-r--r--addons/website_forum/static/src/js/website_forum.js33
1 files changed, 30 insertions, 3 deletions
diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js
index 88dd7e222a7..832d29936ab 100644
--- a/addons/website_forum/static/src/js/website_forum.js
+++ b/addons/website_forum/static/src/js/website_forum.js
@@ -24,6 +24,9 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({
'click .vote_up:not(.karma_required), .vote_down:not(.karma_required)': '_onVotePostClick',
'click .o_js_validation_queue a[href*="/validate"]': '_onValidationQueueClick',
'click .accept_answer:not(.karma_required)': '_onAcceptAnswerClick',
+ 'click .validate_answer [data-href]': '_onAcceptAnswerClick',
+ 'mouseenter .validate_answer [data-href]': '_onRemoveValidAnswerMouse',
+ 'mouseleave .validate_answer [data-href]': '_onRemoveValidAnswerMouse',
'click .favourite_question': '_onFavoriteQuestionClick',
'click .comment_delete': '_onDeleteCommentClick',
'click .notification_close': '_onCloseNotificationClick',
@@ -350,6 +353,8 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({
*/
_onAcceptAnswerClick: function (ev) {
ev.preventDefault();
+ var self = this;
+ var $acceptAnswerLinks = this.$('.accept_answer');
var $link = $(ev.currentTarget);
this._rpc({
route: $link.data('href'),
@@ -368,19 +373,41 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({
$link.parent().append($warning);
}
} else {
+ $acceptAnswerLinks.removeClass('oe_answer_true')
+ .addClass('oe_answer_false');
$link.toggleClass('oe_answer_true', !!data)
.toggleClass('oe_answer_false', !data);
+
+ // TODO in master, review the utility of this function...
+ self._onCheckAnswerStatus(ev);
+
+ // If we are removing an accepted answer, reload the page as the
+ // design is quite different with or without an accepted answer.
+ if ($link.closest('.validate_answer').length) {
+ window.location.reload();
+ }
}
});
- this._onCheckAnswerStatus(ev);
+ },
+ /**
+ * @private
+ * @param {Event} ev
+ */
+ _onRemoveValidAnswerMouse: function (ev) {
+ var hover = (ev.type === 'mouseenter');
+ $(ev.currentTarget).find('.fa')
+ .toggleClass('fa-times-circle text-danger', hover)
+ .toggleClass('fa-check-circle text-success', !hover);
},
/**
* @private
* @param {Event} ev
*/
_onCheckAnswerStatus: function (ev) {
- var $link = $(ev.currentTarget);
- $link.toggleClass('text-success', !$link.hasClass('oe_answer_true'));
+ _.each(this.$('.accept_answer'), function (link) {
+ var $link = $(link);
+ $link.toggleClass('text-success', $link.hasClass('oe_answer_true'));
+ });
},
/**
* @private