[FIX] mail: activity feedback: port odoo/odoo@63167fc5
to the new views
This commit is contained in:
@@ -51,11 +51,12 @@ var AbstractActivityField = AbstractField.extend({
|
||||
},
|
||||
|
||||
// private
|
||||
_markActivityDone: function (id) {
|
||||
_markActivityDone: function (id, feedback) {
|
||||
return this._rpc({
|
||||
model: 'mail.activity',
|
||||
method: 'action_done',
|
||||
args: [[id]],
|
||||
kwargs: {feedback: feedback},
|
||||
});
|
||||
},
|
||||
_readActivities: function () {
|
||||
@@ -133,7 +134,7 @@ var Activity = AbstractActivityField.extend({
|
||||
},
|
||||
|
||||
// public
|
||||
schedule_activity: function () {
|
||||
scheduleActivity: function () {
|
||||
var callback = this._reload.bind(this, {activity: true, thread: true});
|
||||
return this._scheduleActivity(false, callback);
|
||||
},
|
||||
@@ -181,9 +182,48 @@ var Activity = AbstractActivityField.extend({
|
||||
},
|
||||
_onMarkActivityDone: function (event) {
|
||||
event.preventDefault();
|
||||
var activity_id = $(event.currentTarget).data('activity-id');
|
||||
return this._markActivityDone(activity_id)
|
||||
.then(this._reload.bind(this, {activity: true, thread: true}));
|
||||
var self = this;
|
||||
var $popover_el = $(event.currentTarget);
|
||||
var activity_id = $popover_el.data('activity-id');
|
||||
if (!$popover_el.data('bs.popover')) {
|
||||
$popover_el.popover({
|
||||
title : _t('Feedback'),
|
||||
html: 'true',
|
||||
trigger:'click',
|
||||
content : function() {
|
||||
var $popover = $(QWeb.render("mail.activity_feedback_form", {}));
|
||||
$popover.on('click', '.o_activity_popover_done_next', function () {
|
||||
var feedback = _.escape($popover.find('#activity_feedback').val());
|
||||
self._markActivityDone(activity_id, feedback)
|
||||
.then(self.scheduleActivity.bind(self));
|
||||
});
|
||||
$popover.on('click', '.o_activity_popover_done', function () {
|
||||
var feedback = _.escape($popover.find('#activity_feedback').val());
|
||||
self._markActivityDone(activity_id, feedback)
|
||||
.then(self._reload.bind(self, {activity: true, thread: true}));
|
||||
});
|
||||
$popover.on('click', '.o_activity_popover_discard', function () {
|
||||
$popover_el.popover('hide');
|
||||
});
|
||||
return $popover;
|
||||
},
|
||||
}).on("show.bs.popover", function (e) {
|
||||
var $popover = $(this).data("bs.popover").tip();
|
||||
$popover.addClass('o_mail_activity_feedback').attr('tabindex', 0);
|
||||
$(".o_mail_activity_feedback.popover").not(e.target).popover("hide");
|
||||
}).on("shown.bs.popover", function () {
|
||||
var $popover = $(this).data("bs.popover").tip();
|
||||
$popover.find('#activity_feedback').focus();
|
||||
$popover.off('focusout');
|
||||
$popover.focusout(function (e) {
|
||||
// outside click of popover hide the popover
|
||||
// e.relatedTarget is the element receiving the focus
|
||||
if(!$popover.is(e.relatedTarget) && !$popover.find(e.relatedTarget).length) {
|
||||
$popover.popover('hide');
|
||||
}
|
||||
});
|
||||
}).popover('show');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ var Chatter = Widget.extend(chat_mixin, {
|
||||
this.trigger_up('reload', {fieldNames: fieldNames});
|
||||
},
|
||||
_onScheduleActivity: function () {
|
||||
this.fields.activity.schedule_activity();
|
||||
this.fields.activity.scheduleActivity();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
}
|
||||
|
||||
}
|
||||
/* Feedback popover (form view) */
|
||||
.o_mail_activity_feedback {
|
||||
max-width: 410px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Kanban View */
|
||||
.o_kanban_record {
|
||||
|
||||
@@ -438,7 +438,7 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
|
||||
});
|
||||
|
||||
QUnit.test('form activity widget: mark as done and remove', function (assert) {
|
||||
assert.expect(11);
|
||||
assert.expect(14);
|
||||
|
||||
var self = this;
|
||||
|
||||
@@ -481,6 +481,8 @@ QUnit.test('form activity widget: mark as done and remove', function (assert) {
|
||||
assert.ok(_.isEqual(args.args[0], [1]), "should call 'unlink' for id 1");
|
||||
} else if (route === '/web/dataset/call_kw/mail.activity/action_done') {
|
||||
assert.ok(_.isEqual(args.args[0], [2]), "should call 'action_done' for id 2");
|
||||
assert.strictEqual(args.kwargs.feedback, 'everything is ok',
|
||||
"the feedback should be sent correctly");
|
||||
// should generate a message and unlink the activity
|
||||
self.data.partner.records[0].message_ids = [1];
|
||||
messages.push({
|
||||
@@ -534,6 +536,12 @@ QUnit.test('form activity widget: mark as done and remove', function (assert) {
|
||||
assert.ok(!form.$('.o_mail_thread .o_thread_message').length,
|
||||
"there should be no chatter message");
|
||||
form.$('.o_mail_activity .o_activity_done[data-activity-id=2]').click();
|
||||
assert.strictEqual(form.$('.o_mail_activity_feedback.popover').length, 1,
|
||||
"a feedback popover should be visible");
|
||||
$('.o_mail_activity_feedback.popover textarea').val('everything is ok'); // write a feedback
|
||||
form.$('.o_activity_popover_done').click(); // send feedback
|
||||
assert.strictEqual(form.$('.o_mail_activity_feedback.popover').length, 0,
|
||||
"the feedback popover should be closed");
|
||||
assert.ok(!form.$('.o_mail_activity .o_thread_message').length,
|
||||
"there should be no more activity");
|
||||
assert.strictEqual(form.$('.o_mail_thread .o_thread_message').length, 1,
|
||||
|
||||
Reference in New Issue
Block a user