From 8d88430a5fa586cc5d3d60659208d80df7067872 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 20 Feb 2025 09:28:28 -0300 Subject: [PATCH] Bug 38340: (follow-up) Refactor and tidy template files Signed-off-by: Tomas Cohen Arazi Signed-off-by: Brendan Lawlor --- .../includes/ill/backends/Standard/create.inc | 404 +++++++++--------- .../ill/backends/Standard/edititem.inc | 1 + .../ill/backends/Standard/inc/shared.js | 60 +-- .../ill/backends/Standard/migrate.inc | 1 + .../includes/ill/backends/Standard/create.inc | 1 + .../ill/backends/Standard/inc/shared.js | 60 +-- 6 files changed, 265 insertions(+), 262 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/create.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/create.inc index 29e137b3bf0..e06db297665 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/create.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/create.inc @@ -1,215 +1,207 @@ [% SET koha_version = Koha.Version %] [% PROCESS "ill/backends/Standard/inc/form_input_helpers.inc" %] [% IF whole.error %] -[% IF whole.status == 'missing_identifier' %] -

Please note: Mandatory field Identifier is missing.

-[% ELSIF whole.status == 'missing_branch' %] -

Please note: Library is a mandatory field.

-[% ELSIF whole.status == 'invalid_borrower' %] -

Please note: The patron details you entered are invalid.

-[% ELSIF whole.status == 'invalid_branch' %] -

Please note: The library you chose is invalid.

-[% ELSE %] -

Unhandled error

-[% END %] + [% IF whole.status == 'missing_identifier' %] +

Please note: Mandatory field Identifier is missing.

+ [% ELSIF whole.status == 'missing_branch' %] +

Please note: Library is a mandatory field.

+ [% ELSIF whole.status == 'invalid_borrower' %] +

Please note: The patron details you entered are invalid.

+ [% ELSIF whole.status == 'invalid_branch' %] +

Please note: The library you chose is invalid.

+ [% ELSE %] +

Unhandled error

+ [% END %] [% END %] [% IF whole.stage == "form" %] -

Create a manual ILL request

-
- [% INCLUDE 'csrf-token.inc' %] -
- General details -
    -
  1. - - -
  2. -
-
- [% type = whole.value.other.type %] - [% IF type %] - [% INCLUDE "ill/backends/Standard/inc/forms/${type}.inc" %] - [% END %] - [% INCLUDE "ill/backends/Standard/inc/custom_fields.inc" %] -
- Patron options -
    -
  1. - - - Required -
  2. -
  3. - - - Required -
  4. -
-
-
- - Cancel -
- - - -
-[% BLOCK backend_jsinclude %] - -[% END %] - -[% ELSIF whole.stage == "borrowers" %] - -

Borrower selection

-
- [% FOREACH prop IN whole.value.other.keys %] - [% IF prop != 'custom_key' && prop != 'custom_value' && prop != 'cardnumber' %] - +

Create a manual ILL request

+ + [% INCLUDE 'csrf-token.inc' %] +
+ General details +
    +
  1. + + +
  2. +
+
+ [% type = whole.value.other.type %] + [% IF type %] + [% INCLUDE "ill/backends/Standard/inc/forms/${type}.inc" %] + [% END %] + [% INCLUDE "ill/backends/Standard/inc/custom_fields.inc" %] +
+ Patron options +
    +
  1. + + + Required +
  2. +
  3. + + + Required +
  4. +
+
+
+ + Cancel +
+ + + +
+ [% BLOCK backend_jsinclude %] + [% END %] - [% END %] - [% keys = whole.value.other.custom_key.split('\0') %] - [% values = whole.value.other.custom_value.split('\0') %] - [% i = 0 %] - [% FOREACH key IN keys %] - - - [% i = i + 1 %] - [% END %] -
- Available borrowers for surname [% surname | html %] - [% FOREACH opt IN whole.value %] - [% IF opt.key == "brw" %] -
    -
  1. - - -
  2. -
- [% END %] - [% END %] -
-
- - Cancel -
- - +[% ELSIF whole.stage == "borrowers" %] + +

Borrower selection

+
+ [% FOREACH prop IN whole.value.other.keys %] + [% IF prop != 'custom_key' && prop != 'custom_value' && prop != 'cardnumber' %] + + [% END %] + [% END %] + [% keys = whole.value.other.custom_key.split('\0') %] + [% values = whole.value.other.custom_value.split('\0') %] + [% i = 0 %] + [% FOREACH key IN keys %] + + + [% i = i + 1 %] + [% END %] +
+ Available borrowers for surname [% surname | html %] + [% FOREACH opt IN whole.value %] + [% IF opt.key == "brw" %] +
    +
  1. + + +
  2. +
+ [% END %] + [% END %] +
+
+ + Cancel +
+
[% ELSE %] -

Unknown stage. This should not have happened. - +

Unknown stage. This should not have happened.

