Bug 30507: Value builder for field 183

This patch provides values builders for the subfields $a and $2. Those are unimarc official codes who help to
identify the kind of items
Test plan:
1)Go to Home > Cataloging > New record
2)Section 1 - field 183 : it contains subfields $a & $2
3)Inputs are writable but notice that no plugins are suggested
4)Apply patch and repeat 1) to 3)
5)Values builders plugins are available for $a and $2

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
jeremy breuillard 2022-03-04 14:16:33 +01:00 committed by Tomas Cohen Arazi
parent 94423e6d63
commit 9b2bf04e09
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
4 changed files with 595 additions and 0 deletions

View File

@ -0,0 +1,64 @@
#!/usr/bin/perl
# Copyright 2014 Rijksmuseum
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Date::Calc;
use Koha::Util::FrameworkPlugin qw(wrapper);
use C4::Auth qw( get_template_and_user );
use CGI qw ( -utf8 );
use C4::Context;
use C4::Output qw( output_html_with_http_headers );
my $builder= sub {
my $params = shift;
my $id = $params->{id};
return qq|
<script>
function Click$id(event) {
var fieldvalue=\$('#'+event.data.id).val();
window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_183-2.pl&index=\"+event.data.id+\"&result=\"+fieldvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes');
return false; /* prevents scrolling */
}
</script>|;
};
my $launcher= sub {
my $params = shift;
my $cgi = $params->{cgi};
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
template_name => "cataloguing/value_builder/unimarc_field_183-2.tt",
query => $cgi,
type => "intranet",
flagsrequired => {editcatalogue => '*'},
});
$template->param(
index => scalar $cgi->param('index'),
result => scalar $cgi->param('result'),
);
output_html_with_http_headers $cgi, $cookie, $template->output;
};
# Return the hashref with the builder and launcher to FrameworkPlugin object.
# NOTE: If you do not need a popup but only use e.g. Focus, Blur etc. for a
# particular plugin, you only need to define and return the builder.
return { builder => $builder, launcher => $launcher };

View File

@ -0,0 +1,67 @@
#!/usr/bin/perl
# Copyright 2014 Rijksmuseum
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Date::Calc;
use Koha::Util::FrameworkPlugin qw(wrapper);
use C4::Auth qw( get_template_and_user );
use CGI qw ( -utf8 );
use C4::Context;
use C4::Output qw( output_html_with_http_headers );
my $builder= sub {
my $params = shift;
my $id = $params->{id};
return qq|
<script>
function Click$id(event) {
var fieldvalue=\$('#'+event.data.id).val();
window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_183a.pl&index=\"+event.data.id+\"&result=\"+fieldvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes');
return false; /* prevents scrolling */
}
</script>|;
};
my $launcher= sub {
my $params = shift;
my $cgi = $params->{cgi};
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
template_name => "cataloguing/value_builder/unimarc_field_183a.tt",
query => $cgi,
type => "intranet",
flagsrequired => {editcatalogue => '*'},
});
my $results = scalar $cgi->param('result');
$template->param(
index => scalar $cgi->param('index'),
result => $results,
);
output_html_with_http_headers $cgi, $cookie, $template->output;
};
# Return the hashref with the builder and launcher to FrameworkPlugin object.
# NOTE: If you do not need a popup but only use e.g. Focus, Blur etc. for a
# particular plugin, you only need to define and return the builder.
return { builder => $builder, launcher => $launcher };

View File

@ -0,0 +1,60 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Framework plugin example &rsaquo; Cataloguing &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="cat_unimarc_field_183-2" class="cat" style="padding:1em;">
<h3>UNIMARC field 183-2 builder</h3>
<form name="f_pop" action="">
<table>
<tr>
<td><label for="f0">System code :</label></td>
<td>
<select name="f0" id="f0">
[% IF ( f0 == "carr" ) %]
<option value="RDAcarrier" selected="selected">RDA Carrier</option>
[% ELSE %]
<option value="RDAcarrier">RDA Carrier</option>
[% END %]
[% IF ( f0 == "cont" ) %]
<option value="RDAcontent" selected="selected">RDA Content</option>
[% ELSE %]
<option value="RDAcontent">RDA Content</option>
[% END %]
[% IF ( f0 == "media" ) %]
<option value="RDAmedia" selected="selected">RDA Media</option>
[% ELSE %]
<option value="RDAmedia">RDA Media</option>
[% END %]
[% IF ( f0 == "frcarr" ) %]
<option value="RDAfrCarrier" selected="selected">RDA fr Carrier</option>
[% ELSE %]
<option value="RDAfrCarrier">RDA fr Carrier</option>
[% END %]
</select>
</td>
</tr>
</table>
<p><input type="button" value="OK" onclick="submitMyForm();" /> <a href="#" class="cancel close">Cancel</a> </p>
</form>
<script>
// The following function just puts back the value of the input #return
// into the caller's field, referenced by index. And closes the popup.
function submitMyForm() {
var doc = opener.document;
var field = doc.getElementById("[% index | html %]");
field.value = document.f_pop.f0.value;
window.close();
return false;
}
</script>
[% INCLUDE 'popup-bottom.inc' %]

