From 65560a0ec0fd3ac9e629bb5a5a52e3105e5f76db Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 9 Mar 2023 11:53:37 +0000 Subject: [PATCH] Bug 33177: Use include file for subfield constraints in both authority and bibliographic frameworks This patch creates a new include file, subfields-structure-form.inc, which can be used by both auth_subfields_structure.tt and marc_subfields_structure.tt. Conditional logic in the template handles the small differences between the two systems. To test, apply the patch and restart Koha services. - Go to Administration -> MARC bibliograhpic framework - In the "Actions" menu for one of your frameworks, choose "MARC structure." - In the "Actions" menu for one of the tags, choose "Edit subfields" - Test the subfield constraints entry form by making multiple changes and confirming that the changes are saved correctly. - Try making multiple changes under multiple tabs. - Try creating a new subfield under the "New" tab. Perform the same tests under Administration -> Authority types. Note the differences between the two versions: - The biblio version has "Important," "Max length," checkboxes for "Visibility," and a text input for "Link." - The authority version has a dropdown for "Visibility" and "Koha link." --- admin/auth_subfields_structure.pl | 40 +-- .../en/includes/subfields-structure-form.inc | 263 ++++++++++++++++++ .../modules/admin/auth_subfields_structure.tt | 180 +----------- .../modules/admin/marc_subfields_structure.tt | 206 +------------- 4 files changed, 280 insertions(+), 409 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/subfields-structure-form.inc diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index 2198561752..9b18097851 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -122,7 +122,6 @@ if ($op eq 'add_form') { $row_data{tagsubfield} = ""; $row_data{liblibrarian} = ""; $row_data{libopac} = ""; - $row_data{seealso} = ""; $row_data{hidden} = "000"; $row_data{repeatable} = 0; $row_data{mandatory} = 0; @@ -148,36 +147,26 @@ if ($op eq 'add_form') { } elsif ($op eq 'add_validate') { $template->param(tagfield => "$input->param('tagfield')"); my @tagsubfield = $input->multi_param('tagsubfield'); - my @liblibrarian = $input->multi_param('liblibrarian'); - my @libopac = $input->multi_param('libopac'); my @kohafield = ''.$input->param('kohafield'); - my @tab = $input->multi_param('tab'); - my @seealso = $input->multi_param('seealso'); - my @ohidden = $input->multi_param('ohidden'); - my @authorised_value_categories = $input->multi_param('authorised_value'); my $authtypecode = $input->param('authtypecode'); my @frameworkcodes = $input->multi_param('frameworkcode'); - my @value_builder =$input->multi_param('value_builder'); - my @defaultvalue = $input->multi_param('defaultvalue'); my $display_order; for (my $i=0; $i<= $#tagsubfield ; $i++) { - my $tagfield =$input->param('tagfield'); - my $tagsubfield =$tagsubfield[$i]; - $tagsubfield="@" unless $tagsubfield ne ''; - my $liblibrarian =$liblibrarian[$i]; - my $libopac =$libopac[$i]; - my $repeatable =$input->param("repeatable$i")?1:0; - my $mandatory =$input->param("mandatory$i")?1:0; - my $kohafield =$kohafield[$i]; - my $tab =$tab[$i]; - my $seealso =$seealso[$i]; - my $authorised_value = $authorised_value_categories[$i]; - my $frameworkcode =$frameworkcodes[$i]; - my $value_builder=$value_builder[$i]; - my $defaultvalue = $defaultvalue[$i]; - my $hidden = $ohidden[$i]; #collate from 3 hiddens; - my $isurl = $input->param("isurl$i")?1:0; + my $tagfield = $input->param('tagfield'); + my $tagsubfield = $tagsubfield[$i]; + my $liblibrarian = $input->param("liblibrarian_$i"); + my $libopac = $input->param("libopac_$i"); + my $repeatable = $input->param("repeatable_$i") ? 1 : 0; + my $mandatory = $input->param("mandatory_$i") ? 1 : 0; + my $kohafield = $input->param("kohafield_$i"); + my $tab = $input->param("tab_$i"); + my $defaultvalue = $input->param("defaultvalue_$i"); + my $authorised_value = $input->param("authorised_value_$i"); + my $frameworkcode = $frameworkcodes[$i]; + my $value_builder = $input->param("value_builder_$i"); + my $hidden = $input->param("hidden_$i"); + my $isurl = $input->param("isurl_$i") ? 1 : 0; if ($liblibrarian) { my $ass = Koha::Authority::Subfields->find( { @@ -193,7 +182,6 @@ if ($op eq 'add_form') { mandatory => $mandatory, kohafield => $kohafield, tab => $tab, - seealso => $seealso, authorised_value => $authorised_value, frameworkcode => $frameworkcode, value_builder => $value_builder, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/subfields-structure-form.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/subfields-structure-form.inc new file mode 100644 index 0000000000..1474bc6bde --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/subfields-structure-form.inc @@ -0,0 +1,263 @@ +[% BLOCK setsubfield %][% FILTER collapse %] + [% IF ( loo.tagsubfield ) %] + [% SET subfield = loo.tagsubfield %] + [% ELSE %] + [% SET subfield = loo.subfieldcode %] + [% END %] +[% END %][% END %] + +
+ + +
+ + [% FOREACH loo IN loop %] + [% PROCESS setsubfield %] +
+ +
+
+ Basic constraints +
    + [% IF ( subfield == 0 || subfield ) %] +
  1. + Subfield code: + [% subfield | html %] + +
  2. + [% ELSE %] +
  3. + + +
  4. + [% END %] +
  5. + + +
  6. +
  7. + + +
  8. +
  9. + + [% IF loo.repeatable %] + + [% ELSE %] + + [% END %] +
  10. +
  11. + + [% IF loo.mandatory %] + + [% ELSE %] + + [% END %] +
  12. + [% IF ( biblioframework ) %] +
  13. + + [% IF loo.important %] + + [% ELSE %] + + [% END %] +
  14. + [% END %] +
  15. + + +
    Ignore means that the subfield does not display in the record editor and that its value, if any, is deleted from the record
    +
  16. +
+
+
+ +
+
+ Advanced constraints +
    +
  1. + + +
  2. + [% IF ( biblioframework ) %] +
  3. + + +
  4. + [% END %] +
  5. + + [% IF ( biblioframework ) %] + [% IF loo.hidden_protected %] + + [% ELSE %] + + [% END %] + + + + + + + + + + + [% ELSE %] + + [% END %] +
  6. +
  7. + + [% IF loo.isurl %] + + [% ELSE %] + + [% END %] + If checked, it means that the subfield is a URL and can be clicked +
  8. + [% IF ( biblioframework ) %] +
  9. + + +
    An index name, e.g. title or Local-Number
    +
  10. + [% END %] + [% UNLESS ( biblioframework ) %] +
  11. + + +
  12. + [% END %] +
+ [% IF ( biblioframework ) %] + + [% END %] +
+
+ +
+
+ Other options (choose one) +
    +
  1. + + +
  2. +
  3. + [% IF ( biblioframework ) %] + + + [% ELSE %] + + + [% END %] +
  4. +
  5. + + +
  6. +
+
+
+
+ [% END # /FOREACH loo %] +
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt index 9db4d0c8b7..8867881cf1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt @@ -89,7 +89,6 @@ -
Cancel
[% BLOCK outputsubfield %][% FILTER collapse %] [% SWITCH ( subfieldanchor ) %] @@ -102,184 +101,9 @@ [% END %] [% END %][% END %] -
- -
- [% FOREACH loo IN loop %] -
-
    + [% INCLUDE "subfields-structure-form.inc" %] - [% IF ( loo.new_subfield ) %] -
  1. - - -
  2. - [% ELSE %] -
  3. - -
  4. - [% END %] -
  5. - - [% IF loo.repeatable %] - - [% ELSE %] - - [% END %] -
  6. -
  7. - - [% IF loo.mandatory %] - - [% ELSE %] - - [% END %] -
  8. -
  9. -
  10. -
  11. - -
    Ignore means that the subfield does not display in the record editor and that its value, if any, is deleted from the record
    -
  12. -
  13. -
    - Display -
      -
    1. - -
    2. -
    -
    -
  14. -
  15. -
    - Advanced constraints: -
      -
    1. - - [% IF loo.isurl %] - - [% ELSE %] - - [% END %] - If checked, it means that the subfield is a URL and can be clicked. -
    2. -
    3. - - -
    4. -
    -
    -
  16. -
  17. -
    Help input -
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    -
    -
  18. -

-
- [% END %] -
-
+
Cancel
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt index 95df1dbfd6..69a6667a29 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt @@ -138,211 +138,7 @@ [% END %] [% END %][% END %] -
- - -
- - [% FOREACH loo IN loop %] -
- -
-
- Basic constraints -
    - [% IF ( loo.subfieldcode == 0 || loo.subfieldcode ) %] -
  1. - Subfield code: - [% loo.subfieldcode | html %] - -
  2. - [% ELSE %] -
  3. - - -
  4. - [% END %] -
  5. - - -
  6. -
  7. - - -
  8. -
  9. - - [% IF loo.repeatable %] - - [% ELSE %] - - [% END %] -
  10. -
  11. - - [% IF loo.mandatory %] - - [% ELSE %] - - [% END %] -
  12. -
  13. - - [% IF loo.important %] - - [% ELSE %] - - [% END %] -
  14. -
  15. - -
    Ignore means that the subfield does not display in the record editor and that its value, if any, is deleted from the record
    -
  16. -
-
-
- -
-
- Advanced constraints -
    -
  1. - - -
  2. -
  3. - - -
  4. -
  5. - [% IF loo.hidden_protected %] - - [% ELSE %] - - [% END %] - - - - - - - - - - - -
  6. -
  7. - - [% IF loo.isurl %] - - [% ELSE %] - - [% END %] - If checked, it means that the subfield is a URL and can be clicked -
  8. -
  9. - - -
    An index name, e.g. title or Local-Number
    -
  10. -
  11. - - - - - -
  12. -
-
-
- -
-
- Other options (choose one) -
    -
  1. - - -
  2. -
  3. - - -
  4. -
  5. - - -
  6. -
-
-
-
- [% END # /FOREACH loo %] -
-
+ [% INCLUDE "subfields-structure-form.inc" biblioframework = 1 %]
Cancel -- 2.30.2