Bugzilla – Attachment 20975 Details for
Bug 10650
export merge-record.inc javascript into a file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 10650 - export merge-record.inc javascript into a file
PASSED-QA-Bug-10650---export-merge-recordinc-javas.patch (text/plain), 13.39 KB, created by
Katrin Fischer
on 2013-09-10 20:50:40 UTC
(
hide
)
Description:
[PASSED QA] Bug 10650 - export merge-record.inc javascript into a file
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2013-09-10 20:50:40 UTC
Size:
13.39 KB
patch
obsolete
>From adee8b602d59e18efeeabb2dd9b9fd7fa170efff Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Fri, 26 Jul 2013 15:54:45 +0200 >Subject: [PATCH] [PASSED QA] Bug 10650 - export merge-record.inc javascript > into a file > >Bug 9755 added a refactoring of records merge adding the include >merge-record.inc. This include contains a block "mergejs" containing all >JavaScript code that was in merge.tt. >This patch exports this code into a js file. >Translatable strings contained in this file are in >merge-record-strings.inc. > >Test plan : >- Put two records is a list >- Go to this list and check the two records >- Click on "Merge selected" >- Click on next >- Go to second source record >- Click on a repeatable field >=> The field is added to destination record >- Click on a subfield of a field existing in destination record >=> The subfield is added to destination record >- Click on a non repeatable field existing in destination record >=> You get an alert and field is not added >- Click on a subfield of a field not existing in destination record >=> You get an alert and subfield is not added >- Click on Merge >=> Records are merged > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Passes tests and test plan, no regressions found. >--- > .../prog/en/includes/merge-record-strings.inc | 6 + > .../prog/en/includes/merge-record.inc | 136 ------------------- > koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js | 139 ++++++++++++++++++++ > .../prog/en/modules/cataloguing/merge.tt | 7 +- > 4 files changed, 151 insertions(+), 137 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc >new file mode 100644 >index 0000000..822d4b5 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record-strings.inc >@@ -0,0 +1,6 @@ >+[%# transletable strings for merge-record.js %] >+<script type="text/javascript"> >+ var MSG_MERGEREC_ALREADY_EXISTS = _("The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it."); >+ var MSG_MERGEREC_SUBFIELD_PRE = _("This subfield cannot be added: there is no"); >+ var MSG_MERGEREC_SUBFIELD_POST = _("field in the destination record."); >+</script> >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >index 6644b2d..81a7cc8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >@@ -45,142 +45,6 @@ > [% END %] > </div><!-- /div#tabrecord[% recordnumber %] --> > [% END %] >-[% BLOCK mergejs %] >- // Creating tabs >- $("#tabs").tabs(); >- >- // Toggle a field / subfield >- function toggleField(pField) { >- >- // Getting the key of the clicked checkbox >- var ckid = $(pField).attr("id"); >- var tab = ckid.split('_'); >- var source = tab[1]; // From which record the click came from >- var key = tab[2]; >- var type = $(pField).attr("class"); >- >- // Getting field/subfield >- var field; >- var subfield; >- if (type == "subfieldpick") { >- >- field = $(pField).parent().parent().parent().find("span.field").text(); >- subfield = $(pField).parent().find("span.subfield").text(); >- } else { >- >- field = $(pField).parent().find("span.field").text(); >- } >- >- // If the field has just been checked >- if (pField.checked) { >- >- // We check for repeatability >- var canbeadded = true; >- if (type == "subfieldpick") { >- var repeatable = 1; >- var alreadyexists = 0; >- if (tagslib[field] && tagslib[field][subfield]) { >- repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number >- // TODO : Checking for subfields >- } >- } else { >- if (tagslib[field]) { >- repeatable = tagslib[field].repeatable; >- alreadyexists = $("#resultul span.field:contains(" + field + ")"); >- if (repeatable == 0 && alreadyexists.length != 0) { >- canbeadded = false; >- } >- } >- } >- // If the field is not repeatable, we check if it already exists in the result table >- if (canbeadded == false) { >- alert(_("The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.")); >- pField.checked = 0; >- } else { >- >- // Cloning the field or subfield we picked >- var clone = $(pField).parent().clone(); >- >- // Removing the checkboxes from it >- $(clone).find("input.subfieldpick, input.fieldpick").each(function() { >- $(this).remove(); >- }); >- >- >- // If we are a subfield >- if (type == "subfieldpick") { >- // then we need to find who is our parent field... >- fieldkey = $(pField).parent().parent().parent().attr("id"); >- >- // Find where to add the subfield >- >- // First, check if the field is not already in the destination record >- if ($("#resultul li#" + fieldkey).length > 0) { >- // If so, we add our field to it >- $("#resultul li#" + fieldkey + " ul").append(clone); >- } else { >- // If not, we add the subfield to the first matching field >- var where = 0; >- $("#resultul li span.field").each(function() { >- if (where == 0 && $(this).text() == field) { >- where = this; >- } >- }); >- >- // If there is no matching field in the destination record >- if (where == 0) { >- >- // TODO: >- // We select the whole field and removing non-selected subfields, instead of... >- >- // Alerting the user >- alert(_("This subfield cannot be added: there is no") + " " + field + " " + _("field in the destination record.")); >- pField.checked = false; >- >- } else { >- $(where).nextAll("ul").append(clone); >- } >- >- } >- >- >- >- } else { >- // If we are a field >- var where = 0; >- // Find where to add the field >- $("#resultul li span.field").each(function() { >- if (where == 0 && $(this).text() > field) { >- where = this; >- } >- }); >- >- $(where).parent().before(clone); >- } >- } >- } else { >- >- // Else, we remove it from the results tab >- $("ul#resultul li#k" + key).remove(); >- } >-} >- >- >- // When a field is checked / unchecked >- $('input.fieldpick').click(function() { >- toggleField(this); >- // (un)check all subfields >- var ischecked = this.checked; >- $(this).parent().find("input.subfieldpick").each(function() { >- this.checked = ischecked; >- }); >- }); >- >- // When a field or subfield is checked / unchecked >- $("input.subfieldpick").click(function() { >- toggleField(this); >- }); >-[% END %] > [% BLOCK mergesource %] > <div id="tabs" class="toptabs"> > <h2>Source records</h2> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js b/koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js >new file mode 100644 >index 0000000..3686a0e >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/merge-record.js >@@ -0,0 +1,139 @@ >+/* >+ * Merging 2 source records into a destination record >+ */ >+ >+/** >+ * Check or uncheck a field or subfield in a source record >+ * @param pField the checkbox clicked >+ */ >+function toggleField(pField) { >+ >+ // Getting the key of the clicked checkbox >+ var ckid = $(pField).attr("id"); >+ var tab = ckid.split('_'); >+ var source = tab[1]; // From which record the click came from >+ var key = tab[2]; >+ var type = $(pField).attr("class"); >+ >+ // Getting field/subfield >+ var field; >+ var subfield; >+ if (type == "subfieldpick") { >+ field = $(pField).parent().parent().parent().find("span.field").text(); >+ subfield = $(pField).parent().find("span.subfield").text(); >+ } else { >+ field = $(pField).parent().find("span.field").text(); >+ } >+ >+ // If the field has just been checked >+ if (pField.checked) { >+ >+ // We check for repeatability >+ var canbeadded = true; >+ if (type == "subfieldpick") { >+ var repeatable = 1; >+ var alreadyexists = 0; >+ if (tagslib[field] && tagslib[field][subfield]) { >+ // Note : we can't use the dot notation here (tagslib.021) because the key is a number >+ repeatable = tagslib[field][subfield].repeatable; >+ // TODO : Checking for subfields >+ } >+ } else { >+ if (tagslib[field]) { >+ repeatable = tagslib[field].repeatable; >+ alreadyexists = $("#resultul span.field:contains(" + field + ")"); >+ if (repeatable == 0 && alreadyexists.length != 0) { >+ canbeadded = false; >+ } >+ } >+ } >+ >+ // If the field is not repeatable, we check if it already exists in the result table >+ if (canbeadded == false) { >+ alert(MSG_MERGEREC_ALREADY_EXISTS); >+ pField.checked = 0; >+ } else { >+ >+ // Cloning the field or subfield we picked >+ var clone = $(pField).parent().clone(); >+ >+ // Removing the checkboxes from it >+ $(clone).find("input.subfieldpick, input.fieldpick").each(function() { >+ $(this).remove(); >+ }); >+ >+ // If we are a subfield >+ if (type == "subfieldpick") { >+ // then we need to find who is our parent field... >+ fieldkey = $(pField).parent().parent().parent().attr("id"); >+ >+ // Find where to add the subfield >+ >+ // First, check if the field is not already in the destination record >+ if ($("#resultul li#" + fieldkey).length > 0) { >+ >+ // If so, we add our field to it >+ $("#resultul li#" + fieldkey + " ul").append(clone); >+ } else { >+ >+ // If not, we add the subfield to the first matching field >+ var where = 0; >+ $("#resultul li span.field").each(function() { >+ if (where == 0 && $(this).text() == field) { >+ where = this; >+ } >+ }); >+ >+ // If there is no matching field in the destination record >+ if (where == 0) { >+ >+ // TODO: >+ // We select the whole field and removing non-selected subfields, instead of... >+ >+ // Alerting the user >+ alert(MSG_MERGEREC_SUBFIELD_PRE + " " + field + " " + MSG_MERGEREC_SUBFIELD_POST); >+ pField.checked = false; >+ } else { >+ $(where).nextAll("ul").append(clone); >+ } >+ >+ } >+ >+ } else { >+ // If we are a field >+ var where = 0; >+ // Find where to add the field >+ $("#resultul li span.field").each(function() { >+ if (where == 0 && $(this).text() > field) { >+ where = this; >+ } >+ }); >+ >+ $(where).parent().before(clone); >+ } >+ } >+ } else { >+ // Else, we remove it from the results tab >+ $("ul#resultul li#k" + key).remove(); >+ } >+} >+ >+/* >+ * Add actions on field and subfields checkboxes >+ */ >+$(document).ready(function(){ >+ // When a field is checked / unchecked >+ $('input.fieldpick').click(function() { >+ toggleField(this); >+ // (un)check all subfields >+ var ischecked = this.checked; >+ $(this).parent().find("input.subfieldpick").each(function() { >+ this.checked = ischecked; >+ }); >+ }); >+ >+ // When a field or subfield is checked / unchecked >+ $("input.subfieldpick").click(function() { >+ toggleField(this); >+ }); >+}); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >index 4453b98..5ef6c99 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >@@ -1,8 +1,11 @@ > [% PROCESS 'merge-record.inc' %] >+ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Cataloging › Merging records</title> > [% INCLUDE 'greybox.inc' %] > [% INCLUDE 'doc-head-close.inc' %] >+<script type="text/javascript" src="[% themelang %]/js/merge-record.js"></script> >+[% INCLUDE 'merge-record-strings.inc' %] > <style type="text/css"> > div.record ul, div.record li { float:none; display:block; } > div#result { margin-top: 1em; } >@@ -23,7 +26,9 @@ $(document).ready(function(){ > $.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) { > tagslib = json; > }); >- [% PROCESS mergejs %] >+ >+ // Creating tabs >+ $("#tabs").tabs(); > }); > > >-- >1.7.9.5
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 10650
:
19962
|
20914
| 20975