From b6466a996cddf945bac686079de057b176759b18 Mon Sep 17 00:00:00 2001 From: lmstrand Date: Wed, 22 Jan 2025 13:40:14 +0200 Subject: [PATCH] Bug 30618: Highlight missing mandatory select2 elements in item form checks If one tries to add an item and mandatory or important select field isn't filled, field isn't highlighted like input fields. This patch adds correct background color to empty mandatory select2 fields. To test: 1. Add item, but leave mandatory select2 field empty (e.g. home library, itemtype). 2. Attempt to save item. => Note that field isn't highlighted. 3. Apply this patch (restart service if needed). 4. Repeat steps 1. and 2. => Field should now be highlighted. Sponsored-by: Koha-Suomi Oy --- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index f35750951a..f1e59ade80 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -706,6 +706,16 @@ function CheckMandatorySubfields(p) { .find(".input_marceditor"); } if (!editor.val()) { + if ( + editor.hasClass("select2") || + editor.closest(".select2-container").length + ) { + editor + .siblings(".select2") + .children(".selection") + .children(".select2-selection") + .css("background-color", "#FFFFCC"); + } editor.addClass("missing"); total++; } -- 2.34.1