Bug 12176: Remove HTML from additem.pl
This patch removes HTML code from additem.pl. To test: 1. Check no regressions on Add/Edit/Save items 2. Update translation files for a language, check new strings "Tag editor" & "No popup" on staff PO file 3. Check it passes xt/tt_valid.t Patch partially rebased, part rewritten. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
cee05ed04e
commit
47d2de9c02
2 changed files with 110 additions and 39 deletions
|
@ -231,39 +231,43 @@ sub generate_subfield_form {
|
|||
}
|
||||
|
||||
if ( $subfieldlib->{hidden} > 4 or $subfieldlib->{hidden} <= -4 ) {
|
||||
$subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'hidden',
|
||||
id => $subfield_data{id},
|
||||
maxlength => $subfield_data{max_length},
|
||||
value => $value,
|
||||
avalue => $authorised_lib{$value},
|
||||
};
|
||||
}
|
||||
else {
|
||||
my @scrparam = (
|
||||
-name => "field_value",
|
||||
-values => \@authorised_values,
|
||||
-default => $value,
|
||||
-labels => \%authorised_lib,
|
||||
-override => 1,
|
||||
-size => 1,
|
||||
-multiple => 0,
|
||||
-id => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
|
||||
-class => "input_marceditor",
|
||||
);
|
||||
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'select',
|
||||
id => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
|
||||
values => \@authorised_values,
|
||||
labels => \%authorised_lib,
|
||||
default => $value,
|
||||
};
|
||||
# If we're on restricted editing, and our field is not in the list of subfields to allow,
|
||||
# then it is read-only
|
||||
push @scrparam, (-readonly => "readonly"), (-disabled => "disabled")
|
||||
if (
|
||||
not $allowAllSubfields
|
||||
and $restrictededition
|
||||
and !grep { $tag . '$' . $subfieldtag eq $_ } @subfieldsToAllow
|
||||
);
|
||||
$subfield_data{marc_value} =CGI::scrolling_list(@scrparam);
|
||||
if (
|
||||
not $allowAllSubfields
|
||||
and $restrictededition
|
||||
and !grep { $tag . '$' . $subfieldtag eq $_ } @subfieldsToAllow
|
||||
) {
|
||||
$subfield_data{marc_value}->{readonly} ='readonly="readonly"',
|
||||
$subfield_data{marc_value}->{disabled} ='disabled="disabled"',
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
# it's a thesaurus / authority field
|
||||
elsif ( $subfieldlib->{authtypecode} ) {
|
||||
$subfield_data{marc_value} = "<input type=\"text\" $attributes />
|
||||
<a href=\"#\" class=\"buttonDot\"
|
||||
onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$subfieldlib->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}'); return false;\" title=\"Tag Editor\">...</a>
|
||||
";
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'text_auth',
|
||||
id => $subfield_data{id},
|
||||
maxlength => $subfield_data{max_length},
|
||||
value => $value,
|
||||
authtypecode => $subfieldlib->{authtypecode},
|
||||
};
|
||||
}
|
||||
# it's a plugin field
|
||||
elsif ( $subfieldlib->{value_builder} ) { # plugin
|
||||
|
@ -279,29 +283,66 @@ sub generate_subfield_form {
|
|||
#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} = qq[<input type="text" $attributes /><a href="#" id="buttonDot_$subfield_data{id}" class="$class" title="$title">...</a>\n].$plugin->javascript;
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'text_plugin',
|
||||
id => $subfield_data{id},
|
||||
maxlength => $subfield_data{max_length},
|
||||
value => $value,
|
||||
class => $class,
|
||||
title => $title,
|
||||
javascript => $plugin->javascript,
|
||||
};
|
||||
} else {
|
||||
warn $plugin->errstr;
|
||||
$subfield_data{marc_value} = "<input type=\"text\" $attributes />"; # supply default input form
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'text',
|
||||
id => $subfield_data{id},
|
||||
maxlength => $subfield_data{max_length},
|
||||
value => $value,
|
||||
}; # supply default input form
|
||||
}
|
||||
}
|
||||
elsif ( $tag eq '' ) { # it's an hidden field
|
||||
$subfield_data{marc_value} = qq(<input type="hidden" $attributes />);
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'hidden',
|
||||
id => $subfield_data{id},
|
||||
maxlength => $subfield_data{max_length},
|
||||
value => $value,
|
||||
};
|
||||
}
|
||||
elsif ( $subfieldlib->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ?
|
||||
$subfield_data{marc_value} = qq(<input type="text" $attributes />);
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'text',
|
||||
id => $subfield_data{id},
|
||||
maxlength => $subfield_data{max_length},
|
||||
value => $value,
|
||||
};
|
||||
}
|
||||
elsif ( length($value) > 100
|
||||
or (C4::Context->preference("marcflavour") eq "UNIMARC" and
|
||||
300 <= $tag && $tag < 400 && $subfieldtag eq 'a' )
|
||||
or (C4::Context->preference("marcflavour") eq "MARC21" and
|
||||
500 <= $tag && $tag < 600 )
|
||||
) {
|
||||
elsif (
|
||||
length($value) > 100
|
||||
or (
|
||||
C4::Context->preference("marcflavour") eq "UNIMARC"
|
||||
and 300 <= $tag && $tag < 400 && $subfieldtag eq 'a'
|
||||
)
|
||||
or (
|
||||
C4::Context->preference("marcflavour") eq "MARC21"
|
||||
and 500 <= $tag && $tag < 600
|
||||
)
|
||||
) {
|
||||
# oversize field (textarea)
|
||||
$subfield_data{marc_value} = "<textarea $attributes_no_value_textarea>$value</textarea>\n";
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'textarea',
|
||||
id => $subfield_data{id},
|
||||
value => $value,
|
||||
};
|
||||
} else {
|
||||
# it's a standard field
|
||||
$subfield_data{marc_value} = "<input type=\"text\" $attributes />";
|
||||
# it's a standard field
|
||||
$subfield_data{marc_value} = {
|
||||
type => 'text',
|
||||
id => $subfield_data{id},
|
||||
maxlength => $subfield_data{max_length},
|
||||
value => $value,
|
||||
};
|
||||
}
|
||||
|
||||
return \%subfield_data;
|
||||
|
|
|
@ -225,7 +225,37 @@ $(document).ready(function() {
|
|||
[% ELSE %]
|
||||
<label>[% ite.subfield %] - [% ite.marc_lib %]</label>
|
||||
[% END %]
|
||||
[% ite.marc_value %]
|
||||
|
||||
[% 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
|
||||
[% ELSIF ( mv.type == 'select' ) %]
|
||||
<select name="[%- mv.name -%]" id="[%- mv.id -%]" size="1" class="input_marceditor" [% mv.readonly %] [% mv.disabled %]>
|
||||
[% FOREACH aval IN mv.values %]
|
||||
[% IF aval == mv.default %]
|
||||
<option value="[%- aval -%]" selected="selected">[%- mv.labels.$aval -%]</option>
|
||||
[% ELSE %]
|
||||
<option value="[%- aval -%]">[%- mv.labels.$aval -%]</option>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</select>
|
||||
[% ELSIF ( mv.type == 'text_auth' ) %]
|
||||
<input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
|
||||
[% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
|
||||
<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 -%]
|
||||
[% END %]
|
||||
[% 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' ) %]
|
||||
<textarea id="[%- mv.id -%]" name="field_value" class="input_marceditor" rows="5" cols="64" >[% mv.value %]</textarea>
|
||||
[% END %]
|
||||
|
||||
<input type="hidden" name="tag" value="[% ite.tag %]" />
|
||||
<input type="hidden" name="subfield" value="[% ite.subfield %]" />
|
||||
<input type="hidden" name="mandatory" value="[% ite.mandatory %]" />
|
||||
|
|
Loading…
Reference in a new issue