From 3d13086c629245120f4c6887e4d4a1e5a01624a0 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Fri, 28 Apr 2023 13:23:05 +0200 Subject: [PATCH 001/169] fix: sort options by translated label --- .../public/js/frappe/form/controls/select.js | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/select.js b/frappe/public/js/frappe/form/controls/select.js index 6a6f4ccf58..1b91acb383 100644 --- a/frappe/public/js/frappe/form/controls/select.js +++ b/frappe/public/js/frappe/form/controls/select.js @@ -107,33 +107,19 @@ frappe.ui.form.add_options = function (input, options_list) { if (!Array.isArray(options_list)) { return $select; } - // create options - for (var i = 0, j = options_list.length; i < j; i++) { - var v = options_list[i]; - var value = null; - var label = null; - if (!is_null(v)) { - var is_value_null = is_null(v.value); - var is_label_null = is_null(v.label); - var is_disabled = Boolean(v.disabled); - var is_selected = Boolean(v.selected); - if (is_value_null && is_label_null) { - value = v; - label = __(v); - } else { - value = is_value_null ? "" : v.value; - label = is_label_null ? __(value) : __(v.label); - } - } + options_list + .map((raw_option) => parse_option(raw_option)) + .sort((a, b) => a.label.localeCompare(b.label)) + .map((option) => + $("