[IMP] mail: move code to models (ComposerSuggestionView)
Task-3000269 closes odoo/odoo#101576 X-original-commit: 66734b6c187e78e039f7f32c8adf105cb32aa2d6 Signed-off-by: Louis Wicket (wil) <wil@odoo.com> Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
+4
-22
@@ -1,6 +1,7 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { useUpdate } from '@mail/component_hooks/use_update';
|
||||
import { useComponentToModel } from '@mail/component_hooks/use_component_to_model';
|
||||
import { useUpdateToModel } from '@mail/component_hooks/use_update_to_model';
|
||||
import { registerMessagingComponent } from '@mail/utils/messaging_component';
|
||||
|
||||
const { Component } = owl;
|
||||
@@ -12,7 +13,8 @@ export class ComposerSuggestionView extends Component {
|
||||
*/
|
||||
setup() {
|
||||
super.setup();
|
||||
useUpdate({ func: () => this._update() });
|
||||
useComponentToModel({ fieldName: 'component' });
|
||||
useUpdateToModel({ methodName: 'onComponentUpdate' });
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -26,26 +28,6 @@ export class ComposerSuggestionView extends Component {
|
||||
return this.props.record;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_update() {
|
||||
if (
|
||||
this.root.el &&
|
||||
this.composerSuggestionView.composerSuggestionListViewOwner.hasToScrollToActiveSuggestionView &&
|
||||
this.composerSuggestionView.composerSuggestionListViewOwnerAsActiveSuggestionView
|
||||
) {
|
||||
this.root.el.scrollIntoView({
|
||||
block: 'center',
|
||||
});
|
||||
this.composerSuggestionView.composerSuggestionListViewOwner.update({ hasToScrollToActiveSuggestionView: false });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object.assign(ComposerSuggestionView, {
|
||||
|
||||
@@ -26,8 +26,19 @@ registerModel({
|
||||
composerViewOwner.closeSuggestions();
|
||||
composerViewOwner.update({ doFocus: true });
|
||||
},
|
||||
onComponentUpdate() {
|
||||
if (
|
||||
this.component.root.el &&
|
||||
this.composerSuggestionListViewOwner.hasToScrollToActiveSuggestionView &&
|
||||
this.composerSuggestionListViewOwnerAsActiveSuggestionView
|
||||
) {
|
||||
this.component.root.el.scrollIntoView({ block: 'center' });
|
||||
this.composerSuggestionListViewOwner.update({ hasToScrollToActiveSuggestionView: false });
|
||||
}
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
component: attr(),
|
||||
composerSuggestionListViewOwner: one('ComposerSuggestionListView', {
|
||||
compute() {
|
||||
if (this.composerSuggestionListViewExtraComposerSuggestionViewItemOwner) {
|
||||
|
||||
Reference in New Issue
Block a user