View File

@ -0,0 +1,404 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Framework plugin example &rsaquo; Cataloguing &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="cat_unimarc_field_183a" class="cat" style="padding:1em;">
<h3>UNIMARC field 183a builder</h3>
<form name="f_pop" action="">
<table>
<tr>
<td>
<select name="f1" id="f1">
<optgroup label="Audio Carriers">
[% IF ( f1 == "sg" ) %]
<option value="sg" selected="selected">sg - audio cartridge</option>
[% ELSE %]
<option value="sg">sg - audio cartridge</option>
[% END %]
[% IF ( f1 == "sb" ) %]
<option value="sb" selected="selected">sb - audio belt</option>
[% ELSE %]
<option value="sb">sb - audio belt</option>
[% END %]
[% IF ( f1 == "se" ) %]
<option value="se" selected="selected">se - audio cylinder</option>
[% ELSE %]
<option value="se">se - audio cylinder</option>
[% END %]
[% IF ( f1 == "sd" ) %]
<option value="sd" selected="selected">sd - audio disc</option>
[% ELSE %]
<option value="sd">sd - audio disc</option>
[% END %]
[% IF ( f1 == "si" ) %]
<option value="si" selected="selected">si - sound track reel</option>
[% ELSE %]
<option value="si">si - sound track reel</option>
[% END %]
[% IF ( f1 == "sq" ) %]
<option value="sq" selected="selected">sq - audio roll</option>
[% ELSE %]
<option value="sq">sq - audio roll</option>
[% END %]
[% IF ( f1 == "sw" ) %]
<option value="sw" selected="selected">sw - audio wire reel</option>
[% ELSE %]
<option value="sw">sw - audio wire reel</option>
[% END %]
[% IF ( f1 == "ss" ) %]
<option value="ss" selected="selected">ss - audiocassette</option>
[% ELSE %]
<option value="ss">ss - audiocassette</option>
[% END %]
[% IF ( f1 == "st" ) %]
<option value="st" selected="selected">st - audiotape reel</option>
[% ELSE %]
<option value="st">st - audiotape reel</option>
[% END %]
[% IF ( f1 == "sz" ) %]
<option value="sz" disabled="disabled" selected="selected">sz - other audio carrier</option>
[% ELSE %]
<option value="sz" >sz - other audio carrier</option>
[% END %]
</optgroup>
<optgroup label="Computer Carriers">
[% IF ( f1 == "ck" ) %]
<option value="ck" selected="selected">ck - computer card</option>
[% ELSE %]
<option value="ck">ck - computer card</option>
[% END %]
[% IF ( f1 == "cb" ) %]
<option value="cb" selected="selected">cb - computer chip cartridge</option>
[% ELSE %]
<option value="cb">cb - computer chip cartridge</option>
[% END %]
[% IF ( f1 == "cd" ) %]
<option value="cd" selected="selected">cd - computer disc</option>
[% ELSE %]
<option value="cd">cd - computer disc</option>
[% END %]
[% IF ( f1 == "ce" ) %]
<option value="ce" selected="selected">ce - computer disc cartridge</option>
[% ELSE %]
<option value="ce">ce - computer disc cartridge</option>
[% END %]
[% IF ( f1 == "ca" ) %]
<option value="ca" selected="selected">ca - computer tape cartridge</option>
[% ELSE %]
<option value="ca">ca - computer tape cartridge</option>
[% END %]
[% IF ( f1 == "cf" ) %]
<option value="cf" selected="selected">cf - computer tape cassette</option>
[% ELSE %]
<option value="cf">cf - computer tape cassette</option>
[% END %]
[% IF ( f1 == "ch" ) %]
<option value="ch" selected="selected">ch - computer tape reel</option>
[% ELSE %]
<option value="ch">ch - computer tape reel</option>
[% END %]
[% IF ( f1 == "cr" ) %]
<option value="cr" selected="selected">cr - online resource</option>
[% ELSE %]
<option value="cr">cr - online resource</option>
[% END %]
[% IF ( f1 == "cz" ) %]
<option value="cz" selected="selected">cz - other computer carrier</option>
[% ELSE %]
<option value="cz">cz - other computer carrier</option>
[% END %]
</optgroup>
<optgroup label="Microform Carriers">
[% IF ( f1 == "ha" ) %]
<option value="ha" selected="selected">ha - aperture card</option>
[% ELSE %]
<option value="ha">ha - aperture card</option>
[% END %]
[% IF ( f1 == "he" ) %]
<option value="he" selected="selected">he - microfiche</option>
[% ELSE %]
<option value="he">he - microfiche</option>
[% END %]
[% IF ( f1 == "hf" ) %]
<option value="hf" selected="selected">hf - microfiche cassette</option>
[% ELSE %]
<option value="hf">hf - microfiche cassette</option>
[% END %]
[% IF ( f1 == "hb" ) %]
<option value="hb" selected="selected">hb - microfilm cartridge</option>
[% ELSE %]
<option value="hb">hb - microfilm cartridge</option>
[% END %]
[% IF ( f1 == "hc" ) %]
<option value="hc" selected="selected">hc - microfilm cassette</option>
[% ELSE %]
<option value="hc">hc - microfilm cassette</option>
[% END %]
[% IF ( f1 == "hd" ) %]
<option value="hd" selected="selected">hd - microfilm reel</option>
[% ELSE %]
<option value="hd">hd - microfilm reel</option>
[% END %]
[% IF ( f1 == "hj" ) %]
<option value="hj" selected="selected">hj - microfilm roll</option>
[% ELSE %]
<option value="hj">hj - microfilm roll</option>
[% END %]
[% IF ( f1 == "hh" ) %]
<option value="hh" selected="selected">hh - microfilm slip</option>
[% ELSE %]
<option value="hh">hh - microfilm slip</option>
[% END %]
[% IF ( f1 == "hg" ) %]
<option value="hg" selected="selected">hg - microopaque</option>
[% ELSE %]
<option value="hg">hg - microopaque</option>
[% END %]
[% IF ( f1 == "hz" ) %]
<option value="hz" selected="selected">hz - other microform carrier</option>
[% ELSE %]
<option value="hz">hz - other microform carrier</option>
[% END %]
</optgroup>
<optgroup label="Microscopic Carriers">
[% IF ( f1 == "pp" ) %]
<option value="pp" selected="selected">pp - microscope slide</option>
[% ELSE %]
<option value="pp">pp - microscope slide</option>
[% END %]
[% IF ( f1 == "pz" ) %]
<option value="pz" selected="selected">pz - other microscopic carrier</option>
[% ELSE %]
<option value="pz">pz - other microscopic carrier</option>
[% END %]
</optgroup>
<optgroup label="Projected image carriers">
[% IF ( f1 == "mc" ) %]
<option value="mc" selected="selected">mc - film cartridge</option>
[% ELSE %]
<option value="mc">mc - film cartridge</option>
[% END %]
[% IF ( f1 == "mf" ) %]
<option value="mf" selected="selected">mf - film cassette</option>
[% ELSE %]
<option value="mf">mf - film cassette</option>
[% END %]
[% IF ( f1 == "mr" ) %]
<option value="mr" selected="selected">mr - film reel</option>
[% ELSE %]
<option value="mr">mr - film reel</option>
[% END %]
[% IF ( f1 == "mo" ) %]
<option value="mo" selected="selected">mo - film roll</option>
[% ELSE %]
<option value="mo">mo - film roll</option>
[% END %]
[% IF ( f1 == "gd" ) %]
<option value="gd" selected="selected">gd - filmslip</option>
[% ELSE %]
<option value="gd">gd - filmslip</option>
[% END %]
[% IF ( f1 == "gf" ) %]
<option value="gf" selected="selected">gf - filmstrip</option>
[% ELSE %]
<option value="gf">gf - filmstrip</option>
[% END %]
[% IF ( f1 == "gc" ) %]
<option value="gc" selected="selected">gc - filmstrip cartridge</option>
[% ELSE %]
<option value="gc">gc - filmstrip cartridge</option>
[% END %]
[% IF ( f1 == "gt" ) %]
<option value="gt" selected="selected">gt - overhead transparency</option>
[% ELSE %]
<option value="gt">gt - overhead transparency</option>
[% END %]
[% IF ( f1 == "gs" ) %]
<option value="gs" selected="selected">gs - slide</option>
[% ELSE %]
<option value="gs">gs - slide</option>
[% END %]
[% IF ( f1 == "mz" ) %]
<option value="mz" selected="selected">mz - other projected image carrier</option>
[% ELSE %]
<option value="mz">mz - other projected image carrier</option>
[% END %]
</optgroup>
<optgroup label="Stereographic Carriers">
[% IF ( f1 == "eh" ) %]
<option value="eh" selected="selected">eh - stereograph card</option>
[% ELSE %]
<option value="eh">eh - stereograph card</option>
[% END %]
[% IF ( f1 == "es" ) %]
<option value="es" selected="selected">es - stereograph disc</option>
[% ELSE %]
<option value="es">es - stereograph disc</option>
[% END %]
[% IF ( f1 == "ez" ) %]
<option value="ez" selected="selected">ez - other stereographic carrier</option>
[% ELSE %]
<option value="ez">ez - other stereographic carrier</option>
[% END %]
</optgroup>
<optgroup label="Unmediated carriers">
[% IF ( f1 == "no" ) %]
<option value="no" selected="selected">no - card</option>
[% ELSE %]
<option value="no">no - card</option>
[% END %]
[% IF ( f1 == "nn" ) %]
<option value="nn" selected="selected">nn - flipchart</option>
[% ELSE %]
<option value="nn">nn - flipchart</option>
[% END %]
[% IF ( f1 == "na" ) %]
<option value="na" selected="selected">na - roll</option>
[% ELSE %]
<option value="na">na - roll</option>
[% END %]
[% IF ( f1 == "nb" ) %]
<option value="nb" selected="selected">nb - sheet</option>
[% ELSE %]
<option value="nb">nb - sheet</option>
[% END %]
[% IF ( f1 == "nc" ) %]
<option value="nc" selected="selected">nc - volume</option>
[% ELSE %]
<option value="nc">nc - volume</option>
[% END %]
[% IF ( f1 == "nr" ) %]
<option value="nr" selected="selected">nr - object</option>
[% ELSE %]
<option value="nr">nr - object</option>
[% END %]
[% IF ( f1 == "nz" ) %]
<option value="nz" selected="selected">nz - other unmediated carrier</option>
[% ELSE %]
<option value="nz">nz - other unmediated carrier</option>
[% END %]
</optgroup>
<optgroup label="Video carriers">
[% IF ( f1 == "vc" ) %]
<option value="vc" selected="selected">vc - video cartridge</option>
[% ELSE %]
<option value="vc">vc - video cartridge</option>
[% END %]
[% IF ( f1 == "vf" ) %]
<option value="vf" selected="selected">vf - videocassette</option>
[% ELSE %]
<option value="vf">vf - videocassette</option>
[% END %]
[% IF ( f1 == "vd" ) %]
<option value="vd" selected="selected">vd - videodisc</option>
[% ELSE %]
<option value="vd">vd - videodisc</option>
[% END %]
[% IF ( f1 == "vr" ) %]
<option value="vr" selected="selected">vr - videotape reel</option>
[% ELSE %]
<option value="vr">vr - videotape reel</option>
[% END %]
[% IF ( f1 == "vz" ) %]
<option value="vz" selected="selected">vz - other video carrier</option>
[% ELSE %]
<option value="vz">vz - other video carrier</option>
[% END %]
</optgroup>
<optgroup label="Unspecified carriers">
[% IF ( f1 == "zu" ) %]
<option value="zu" selected="selected">zu - unspecified</option>
[% ELSE %]
<option value="zu">zu - unspecified</option>
[% END %]
</optgroup>
</select>
</td>
</tr>
</table>
<p><input type="button" value="OK" onclick="submitMyForm();" /> <a href="#" class="cancel close">Cancel</a> </p>
</form>
<script>
function submitMyForm() {
var doc = opener.document;
var field = doc.getElementById("[% index | html %]");
subfield();
function subfield() {
const tag = $(field).closest('.tag');
const sub = tag.find('[id*="tag_183_subfield_2_"]');
if ( field != 'undefined' ) {
sub[0].value = "RDAcarrier";
}
return subfield;
}
field.value = document.f_pop.f1.value;
window.close();
return false;
}
</script>
[% INCLUDE 'popup-bottom.inc' %]