[IMP] mail: introduce ComposerView/onClickSuggestion

Task-2579306

closes odoo/odoo#88152

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Alexandre Kühn
2022-04-07 14:20:59 +02:00
parent 45a4f1d40b
commit 04b8a270d4
2 changed files with 10 additions and 5 deletions
@@ -1,7 +1,6 @@
/** @odoo-module **/
import { useUpdate } from '@mail/component_hooks/use_update';
import { replace } from '@mail/model/model_field_command';
import { registerMessagingComponent } from '@mail/utils/messaging_component';
const { Component } = owl;
@@ -94,10 +93,7 @@ export class ComposerSuggestion extends Component {
*/
_onClick(ev) {
ev.preventDefault();
this.composerView.update({ activeSuggestion: replace(this.composerSuggestion) });
this.composerView.insertSuggestion();
this.composerView.closeSuggestions();
this.composerView.update({ doFocus: true });
this.composerView.onClickSuggestion(this.composerSuggestion);
}
}
@@ -247,6 +247,15 @@ registerModel({
replyingToMessageView: clear(),
});
},
/**
* @param {ComposerSuggestion} suggestion
*/
onClickSuggestion(suggestion) {
this.update({ activeSuggestion: replace(suggestion) });
this.insertSuggestion();
this.closeSuggestions();
this.update({ doFocus: true });
},
/**
* @private
* @param {KeyboardEvent} ev