[IMP] mail: introduce main and extra suggestions on composer view
Suggestion list view should depend on finding suggestables, not on the existence of suggestion views (which themselves have to be computed on the suggestion list view instead). Part of task-2741982 Part-of: odoo/odoo#95341
This commit is contained in:
@@ -884,11 +884,21 @@ registerModel({
|
||||
* @private
|
||||
* @returns {FieldCommand}
|
||||
*/
|
||||
_computeExtraSuggestionViews() {
|
||||
_computeExtraSuggestions() {
|
||||
if (this.suggestionDelimiterPosition === undefined) {
|
||||
return clear();
|
||||
}
|
||||
return unlink(this.mainSuggestionViews);
|
||||
return unlink(this.mainSuggestions);
|
||||
},
|
||||
/**
|
||||
* @returns {FieldCommand}
|
||||
*/
|
||||
_computeExtraSuggestionViews() {
|
||||
return insertAndReplace(this.extraSuggestions.map(suggestable => {
|
||||
return {
|
||||
suggestable: replace(suggestable),
|
||||
};
|
||||
}));
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
@@ -960,7 +970,7 @@ registerModel({
|
||||
* @return {boolean}
|
||||
*/
|
||||
_computeHasSuggestions() {
|
||||
return this.mainSuggestionViews.length > 0 || this.extraSuggestionViews.length > 0;
|
||||
return this.mainSuggestions.length > 0 || this.extraSuggestions.length > 0;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
@@ -1024,11 +1034,21 @@ registerModel({
|
||||
* @private
|
||||
* @returns {Record[]}
|
||||
*/
|
||||
_computeMainSuggestionViews() {
|
||||
_computeMainSuggestions() {
|
||||
if (this.suggestionDelimiterPosition === undefined) {
|
||||
return clear();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @returns {FieldCommand}
|
||||
*/
|
||||
_computeMainSuggestionViews() {
|
||||
return insertAndReplace(this.mainSuggestions.map(suggestable => {
|
||||
return {
|
||||
suggestable: replace(suggestable),
|
||||
};
|
||||
}));
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {string}
|
||||
@@ -1389,21 +1409,9 @@ registerModel({
|
||||
mainSuggestedRecords.length = Math.min(mainSuggestedRecords.length, limit);
|
||||
extraSuggestedRecords.length = Math.min(extraSuggestedRecords.length, limit - mainSuggestedRecords.length);
|
||||
this.update({
|
||||
extraSuggestionViews: insertAndReplace(
|
||||
extraSuggestedRecords.map(record => {
|
||||
return {
|
||||
suggestable: replace(record.suggestable),
|
||||
};
|
||||
}),
|
||||
),
|
||||
extraSuggestions: replace(extraSuggestedRecords.map(record => record.suggestable)),
|
||||
hasToScrollToActiveSuggestionView: true,
|
||||
mainSuggestionViews: insertAndReplace(
|
||||
mainSuggestedRecords.map(record => {
|
||||
return {
|
||||
suggestable: replace(record.suggestable),
|
||||
};
|
||||
}),
|
||||
),
|
||||
mainSuggestions: replace(mainSuggestedRecords.map(record => record.suggestable)),
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -1490,6 +1498,9 @@ registerModel({
|
||||
inverse: 'composerViewOwnerAsEmoji',
|
||||
isCausal: true,
|
||||
}),
|
||||
extraSuggestions: many('ComposerSuggestable', {
|
||||
compute: '_computeExtraSuggestions',
|
||||
}),
|
||||
/**
|
||||
* Determines the extra suggestions.
|
||||
*/
|
||||
@@ -1595,6 +1606,9 @@ registerModel({
|
||||
textareaLastInputValue: attr({
|
||||
default: "",
|
||||
}),
|
||||
mainSuggestions: many('ComposerSuggestable', {
|
||||
compute: '_computeMainSuggestions',
|
||||
}),
|
||||
/**
|
||||
* Determines the main suggestions.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user