diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index 68eea23180..324b3e0fd9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -314,16 +314,35 @@ [% WRAPPER tab_panels %] [% FOR language IN languages %] [% SET translated_content = translated_contents.item(language.lang) %] + [% SET required = category == 'news' && language.lang == 'default' ? 1 : 0 %] [% WRAPPER tab_panel tabname="lang_${language.lang}" %]
  1. - - + + + [% IF required %]Required[% END %]
  2. - - @@ -690,33 +709,44 @@ $( "#" + location + "_notes" ).show(); } - $(document).ready(function() { - [% IF category == 'news' %] + const category = "[% category | html %]"; + const wysiwyg = [% wysiwyg ? 1 : 0 | html %]; + + if (category == "news") { $("#add_additional_content").validate({ - submitHandler: function(form){ - if ( ! $("#title_default").val().length > 0 ) { - alert(_("Please specify a title for 'Default'")); + submitHandler: function (form) { + // catch an empty title_default when default tab is not visible + if (!document.querySelector("#lang_default_panel.show") && !$("#title_default").val().length > 0) { + const defaultTab = document.querySelector("#lang_default-tab"); + const tab = new bootstrap.Tab(defaultTab); + tab.show(); + $("#title_default").focus(); return false; } - else { - [% UNLESS wysiwyg %] - let content = $('#content_default').siblings(".CodeMirror")[0].CodeMirror.getValue(); - [% ELSE %] - let content = tinyMCE.get('content_default').getContent(); - [% END %] - if ( ! content.length > 0 ) { - alert(_("Please specify a content for 'Default'")); - return false; + let content = wysiwyg ? tinyMCE.get("content_default").getContent() : $("#content_default").siblings(".CodeMirror")[0].CodeMirror.getValue(); + if (!content.length > 0) { + // catch an empty content_default when default tab is not visible + if (!document.querySelector("#lang_default_panel.show")) { + const defaultTab = document.querySelector("#lang_default-tab"); + const tab = new bootstrap.Tab(defaultTab); + tab.show(); } + // focus editor + if (wysiwyg) { + tinyMCE.get("content_default").focus(); + } else { + $("#content_default").siblings(".CodeMirror")[0].CodeMirror.focus(); + } + return false; } - form.submit(); - } + }, }); - [% END %] + } - showLocationNotes( $("#location").val() ); + $(document).ready(function () { + showLocationNotes($("#location").val()); $("#location").on("change", function(){ showLocationNotes( $(this).val() );