[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/edititem.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/edititem.inc index fe67493c359..f3b9d5fdff2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/edititem.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/edititem.inc @@ -84,6 +84,7 @@ [% BLOCK backend_jsinclude %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/inc/shared.js b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/inc/shared.js index c65fcdab401..61f188abe96 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/inc/shared.js +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/inc/shared.js @@ -1,44 +1,48 @@ -var core = [ [% whole.core %] ]; -var opac = [% opac || 0 %]; -document.addEventListener('DOMContentLoaded', function() { - $('#add-new-fields').click(function(e) { +document.addEventListener("DOMContentLoaded", function () { + $("#add-new-fields").click(function (e) { e.preventDefault(); - var row = '
  • ' + + var row = + '
  • ' + '' + - ' ' + + "" + + '" name="custom_key" placeholder="' + + __("key") + + '">' + + " " + ' ' + + "" + + '" placeholder="' + + __("value") + + '"> ' + '
  • '; - $('#standard-fields').append(row); + __("Delete") + + ""; + $("#standard-fields").append(row); }); - $('#standard-fields').on('click', '.delete-new-field', - function(event) { - event.preventDefault(); - $(event.target).parent().remove(); - } - ); - $('#type').change(function() { - $('#create_form').prepend( + $("#standard-fields").on("click", ".delete-new-field", function (event) { + event.preventDefault(); + $(event.target).parent().remove(); + }); + $("#type").change(function () { + $("#create_form").prepend( '' ); - $('#create_form').submit(); + $("#create_form").submit(); }); - $('#standard-fields').on('keyup', '.custom-name', function() { + $("#standard-fields").on("keyup", ".custom-name", function () { var val = $(this).val(); if (core.indexOf(val.toLowerCase()) > -1) { - $('#custom-warning').text(__("The name '%s' is not permitted").format(val)).show(); - $('#ill-submit').attr('disabled', true); - $('#add-new-fields').attr('disabled', true); + $("#custom-warning") + .text(__("The name '%s' is not permitted").format(val)) + .show(); + $("#ill-submit").attr("disabled", true); + $("#add-new-fields").attr("disabled", true); } else { - $('#custom-warning').hide(); - $('#ill-submit').attr('disabled', false); - $('#add-new-fields').attr('disabled', false); + $("#custom-warning").hide(); + $("#ill-submit").attr("disabled", false); + $("#add-new-fields").attr("disabled", false); } }); }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/migrate.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/migrate.inc index af20a7fdb66..9661c640e82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/migrate.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/migrate.inc @@ -107,6 +107,7 @@ [% BLOCK backend_jsinclude %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/create.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/create.inc index d79b91ef527..3b697151c04 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/create.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/create.inc @@ -108,6 +108,7 @@ [% BLOCK backend_jsinclude %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/inc/shared.js b/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/inc/shared.js index c65fcdab401..493a4146c64 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/inc/shared.js +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/inc/shared.js @@ -1,44 +1,48 @@ -var core = [ [% whole.core %] ]; -var opac = [% opac || 0 %]; -document.addEventListener('DOMContentLoaded', function() { - $('#add-new-fields').click(function(e) { +document.addEventListener("DOMContentLoaded", function () { + $("#add-new-fields").click(function (e) { e.preventDefault(); - var row = '
  • ' + + var row = + '
  • ' + '' + - ' ' + + "form-control input-fluid custom-field-input" + + '" name="custom_key" placeholder="' + + __("key") + + '">' + + " " + ' ' + + "form-control input-fluid custom-field-input" + + '" placeholder="' + + __("value") + + '"> ' + '
  • '; - $('#standard-fields').append(row); + __("Delete") + + ""; + $("#standard-fields").append(row); }); - $('#standard-fields').on('click', '.delete-new-field', - function(event) { - event.preventDefault(); - $(event.target).parent().remove(); - } - ); - $('#type').change(function() { - $('#create_form').prepend( + $("#standard-fields").on("click", ".delete-new-field", function (event) { + event.preventDefault(); + $(event.target).parent().remove(); + }); + $("#type").change(function () { + $("#create_form").prepend( '' ); - $('#create_form').submit(); + $("#create_form").submit(); }); - $('#standard-fields').on('keyup', '.custom-name', function() { + $("#standard-fields").on("keyup", ".custom-name", function () { var val = $(this).val(); if (core.indexOf(val.toLowerCase()) > -1) { - $('#custom-warning').text(__("The name '%s' is not permitted").format(val)).show(); - $('#ill-submit').attr('disabled', true); - $('#add-new-fields').attr('disabled', true); + $("#custom-warning") + .text(__("The name '%s' is not permitted").format(val)) + .show(); + $("#ill-submit").attr("disabled", true); + $("#add-new-fields").attr("disabled", true); } else { - $('#custom-warning').hide(); - $('#ill-submit').attr('disabled', false); - $('#add-new-fields').attr('disabled', false); + $("#custom-warning").hide(); + $("#ill-submit").attr("disabled", false); + $("#add-new-fields").attr("disabled", false); } }); }); -- 2.49.0