[REF] web: Move orderByToString to views/utils.js

This commit moves the 'orderByToString' helper to views/utils.js.

Part-of: odoo/odoo#110819
Co-authored-by: Mathieu Duckerts-Antoine <dam@dooo.com>
This commit is contained in:
Mathieu Duckerts-Antoine
2023-02-14 17:09:05 +01:00
committed by Bruno Boi
co-authored by Mathieu Duckerts-Antoine
parent a3dd93194f
commit f3dfd9b651
2 changed files with 22 additions and 15 deletions
@@ -21,7 +21,14 @@ import { session } from "@web/session";
import { FormArchParser } from "@web/views/form/form_arch_parser";
import { ListConfirmationDialog } from "@web/views/list/list_confirmation_dialog";
import { Model } from "@web/views/model";
import { archParseBoolean, evalDomain, isNumeric, isRelational, isX2Many } from "@web/views/utils";
import {
archParseBoolean,
evalDomain,
isNumeric,
isRelational,
isX2Many,
orderByToString,
} from "@web/views/utils";
const { DateTime } = luxon;
import { markRaw, markup, toRaw } from "@odoo/owl";
@@ -66,20 +73,6 @@ export function isAllowedDateField(groupByField) {
);
}
/**
* @typedef {Object} OrderTerm ?
* @property {string} name
* @property {boolean} asc
*/
/**
* @param {OrderTerm[]} orderBy
* @returns {string}
*/
function orderByToString(orderBy) {
return orderBy.map((o) => `${o.name} ${o.asc ? "ASC" : "DESC"}`).join(", ");
}
/**
* @param {RawContext} rawContext
* @param {Context} defaultContext
+14
View File
@@ -241,6 +241,20 @@ export function processMeasure(measure) {
return measure === "__count__" ? "__count" : measure;
}
/**
* @typedef {Object} OrderTerm ?
* @property {string} name
* @property {boolean} asc
*/
/**
* @param {OrderTerm[]} orderBy
* @returns {string}
*/
export function orderByToString(orderBy) {
return orderBy.map((o) => `${o.name} ${o.asc ? "ASC" : "DESC"}`).join(", ");
}
/**
* @param {any} string
* @return {OrderTerm[]}