Bug 12176: [QA Follow-up] Small additem adjustments
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 20 May 2015 12:56:48 +0000 (14:56 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 26 May 2015 17:24:39 +0000 (14:24 -0300)
Adjusting a few small things and making qa tools happy:

[1] Remove .hidden after [% avalue %] in additem.tt. (Typo)
[2] A closer look revealed that mv.avalue is useless too. An input element
    does not contain any content. Putting it after the hidden element
    in a non-visible context has no meaning.
[3] Change handling of select attributes readonly and disabled.
[4] Remove unused variable $attributes_no_value_textarea
[5] Removed a comment with TODO referring to this report.
[6] Moving a duplicated TT variable (mv.javascript) outside IF statement.
[7] And finally could not resist this one: Moving strings Tag editor and
    No popup from script to template.  Plugins++
    NOTE: Most item plugins redirect click to focus. In that case there is
    no popup, but unfortunately the text Tag editor comes up.
    When you remove or rename function Click, No popup comes up. So it works.

Sorry that this small list kept growing :)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt

index 48bcd59..8a800e1 100755 (executable)
@@ -155,7 +155,6 @@ sub generate_subfield_form {
            $value = $input->param('barcode');
        }
         my $attributes_no_value = qq(id="$subfield_data{id}" name="field_value" class="input_marceditor" size="50" maxlength="$subfield_data{maxlength}" );
-        my $attributes_no_value_textarea = qq(id="$subfield_data{id}" name="field_value" class="input_marceditor" rows="5" cols="64" );
 
         # Getting list of subfields to keep when restricted editing is enabled
         my $subfieldsToAllowForRestrictedEditing = C4::Context->preference('SubfieldsToAllowForRestrictedEditing');
@@ -236,7 +235,6 @@ sub generate_subfield_form {
                     id          => $subfield_data{id},
                     maxlength   => $subfield_data{max_length},
                     value       => $value,
-                    avalue      => $authorised_lib{$value},
                 };
             }
             else {
@@ -249,14 +247,11 @@ sub generate_subfield_form {
                 };
                 # If we're on restricted editing, and our field is not in the list of subfields to allow,
                 # then it is read-only
-                if (
+                $subfield_data{marc_value}->{readonlyselect} = (
                     not $allowAllSubfields
                     and $restrictededition
                     and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
-                ) {
-                    $subfield_data{marc_value}->{readonly} ='readonly="readonly"',
-                    $subfield_data{marc_value}->{disabled} ='disabled="disabled"',
-                }
+                ) ? 1: 0;
             }
         }
             # it's a thesaurus / authority field
@@ -280,16 +275,14 @@ sub generate_subfield_form {
                 id => $subfield_data{id}, tabloop => $loop_data };
             $plugin->build( $pars );
             if( !$plugin->errstr ) {
-                #TODO Report 12176 will make this even better !
                 my $class= 'buttonDot'. ( $plugin->noclick? ' disabled': '' );
-                my $title= $plugin->noclick? 'No popup': 'Tag editor';
                 $subfield_data{marc_value} = {
                     type        => 'text_plugin',
                     id          => $subfield_data{id},
                     maxlength   => $subfield_data{max_length},
                     value       => $value,
                     class       => $class,
-                    title       => $title,
+                    nopopup     => $plugin->noclick,
                     javascript  => $plugin->javascript,
                 };
             } else {
index 78e97c5..1cc8402 100644 (file)
@@ -228,9 +228,13 @@ $(document).ready(function() {
 
                 [% SET mv = ite.marc_value %]
                 [% IF ( mv.type == 'hidden' ) %]
-                    <input type="hidden" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />[% mv.avalue %].hidden
+                    <input type="hidden" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]">
                 [% ELSIF ( mv.type == 'select' ) %]
-                    <select name="[%- mv.name -%]" id="[%- mv.id -%]" size="1" class="input_marceditor" [% mv.readonly %] [% mv.disabled %]>
+                    [% IF ( mv.readonlyselect ) %]
+                        <select name="[%- mv.name -%]" id="[%- mv.id -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
+                    [% ELSE %]
+                        <select name="[%- mv.name -%]" id="[%- mv.id -%]" size="1" class="input_marceditor">
+                    [% END %]
                     [% FOREACH aval IN mv.values %]
                         [% IF aval == mv.default %]
                         <option value="[%- aval -%]" selected="selected">[%- mv.labels.$aval -%]</option>
@@ -245,11 +249,12 @@ $(document).ready(function() {
                     <a href="#" class="buttonDot"  onclick="[%- dopop -%]; return false;" title="Tag Editor">...</a>
                 [% ELSIF ( mv.type == 'text_plugin' ) %]
                     <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
-                    [% IF ( mv.title == 'Tag editor' ) %]
-                    <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="Tag editor">...</a>[%- mv.javascript -%]
-                    [% ELSIF ( mv.title == 'No popup' ) %]
-                    <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="No popup">...</a>[%- mv.javascript -%]
+                    [% IF ( mv.nopopup ) %]
+                        <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="No popup">...</a>
+                    [% ELSE  %]
+                        <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="Tag editor">...</a>
                     [% END %]
+                    [%- mv.javascript -%]
                 [% ELSIF ( mv.type == 'text' ) %]
                     <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
                 [% ELSIF ( mv.type == 'textarea' ) %]