summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components
diff options
context:
space:
mode:
authorDhruv Patel <dhp@odoo.com>2021-02-05 06:20:22 +0000
committerDhruv Patel <dhp@odoo.com>2021-03-15 11:16:04 +0000
commit4445207161c84d2854055df63013c1361e5d4697 (patch)
tree624a8ddb642f4884b06e88f7b60aa1db958d1a6a /addons/mail/static/src/components
parent0847fc136e0bb2db3e41912e863096c60d8453d2 (diff)
[FIX] mail: channels alphabetical order should not be case sensitive
Currently, In channels listing, the order of the channels is case sensitive. The Uppercase names are listing first and then all the Lowercase ones. but it should be displayed in the alphabetical case insensitive order. With this commit, we have resolved this issue and now channels are listing in case insensitive alphabetical manner. Task : 2453592 closes odoo/odoo#65579 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components')
-rw-r--r--addons/mail/static/src/components/discuss/tests/discuss_sidebar_tests.js18
-rw-r--r--addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js12
2 files changed, 29 insertions, 1 deletions
diff --git a/addons/mail/static/src/components/discuss/tests/discuss_sidebar_tests.js b/addons/mail/static/src/components/discuss/tests/discuss_sidebar_tests.js
index 23d74c5cbe3..34c884ebe6c 100644
--- a/addons/mail/static/src/components/discuss/tests/discuss_sidebar_tests.js
+++ b/addons/mail/static/src/components/discuss/tests/discuss_sidebar_tests.js
@@ -138,6 +138,24 @@ QUnit.test('sidebar find shows channels matching search term even when user is m
);
});
+QUnit.test('sidebar channels should be ordered case insensitive alphabetically', async function (assert) {
+ assert.expect(1);
+
+ this.data['mail.channel'].records.push(
+ { id: 19, name: "Xyz" },
+ { id: 20, name: "abc" },
+ { id: 21, name: "Abc" },
+ { id: 22, name: "Xyz" }
+ );
+ await this.start();
+ const results = document.querySelectorAll('.o_DiscussSidebar_groupChannel .o_DiscussSidebarItem_name');
+ assert.deepEqual(
+ [results[0].textContent, results[1].textContent, results[2].textContent, results[3].textContent],
+ ["abc", "Abc", "Xyz", "Xyz"],
+ "Channel name should be in case insensitive alphabetical order"
+ );
+});
+
});
});
});
diff --git a/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js b/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js
index 09b512aaad7..d12d0353854 100644
--- a/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js
+++ b/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js
@@ -116,7 +116,17 @@ class DiscussSidebar extends Component {
thread.isPinned &&
thread.model === 'mail.channel'
)
- .sort((c1, c2) => c1.displayName < c2.displayName ? -1 : 1);
+ .sort((c1, c2) => {
+ if (c1.displayName && !c2.displayName) {
+ return -1;
+ } else if (!c1.displayName && c2.displayName) {
+ return 1;
+ } else if (c1.displayName && c2.displayName && c1.displayName !== c2.displayName) {
+ return c1.displayName.toLowerCase() < c2.displayName.toLowerCase() ? -1 : 1;
+ } else {
+ return c1.id - c2.id;
+ }
+ });
if (!this.discuss.sidebarQuickSearchValue) {
return allOrderedAndPinnedMultiUserChannels;
}