From e76204c1e793351bcebbcac354086f9a4c947bbe Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Wed, 2 Oct 2024 10:07:59 +0200 Subject: [PATCH] Add a better label to the move region dropdown... --- .../static/content_editor/content_editor.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/content_editor/static/content_editor/content_editor.js b/content_editor/static/content_editor/content_editor.js index d30f65b6..4c43c4ce 100644 --- a/content_editor/static/content_editor/content_editor.js +++ b/content_editor/static/content_editor/content_editor.js @@ -515,22 +515,30 @@ } } - if (regions.length < 2 && !/^_unknown_/.test($inline.data("region"))) + const isCurrentUnknown = /^_unknown_/.test($inline.data("region")) + + if (regions.length < 2 && !isCurrentUnknown) { return + } - const select = buildDropdown(regions) + const select = buildDropdown( + regions, + isCurrentUnknown ? ContentEditor.messages.unknownRegion : "", + ) const regionInput = $inline.find(".order-machine-region") select.className = "inline_move_to_region" - select.value = regionInput.val() + select.value = isCurrentUnknown ? "" : regionInput.val() $inline.find("> h3 .inline_label").after(select) select.addEventListener("change", () => { - $inline.attr("data-region", select.value) - regionInput.val(select.value) - hideInlinesFromOtherRegions() - setBiggestOrdering($inline) - reorderInlines() + if (select.value) { + $inline.attr("data-region", select.value) + regionInput.val(select.value) + hideInlinesFromOtherRegions() + setBiggestOrdering($inline) + reorderInlines() + } }) }