From f163710c9eb08bacb7375d0a7f8cf5abb57ef56a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 13 Feb 2023 19:34:45 +0000 Subject: [PATCH] Bug 32164: Add link to MARC modification templates from batch record modification page This patch adds a more visible link from the batch record modification page in the event that there are no MARC modification templates defined. The template checks that the user has permission. The patch also modifies the same message on the MARC modification templates page so that the interfaces are more unified, and tweaks the operation of the "New action" button. To test you should have no MARC modification templates defined. - Apply the patch and go to Tools -> Batch record modification. - If you're logged in as a user with permission you should see a message dialog containing a button, "Create a new MARC modification template." - Clicking it should take you to the MARC modification templates page, where you'll see a similar message and a button, "Create a new template." Clicking this button should trigger a modal form, just like clicking the "New template" button in the toolbar should. - Submit the form to create a new template. You should see message on the following page that says "New action." Clicking the button should display the entry form, and then clicking "Cancel" should hide the form and redisplay the message. Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall --- .../en/modules/tools/batch_record_modification.tt | 7 +++++-- .../en/modules/tools/marc_modification_templates.tt | 12 +++++++++--- .../prog/js/marc_modification_templates.js | 8 +++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt index fc2dcff60d0..f7935a09448 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt @@ -269,8 +269,11 @@ [% ELSIF view == 'errors' %] [% FOR error IN errors %] [% IF error == 'no_template_defined' %] -
- No MARC modification template is defined. You have to create at least one template for using this tool. +
+

No MARC modification template is defined. You have to create at least one template in order to use this tool.

+ [% IF ( CAN_user_tools_marc_modification_templates ) %] + Create a new MARC modification template + [% END %]
[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt index 53e80a5d889..01c1bfc44fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt @@ -70,7 +70,7 @@
New template [% IF ( template_id != '' ) %] - New action + New action Delete template [% END %]
@@ -208,7 +208,10 @@
[% ELSE %] -

There are no defined actions for this template.

+
+

There are no defined actions for this template.

+

New action

+
[% END # /IF ActionsLoop %]
@@ -307,7 +310,10 @@ [% ELSE %]

MARC modification templates

-

There are no defined templates. Please create a template first.

+
+

There are no defined templates. Please create a template first.

+ Create a new template +
[% END # /IF TemplatesLoop %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js index e513fbe8968..847f88c009f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js @@ -68,9 +68,10 @@ $(document).ready(function() { updateAllEvery(); }); - $("#new_action").on("click",function(e){ + $(".new_action").on("click",function(e){ e.preventDefault(); cancelEditAction(); + $("#no_defined_actions").hide(); $("#add_action").show(); $("#action").focus(); }); @@ -350,6 +351,11 @@ function cancelEditAction() { document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml; document.getElementById('action_submit').value = window.action_submit_value; + + if( $("#template_actions").length < 1 ){ + $("#no_defined_actions").show(); + } + $("#add_action").hide(); } -- 2.30.2