[IMP] mail: introduce AutocompleteInputView
With all its identifying fields Task-2817076 closes odoo/odoo#88035 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
onFocusin="_onFocusinThread"
|
||||
/>
|
||||
</t>
|
||||
<t t-if="chatWindow.hasNewMessageForm">
|
||||
<t t-if="chatWindow.newMessageAutocompleteInputView">
|
||||
<div class="o_ChatWindow_newMessageForm">
|
||||
<span class="o_ChatWindow_newMessageFormLabel">
|
||||
To:
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<t t-if="messaging.device.isMobile and discussView.discuss.activeMobileNavbarTabId === 'mailbox'">
|
||||
<DiscussMobileMailboxSelection className="'o_Discuss_mobileMailboxSelection border-bottom'"/>
|
||||
</t>
|
||||
<t t-if="messaging.device.isMobile and (discussView.discuss.isAddingChannel or discussView.discuss.isAddingChat)">
|
||||
<t t-if="discussView.mobileAddItemHeaderAutocompleteInputView">
|
||||
<div class="o_Discuss_mobileAddItemHeader border-bottom">
|
||||
<AutocompleteInput
|
||||
className="'o_Discuss_mobileAddItemHeaderInput'"
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class="o_DiscussSidebarCategory_content">
|
||||
<t t-if="category.isOpen">
|
||||
<t t-if="category.isAddingItem">
|
||||
<t t-if="category.addingItemAutocompleteInputView">
|
||||
<div class="o_DiscussSidebarCategory_addingItem d-flex mb-2">
|
||||
<AutocompleteInput
|
||||
className="'o_DiscussSidebarCategory_addingItemInput flex-grow-1'"
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<t t-if="!messaging.device.isMobile and !messaging.discuss.discussView">
|
||||
<t t-call="mail.MessagingMenu.newMessageButton"/>
|
||||
</t>
|
||||
<t t-if="messaging.device.isMobile and messagingMenu.isMobileNewMessageToggled">
|
||||
<t t-if="messagingMenu.mobileNewMessageAutocompleteInputView">
|
||||
<AutocompleteInput
|
||||
className="'o_MessagingMenu_mobileNewMessageInput'"
|
||||
customClass="id + '_mobileNewMessageInputAutocomplete'"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { registerModel } from '@mail/model/model_core';
|
||||
import { one } from '@mail/model/model_field';
|
||||
|
||||
registerModel({
|
||||
name: 'AutocompleteInputView',
|
||||
identifyingFields: [[
|
||||
'chatWindowOwnerAsNewMessage',
|
||||
'discussSidebarCategoryOwnerAsAddingItem',
|
||||
'discussViewOwnerAsMobileAddItemHeader',
|
||||
'messagingMenuOwnerAsMobileNewMessageInput',
|
||||
]],
|
||||
fields: {
|
||||
chatWindowOwnerAsNewMessage: one('ChatWindow', {
|
||||
inverse: 'newMessageAutocompleteInputView',
|
||||
readonly: true,
|
||||
}),
|
||||
discussSidebarCategoryOwnerAsAddingItem: one('DiscussSidebarCategory', {
|
||||
inverse: 'addingItemAutocompleteInputView',
|
||||
readonly: true,
|
||||
}),
|
||||
discussViewOwnerAsMobileAddItemHeader: one('DiscussView', {
|
||||
inverse: 'mobileAddItemHeaderAutocompleteInputView',
|
||||
readonly: true,
|
||||
}),
|
||||
messagingMenuOwnerAsMobileNewMessageInput: one('MessagingMenu', {
|
||||
inverse: 'mobileNewMessageAutocompleteInputView',
|
||||
readonly: true,
|
||||
}),
|
||||
},
|
||||
});
|
||||
@@ -286,6 +286,16 @@ registerModel({
|
||||
}
|
||||
return this.env._t("New message");
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {FieldCommand}
|
||||
*/
|
||||
_computeNewMessageAutocompleteInputView() {
|
||||
if (this.hasNewMessageForm) {
|
||||
return insertAndReplace();
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {string}
|
||||
@@ -489,6 +499,11 @@ registerModel({
|
||||
name: attr({
|
||||
compute: '_computeName',
|
||||
}),
|
||||
newMessageAutocompleteInputView: one('AutocompleteInputView', {
|
||||
compute: '_computeNewMessageAutocompleteInputView',
|
||||
inverse: 'chatWindowOwnerAsNewMessage',
|
||||
isCausal: true,
|
||||
}),
|
||||
/**
|
||||
* The content of placeholder for the autocomplete input of
|
||||
* 'new_message' chat window.
|
||||
|
||||
@@ -63,6 +63,16 @@ registerModel({
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {FieldCommand}
|
||||
*/
|
||||
_computeAddingItemAutocompleteInputView() {
|
||||
if (this.isOpen && this.isAddingItem) {
|
||||
return insertAndReplace();
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {FieldCommand}
|
||||
@@ -196,6 +206,11 @@ registerModel({
|
||||
activeItem: one('DiscussSidebarCategoryItem', {
|
||||
compute: '_computeActiveItem',
|
||||
}),
|
||||
addingItemAutocompleteInputView: one('AutocompleteInputView', {
|
||||
compute: '_computeAddingItemAutocompleteInputView',
|
||||
inverse: 'discussSidebarCategoryOwnerAsAddingItem',
|
||||
isCausal: true,
|
||||
}),
|
||||
/**
|
||||
* Determines how the autocomplete of this category should behave.
|
||||
* Must be one of: 'channel', 'chat'.
|
||||
|
||||
@@ -2,11 +2,32 @@
|
||||
|
||||
import { registerModel } from '@mail/model/model_core';
|
||||
import { one } from '@mail/model/model_field';
|
||||
import { clear, insertAndReplace } from '@mail/model/model_field_command';
|
||||
|
||||
registerModel({
|
||||
name: 'DiscussView',
|
||||
identifyingFields: ['discuss'],
|
||||
recordMethods: {
|
||||
/**
|
||||
* @private
|
||||
* @returns {FieldCommand}
|
||||
*/
|
||||
_computeMobileAddItemHeaderAutocompleteInputView() {
|
||||
if (
|
||||
this.messaging.device.isMobile &&
|
||||
(this.discuss.isAddingChannel || this.discuss.isAddingChat)
|
||||
) {
|
||||
return insertAndReplace();
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
mobileAddItemHeaderAutocompleteInputView: one('AutocompleteInputView', {
|
||||
compute: '_computeMobileAddItemHeaderAutocompleteInputView',
|
||||
inverse: 'discussViewOwnerAsMobileAddItemHeader',
|
||||
isCausal: true,
|
||||
}),
|
||||
discuss: one('Discuss', {
|
||||
inverse: 'discussView',
|
||||
readonly: true,
|
||||
|
||||
@@ -59,6 +59,16 @@ registerModel({
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {FieldCommand}
|
||||
*/
|
||||
_computeMobileNewMessageAutocompleteInputView() {
|
||||
if (this.isOpen && this.messaging.isInitialized && this.messaging.device.isMobile && this.isMobileNewMessageToggled) {
|
||||
return insertAndReplace();
|
||||
}
|
||||
return clear();
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {string}
|
||||
@@ -114,6 +124,11 @@ registerModel({
|
||||
inverse: 'messagingMenu',
|
||||
isCausal: true,
|
||||
}),
|
||||
mobileNewMessageAutocompleteInputView: one('AutocompleteInputView', {
|
||||
compute: '_computeMobileNewMessageAutocompleteInputView',
|
||||
inverse: 'messagingMenuOwnerAsMobileNewMessageInput',
|
||||
isCausal: true,
|
||||
}),
|
||||
mobileNewMessageInputPlaceholder: attr({
|
||||
compute: '_computeMobileNewMessageInputPlaceholder',
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user