[FIX] mail: display follower subtypes order by sequence

Before this fix, follower subtypes were displayed by order of id,
whereas in DiscussController.read_subscription_data(),
it was ordered by :
\- parent_mode
\- res_mode
\- internal
\- sequence

See : https://github.com/odoo/odoo/blob/fc115ebdf7c3783f9eaabba71eccce23c676d957/addons/mail/controllers/discuss.py#L471-472
In this commit, we just reproduce the same order.

Also, for `parentModel` and `resModel`, we want the record
with their values unset to come first.
We added 'undefined-first',
as this sort order might be needed for other models.

closes odoo/odoo#93315

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Audric Onockx (auon)
2022-06-20 17:57:38 +02:00
committed by Sébastien Theys
parent ba59359420
commit f07439fbc8
3 changed files with 18 additions and 1 deletions
@@ -77,6 +77,15 @@ export class RelationSet {
}
break;
}
case 'falsy-first': {
if (!valA) {
return -1;
}
if (!valB) {
return 1;
}
break;
}
case 'case-insensitive-asc': {
if (typeof valA !== 'string' || typeof valB !== 'string') {
break;
@@ -57,6 +57,8 @@ registerModel({
parentModel: attr(),
// AKU FIXME: use relation instead
resModel: attr(),
sequence: attr(),
sequence: attr({
default: 1,
}),
},
});
@@ -49,6 +49,12 @@ registerModel({
*/
_sortFollowerSubtypeViews() {
return [
['falsy-first', 'subtype.parentModel'],
['case-insensitive-asc', 'subtype.parentModel'],
['falsy-first', 'subtype.resModel'],
['case-insensitive-asc', 'subtype.resModel'],
['smaller-first', 'subtype.isInternal'],
['smaller-first', 'subtype.sequence'],
['smaller-first', 'subtype.id'],
];
},