Bugzilla – Attachment 39196 Details for
Bug 13437
Convert marc21 framework plugins to new style
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13437: Replace javascript function parameter in builder
Bug-13437-Replace-javascript-function-parameter-in.patch (text/plain), 18.07 KB, created by
Marcel de Rooy
on 2015-05-14 17:38:28 UTC
(
hide
)
Description:
Bug 13437: Replace javascript function parameter in builder
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-05-14 17:38:28 UTC
Size:
18.07 KB
patch
obsolete
>From 8402eb0fd5ea5aa6aa5eab4e87b87f7d3ea1cd78 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 14 May 2015 15:09:40 +0200 >Subject: [PATCH] Bug 13437: Replace javascript function parameter in builder >Content-Type: text/plain; charset=utf-8 > >The builder contains js functions with a parameter like subfield_managed >or i or something similar. This parameter contains the html id of the >field corresponding with the plugin. >With the functionality of Koha::FrameworkPlugin in place, we can eliminate >one js function call and get the same id via the event passed in. Note >that this actually makes the function a 'real' event handler. > >Also note that in many cases this parameter was not used but the id >was borrowed from a perl variable like $params->{id}. If the field is not >cloned, this is not a problem. But some fields can be cloned and should >not use the static perl value but should get it from the event. > >Test plan: >Look for js errors when loading the marc editor. >Since the Focus or Click event code has been touched for most marc21 >plugins, move your cursor into the field or click on the tag editor >button. Verify that the focus event updates the correct field or the >click event correctly launches the plugin AND the value comes back into >the right field. >Bonus: Attach a plugin with popup (like leader) to 040$d. Clone this field. >Verify that the two launch buttons operate on the correct value. >(This resolves a current bug.) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Checked all 15 plugins. >Plugin marc21_linking_section seems to work, but I could not get it to pass >back something useful into my field. (Same without this patch.) >Tested the clone button with leader on 040d. >--- > cataloguing/value_builder/marc21_field_003.pl | 4 ++-- > cataloguing/value_builder/marc21_field_005.pl | 4 ++-- > cataloguing/value_builder/marc21_field_006.pl | 6 +++--- > cataloguing/value_builder/marc21_field_007.pl | 6 +++--- > cataloguing/value_builder/marc21_field_008.pl | 12 ++++++------ > cataloguing/value_builder/marc21_field_008_authorities.pl | 12 ++++++------ > cataloguing/value_builder/marc21_field_040c.pl | 4 ++-- > cataloguing/value_builder/marc21_field_040d.pl | 4 ++-- > cataloguing/value_builder/marc21_field_245h.pl | 6 +++--- > cataloguing/value_builder/marc21_leader.pl | 12 ++++++------ > cataloguing/value_builder/marc21_leader_authorities.pl | 12 ++++++------ > cataloguing/value_builder/marc21_leader_book.pl | 6 +++--- > cataloguing/value_builder/marc21_leader_computerfile.pl | 6 +++--- > cataloguing/value_builder/marc21_leader_video.pl | 6 +++--- > cataloguing/value_builder/marc21_linking_section.pl | 6 +++--- > 15 files changed, 53 insertions(+), 53 deletions(-) > >diff --git a/cataloguing/value_builder/marc21_field_003.pl b/cataloguing/value_builder/marc21_field_003.pl >index 9844863..189a00a 100755 >--- a/cataloguing/value_builder/marc21_field_003.pl >+++ b/cataloguing/value_builder/marc21_field_003.pl >@@ -32,8 +32,8 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- document.getElementById(\"$params->{id}\").value='$org'; >+function Focus$function_name(event) { >+ document.getElementById(event.data.id).value='$org'; > return 0; > } > >diff --git a/cataloguing/value_builder/marc21_field_005.pl b/cataloguing/value_builder/marc21_field_005.pl >index 4771bbd..4bf4c21 100755 >--- a/cataloguing/value_builder/marc21_field_005.pl >+++ b/cataloguing/value_builder/marc21_field_005.pl >@@ -33,8 +33,8 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- document.getElementById(\"$params->{id}\").value='$date'; >+function Focus$function_name(event) { >+ document.getElementById(event.data.id).value='$date'; > return 0; > } > >diff --git a/cataloguing/value_builder/marc21_field_006.pl b/cataloguing/value_builder/marc21_field_006.pl >index 1a01cf0..a773d9c 100755 >--- a/cataloguing/value_builder/marc21_field_006.pl >+++ b/cataloguing/value_builder/marc21_field_006.pl >@@ -36,9 +36,9 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_006.pl&index=$params->{id}&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_006.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_field_007.pl b/cataloguing/value_builder/marc21_field_007.pl >index d8bf1ea..d7b9789 100755 >--- a/cataloguing/value_builder/marc21_field_007.pl >+++ b/cataloguing/value_builder/marc21_field_007.pl >@@ -35,9 +35,9 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_007.pl&index=$params->{id}&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_007.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_field_008.pl b/cataloguing/value_builder/marc21_field_008.pl >index e93e522..e47a20d 100755 >--- a/cataloguing/value_builder/marc21_field_008.pl >+++ b/cataloguing/value_builder/marc21_field_008.pl >@@ -43,17 +43,17 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- if ( document.getElementById(\"$params->{id}\").value ) { >+function Focus$function_name(event) { >+ if ( document.getElementById(event.data.id).value ) { > } > else { >- document.getElementById(\"$params->{id}\").value='$dateentered' + 'b xxu||||| |||| 00| 0 $lang d'; >+ document.getElementById(event.data.id).value='$dateentered' + 'b xxu||||| |||| 00| 0 $lang d'; > } > return 1; > } > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; > //Retrieve full leader string and pass it to the 008 tag editor > var leader_value = \$(\"input[id^='tag_000']\").val(); > var leader_parameter = \"\"; >@@ -61,7 +61,7 @@ function Click$function_name(i) { > //Only add the parameter to the URL if there is a value to add > leader_parameter = \"&leader=\"+leader_value; > } >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008.pl&index=$params->{id}&result=\"+defaultvalue+leader_parameter,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue+leader_parameter,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_field_008_authorities.pl b/cataloguing/value_builder/marc21_field_008_authorities.pl >index 5489a43..fe109a2 100755 >--- a/cataloguing/value_builder/marc21_field_008_authorities.pl >+++ b/cataloguing/value_builder/marc21_field_008_authorities.pl >@@ -40,22 +40,22 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- if (!document.getElementById(\"$params->{id}\").value) { >+function Focus$function_name(event) { >+ if (!document.getElementById(event.data.id).value) { > var authtype=document.forms['f'].elements['authtypecode'].value; > var fieldval='$dateentered$defaultval'; > if(authtype && (authtype == 'TOPIC_TERM' || authtype == 'GENRE/FORM' || authtype == 'CHRON_TERM')) { > fieldval= fieldval.substr(0,14)+'b'+fieldval.substr(15); > } >- document.getElementById(\"$params->{id}\").value=fieldval; >+ document.getElementById(event.data.id).value=fieldval; > } > return 1; > } > >-function Click$function_name(i) { >+function Click$function_name(event) { > var authtype=document.forms['f'].elements['authtypecode'].value; >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=$params->{id}&result=\"+defaultvalue+\"&authtypecode=\"+authtype,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue+\"&authtypecode=\"+authtype,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_field_040c.pl b/cataloguing/value_builder/marc21_field_040c.pl >index 0ad692b..4409b1b 100755 >--- a/cataloguing/value_builder/marc21_field_040c.pl >+++ b/cataloguing/value_builder/marc21_field_040c.pl >@@ -31,8 +31,8 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- document.getElementById(\"$params->{id}\").value='$org'; >+function Focus$function_name(event) { >+ document.getElementById(event.data.id).value='$org'; > return 0; > } > >diff --git a/cataloguing/value_builder/marc21_field_040d.pl b/cataloguing/value_builder/marc21_field_040d.pl >index 0ad692b..4409b1b 100755 >--- a/cataloguing/value_builder/marc21_field_040d.pl >+++ b/cataloguing/value_builder/marc21_field_040d.pl >@@ -31,8 +31,8 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- document.getElementById(\"$params->{id}\").value='$org'; >+function Focus$function_name(event) { >+ document.getElementById(event.data.id).value='$org'; > return 0; > } > >diff --git a/cataloguing/value_builder/marc21_field_245h.pl b/cataloguing/value_builder/marc21_field_245h.pl >index 9317497..0680410 100755 >--- a/cataloguing/value_builder/marc21_field_245h.pl >+++ b/cataloguing/value_builder/marc21_field_245h.pl >@@ -30,13 +30,13 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Blur$function_name(index) { >- var fieldValue = document.getElementById(\"$params->{id}\").value; >+function Blur$function_name(event) { >+ var fieldValue = document.getElementById(event.data.id).value; > if ( fieldValue.substring(0,1) != '[' > && > fieldValue.substring(fieldValue.length-1) != '[' > ) { >- document.getElementById(\"$params->{id}\").value = '[' + fieldValue + ']'; >+ document.getElementById(event.data.id).value = '[' + fieldValue + ']'; > } > return 0; > } >diff --git a/cataloguing/value_builder/marc21_leader.pl b/cataloguing/value_builder/marc21_leader.pl >index 28f7dce..4366c62 100755 >--- a/cataloguing/value_builder/marc21_leader.pl >+++ b/cataloguing/value_builder/marc21_leader.pl >@@ -35,16 +35,16 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- if(!document.getElementById(\"$params->{id}\").value){ >- document.getElementById(\"$params->{id}\").value = ' nam a22 7a 4500'; >+function Focus$function_name(event) { >+ if(!document.getElementById(event.data.id).value){ >+ document.getElementById(event.data.id).value = ' nam a22 7a 4500'; > } > return 1; > } > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=$params->{id}&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_leader_authorities.pl b/cataloguing/value_builder/marc21_leader_authorities.pl >index 527b12f..1b7aa7e 100755 >--- a/cataloguing/value_builder/marc21_leader_authorities.pl >+++ b/cataloguing/value_builder/marc21_leader_authorities.pl >@@ -35,16 +35,16 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Focus$function_name(subfield_managed) { >- if(!document.getElementById(\"$params->{id}\").value){ >- document.getElementById(\"$params->{id}\").value = ' nz a22 n 4500'; >+function Focus$function_name(event) { >+ if(!document.getElementById(event.data.id).value){ >+ document.getElementById(event.data.id).value = ' nz a22 n 4500'; > } > return 1; > } > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader_authorities.pl&index=$params->{id}&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader_authorities.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_leader_book.pl b/cataloguing/value_builder/marc21_leader_book.pl >index 646b32d..0707347 100755 >--- a/cataloguing/value_builder/marc21_leader_book.pl >+++ b/cataloguing/value_builder/marc21_leader_book.pl >@@ -35,9 +35,9 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=$params->{id}&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_leader_computerfile.pl b/cataloguing/value_builder/marc21_leader_computerfile.pl >index d47cf36..d3374db 100755 >--- a/cataloguing/value_builder/marc21_leader_computerfile.pl >+++ b/cataloguing/value_builder/marc21_leader_computerfile.pl >@@ -35,9 +35,9 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=$params->{id}&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_leader_video.pl b/cataloguing/value_builder/marc21_leader_video.pl >index a52a0c6..9f318a0 100755 >--- a/cataloguing/value_builder/marc21_leader_video.pl >+++ b/cataloguing/value_builder/marc21_leader_video.pl >@@ -35,9 +35,9 @@ my $builder = sub { > <script type=\"text/javascript\"> > //<![CDATA[ > >-function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=\"+i+\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); >+function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes'); > > } > //]]> >diff --git a/cataloguing/value_builder/marc21_linking_section.pl b/cataloguing/value_builder/marc21_linking_section.pl >index 54909ba..195dedb 100644 >--- a/cataloguing/value_builder/marc21_linking_section.pl >+++ b/cataloguing/value_builder/marc21_linking_section.pl >@@ -39,9 +39,9 @@ my $builder = sub { > my $function_name = $params->{id}; > my $res = " > <script type='text/javascript'> >- function Click$function_name(i) { >- defaultvalue=document.getElementById(\"$params->{id}\").value; >- window.open(\"/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=marc21_linking_section.pl&index=\" + i + \"&result=\"+defaultvalue,\"marc21_field_7\"+i+\"\",'width=900,height=700,toolbar=false,scrollbars=yes'); >+ function Click$function_name(event) { >+ defaultvalue=document.getElementById(event.data.id).value; >+ window.open(\"/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=marc21_linking_section.pl&index=\" + event.data.id + \"&result=\"+defaultvalue,\"marc21_field_7\"+ event.data.id +\"\",'width=900,height=700,toolbar=false,scrollbars=yes'); > > } > </script> >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13437
:
39093
|
39095
|
39140
|
39141
|
39142
|
39177
|
39184
|
39193
|
39194
|
39195
|
39196
|
39371
|
39372
|
39373
|
39374
|
39375
|
39949
|
39950
|
39951
|
39952
|
39953