+
+
-
-
-
diff --git a/addons/mail/static/src/components/activity_mark_done_popover/tests/activity_mark_done_popover_tests.js b/addons/mail/static/src/components/activity_mark_done_popover/tests/activity_mark_done_popover_tests.js
index 48de4aca668..001f08b12ee 100644
--- a/addons/mail/static/src/components/activity_mark_done_popover/tests/activity_mark_done_popover_tests.js
+++ b/addons/mail/static/src/components/activity_mark_done_popover/tests/activity_mark_done_popover_tests.js
@@ -1,13 +1,6 @@
/** @odoo-module **/
-import { insert } from '@mail/model/model_field_command';
-import {
- afterEach,
- afterNextRender,
- beforeEach,
- createRootMessagingComponent,
- start,
-} from '@mail/utils/test_utils';
+import { afterEach, beforeEach, start } from '@mail/utils/test_utils';
import Bus from 'web.Bus';
@@ -18,13 +11,6 @@ QUnit.module('activity_mark_done_popover_tests.js', {
beforeEach() {
beforeEach(this);
- this.createActivityMarkDonePopoverComponent = async activity => {
- await createRootMessagingComponent(this, "ActivityMarkDonePopover", {
- props: { activityLocalId: activity.localId },
- target: this.widget.el,
- });
- };
-
this.start = async params => {
const res = await start({ ...params, data: this.data });
const { components, env, widget } = res;
diff --git a/addons/mail/static/src/models/activity_mark_done_popover_view/activity_mark_done_popover_view.js b/addons/mail/static/src/models/activity_mark_done_popover_view/activity_mark_done_popover_view.js
new file mode 100644
index 00000000000..858ef155059
--- /dev/null
+++ b/addons/mail/static/src/models/activity_mark_done_popover_view/activity_mark_done_popover_view.js
@@ -0,0 +1,78 @@
+/** @odoo-module **/
+
+import { registerModel } from '@mail/model/model_core';
+import { attr, one2one } from '@mail/model/model_field';
+
+registerModel({
+ name: 'ActivityMarkDonePopoverView',
+ identifyingFields: ['activityViewOwner'],
+ recordMethods: {
+ /**
+ * Handles blur on this feedback textarea.
+ */
+ onBlur() {
+ if (!this.exists() || !this.feedbackTextareaRef || !this.feedbackTextareaRef.el) {
+ return;
+ }
+ this._backupFeedback();
+ },
+ /**
+ * Handles click on this "Discard" button.
+ */
+ onClickDiscard() {
+ this._close();
+ },
+ /**
+ * Handles click on this "Done" button.
+ */
+ async onClickDone() {
+ await this.activityViewOwner.activity.markAsDone({
+ feedback: this.feedbackTextareaRef.el.value,
+ });
+ if (!this.exists() || !this.component) {
+ return;
+ }
+ this.component.trigger('reload', { keepChanges: true });
+ },
+ /**
+ * Handles click on this "Done & Schedule Next" button.
+ */
+ onClickDoneAndScheduleNext() {
+ this.activityViewOwner.activity.markAsDoneAndScheduleNext({
+ feedback: this.feedbackTextareaRef.el.value,
+ });
+ },
+ /**
+ * Handles keydown on this activity mark done.
+ */
+ onKeydown(ev) {
+ if (ev.key === 'Escape') {
+ this._close();
+ }
+ },
+ /**
+ * @private
+ */
+ _backupFeedback() {
+ this.activityViewOwner.activity.update({
+ feedbackBackup: this.feedbackTextareaRef.el.value,
+ });
+ },
+ /**
+ * @private
+ */
+ _close() {
+ this._backupFeedback();
+ this.component.trigger('o-popover-close');
+ },
+ },
+ fields: {
+ activityViewOwner: one2one('ActivityView', {
+ inverse: 'activityMarkDonePopoverView',
+ readonly: true,
+ required: true,
+ }),
+ component: attr(),
+ feedbackTextareaRef: attr(),
+ },
+});
diff --git a/addons/mail/static/src/models/activity_view/activity_view.js b/addons/mail/static/src/models/activity_view/activity_view.js
index a3ea6169cb1..7d1a7081a33 100644
--- a/addons/mail/static/src/models/activity_view/activity_view.js
+++ b/addons/mail/static/src/models/activity_view/activity_view.js
@@ -150,6 +150,11 @@ registerModel({
readonly: true,
required: true,
}),
+ activityMarkDonePopoverView: one2one('ActivityMarkDonePopoverView', {
+ default: insertAndReplace(),
+ inverse: 'activityViewOwner',
+ isCausal: true,
+ }),
/**
* Determines whether the details are visible.
*/