Bug 21704: Edit framework subfield link is broken (TT filter)
authorTomas Cohen Arazi <tomascohen@theke.io>
Sun, 28 Oct 2018 12:36:32 +0000 (09:36 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 29 Oct 2018 00:17:33 +0000 (00:17 +0000)
This patch removes URL building from the controller
(admin/marctagstructure.pl) and does it on the templates, using the
right 'uri' filter for the query parameters.

It also removes:
- No longer used attributes that are passed to the template
- Duplicated code in the templates

To test:
- Go to Home > Administration > MARC bibliographic framework
- On any of the listed frameworks, pick the 'MARC structure' action in
the dropdown
- On any subfield, hover on the actions dropdown
=> FAIL: The URLs are wrongly formed
- Click on the links
=> FAIL: You get errors because of the bad URL
- Apply this patch
- Reload the 'MARC structure' page
- On any subfield, hover on the actions dropdown
=> SUCCESS: LInks look correct
- Click on any of them
=> SUCCESS: They work!
- Use the 'Display only used tags/subfields' checkbox
=> SUCCESS: No behaviour change!
- Sign off :-D

Sponsored-by: Theke Solutions

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

admin/marctagstructure.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt

index 43de4fb..e42ce4f 100755 (executable)
@@ -248,9 +248,6 @@ if ($op eq 'add_form') {
                        $row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
             $row_data{ind1_defaultvalue} = $results[$i]->{'mts_ind1_defaultvalue'};
             $row_data{ind2_defaultvalue} = $results[$i]->{'mts_ind2_defaultvalue'};
-                       $row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&amp;tagfield=".$results[$i]->{'mts_tagfield'}."&amp;frameworkcode=".$frameworkcode;
-                       $row_data{edit}          = "$script_name?op=add_form&amp;searchfield="            .$results[$i]->{'mts_tagfield'}."&amp;frameworkcode=".$frameworkcode;
-                       $row_data{delete}        = "$script_name?op=delete_confirm&amp;searchfield="      .$results[$i]->{'mts_tagfield'}."&amp;frameworkcode=".$frameworkcode;
                        $j=$i;
                        my @internal_loop = ();
                        while ( ( $j < $cnt ) and ( $results[$i]->{'tagfield'} == $results[$j]->{'tagfield'} ) ) {
@@ -295,9 +292,6 @@ if ($op eq 'add_form') {
                        $row_data{authorised_value} = $results->[$i]{'authorised_value'};
             $row_data{ind1_defaultvalue} = $results->[$i]{'ind1_defaultvalue'};
             $row_data{ind2_defaultvalue} = $results->[$i]{'ind2_defaultvalue'};
-                       $row_data{subfield_link}    = "marc_subfields_structure.pl?tagfield="          .$results->[$i]{'tagfield'}."&amp;frameworkcode=".$frameworkcode;
-                       $row_data{edit}             = "$script_name?op=add_form&amp;searchfield="      .$results->[$i]{'tagfield'}."&amp;frameworkcode=".$frameworkcode;
-                       $row_data{delete}           = "$script_name?op=delete_confirm&amp;searchfield=".$results->[$i]{'tagfield'}."&amp;frameworkcode=".$frameworkcode;
                        push(@loop_data, \%row_data);
                }
                $template->param(loop => \@loop_data);
index 1214808..1910451 100644 (file)
@@ -41,7 +41,7 @@
 
 [% IF ( else ) %]
 <div id="toolbar" class="btn-toolbar">
-    <a class="btn btn-default btn-sm" id="addtag" href="/cgi-bin/koha/admin/marctagstructure.pl?op=add_form&amp;frameworkcode=[% framework.frameworkcode | html %]"><i class="fa fa-plus"></i> New tag</a>
+    <a class="btn btn-default btn-sm" id="addtag" href="/cgi-bin/koha/admin/marctagstructure.pl?op=add_form&amp;frameworkcode=[% framework.frameworkcode | uri %]"><i class="fa fa-plus"></i> New tag</a>
 </div>[% END %]
 
 <h1>MARC Framework for [% IF framework %][% framework.frameworktext | html %] ([% framework.frameworkcode | html %])[% ELSE %]default MARC framework[% END %]</h1>
         </tr>
     </thead>
     <tbody>
-    [% IF ( select_display ) %]
-        [% FOREACH loo IN loop %]
+    [% FOREACH loo IN loop %]
         <tr>
             <td>[% loo.tagfield | html %]</td>
             <td>
                 [% loo.liblibrarian | html %]
+            [% IF ( select_display ) %]
                 [% FOREACH subfield IN loo.subfields %]
                     <p>
                         Tab:[% subfield.tab | html %] | $[% subfield.tagsubfield | html %]
                         [% subfield.liblibrarian | html %] [% IF ( subfield.kohafield ) %][% subfield.kohafield | html %][% END %][% IF ( subfield.repeatable ) %], repeatable[% END %][% IF ( subfield.mandatory ) %], Mandatory[% END %][% IF ( subfield.seealso ) %], See [% subfield.seealso | html %][% END %][% IF ( subfield.authorised_value ) %], [% subfield.authorised_value | html %][% END %][% IF ( subfield.authtypecode ) %], [% subfield.authtypecode | html %][% END %][% IF ( subfield.value_builder ) %], [% subfield.value_builder | html %][% END %]
                     </p>
                 [% END %]
+            [% END %]
             </td>
             <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
             <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
                     <a class="btn btn-default btn-xs dropdown-toggle" id="marctagactions[% loo.tagfield | html %]" role="button" data-toggle="dropdown" href="#">
                         Actions <b class="caret"></b></a>
                     <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="marctagactions[% loo.tagfield | html %]">
-                        <li><a href="[% loo.subfield_link | uri %]"><i class="fa fa-eye"></i> Subfields</a></li>
-                        <li><a href="[% loo.edit | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
-                        <li><a href="[% loo.delete | uri %]"><i class="fa fa-trash"></i> Delete</a></li>
+                        <li><a href="marc_subfields_structure.pl?op=add_form&amp;tagfield=[% loo.tagfield | uri %]&amp;frameworkcode=[% framework.frameworkcode | uri %]"><i class="fa fa-eye"></i> Subfields</a></li>
+                        <li><a href="?op=add_form&amp;searchfield=[% loo.tagfield | uri %]&amp;frameworkcode=[% framework.frameworkcode | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
+                        <li><a href="?op=delete_confirm&amp;searchfield=[% loo.tagfield | uri %]&amp;frameworkcode=[% framework.frameworkcode | uri %]"><i class="fa fa-trash"></i> Delete</a></li>
                     </ul>
                 </div>
             </td>
         </tr>
-        [% END %]
-    [% ELSE %]
-    [% FOREACH loo IN loop %]
-    <tr>
-        <td>[% loo.tagfield | html %]</td>
-        <td>[% loo.liblibrarian | html %]</td>
-        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
-        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
-        <td>[% loo.authorised_value | html %]</td>
-        <td>[% loo.ind1_defaultvalue | html %]</td>
-        <td>[% loo.ind2_defaultvalue | html %]</td>
-        <td>
-            <div class="dropdown">
-                <a class="btn btn-default btn-xs dropdown-toggle" id="marctagactions[% loo.tagfield | html %]" role="button" data-toggle="dropdown" href="#">
-                    Actions <b class="caret"></b></a>
-                <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="marctagactions[% loo.tagfield | html %]">
-                    <li><a href="[% loo.subfield_link | uri %]"><i class="fa fa-eye"></i> Subfields</a></li>
-                    <li><a href="[% loo.edit | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
-                    <li><a href="[% loo.delete | uri %]"><i class="fa fa-trash"></i> Delete</a></li>
-                </ul>
-            </div>
-        </td>
-    </tr>
-    [% END %]
     [% END %]
     </tbody>
     </table>
-
-
-
 [% END %]
 
             </main>