2 <div id="tabrecord[% recordnumber %]">
6 <ul id="ulrecord[% recordnumber %]">
7 [% FOREACH record IN records %]
8 [% FOREACH fiel IN record.field %]
9 <li id="k[% fiel.key %]">
10 [% IF (defaultrecord) %]
11 <input type="checkbox" checked="checked" class="fieldpick" id="rec_[% recordnumber %]_[% fiel.key %]" />
13 <input type="checkbox" class="fieldpick" id="rec_[% recordnumber %]_[% fiel.key %]" />
15 <span class="field">[% fiel.tag %]</span>
17 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
18 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
19 [% IF ( fiel.value ) %] / [% fiel.value %]
20 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
21 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value %]" />
24 [% IF ( fiel.subfield ) %]
26 [% FOREACH subfiel IN fiel.subfield %]
27 <li id="k[% subfiel.subkey %]">
28 [% IF (defaultrecord) %]
29 <input type="checkbox" checked="checked" class="subfieldpick" id="rec_[% recordnumber %]_[% subfiel.subkey %]" />
31 <input type="checkbox" class="subfieldpick" id="rec_[% recordnumber %]_[% subfiel.subkey %]" />
33 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
34 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
35 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
44 </div><!-- /div.record -->
46 </div><!-- /div#tabrecord[% recordnumber %] -->
52 // Toggle a field / subfield
53 function toggleField(pField) {
55 // Getting the key of the clicked checkbox
56 var ckid = $(pField).attr("id");
57 var tab = ckid.split('_');
58 var source = tab[1]; // From which record the click came from
60 var type = $(pField).attr("class");
62 // Getting field/subfield
65 if (type == "subfieldpick") {
67 field = $(pField).parent().parent().parent().find("span.field").text();
68 subfield = $(pField).parent().find("span.subfield").text();
71 field = $(pField).parent().find("span.field").text();
74 // If the field has just been checked
77 // We check for repeatability
78 var canbeadded = true;
79 if (type == "subfieldpick") {
81 var alreadyexists = 0;
82 if (tagslib[field] && tagslib[field][subfield]) {
83 repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number
84 // TODO : Checking for subfields
88 repeatable = tagslib[field].repeatable;
89 alreadyexists = $("#resultul span.field:contains(" + field + ")");
90 if (repeatable == 0 && alreadyexists.length != 0) {
95 // If the field is not repeatable, we check if it already exists in the result table
96 if (canbeadded == false) {
97 alert(_("The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it."));
101 // Cloning the field or subfield we picked
102 var clone = $(pField).parent().clone();
104 // Removing the checkboxes from it
105 $(clone).find("input.subfieldpick, input.fieldpick").each(function() {
110 // If we are a subfield
111 if (type == "subfieldpick") {
112 // then we need to find who is our parent field...
113 fieldkey = $(pField).parent().parent().parent().attr("id");
115 // Find where to add the subfield
117 // First, check if the field is not already in the destination record
118 if ($("#resultul li#" + fieldkey).length > 0) {
119 // If so, we add our field to it
120 $("#resultul li#" + fieldkey + " ul").append(clone);
122 // If not, we add the subfield to the first matching field
124 $("#resultul li span.field").each(function() {
125 if (where == 0 && $(this).text() == field) {
130 // If there is no matching field in the destination record
134 // We select the whole field and removing non-selected subfields, instead of...
137 alert(_("This subfield cannot be added: there is no") + " " + field + " " + _("field in the destination record."));
138 pField.checked = false;
141 $(where).nextAll("ul").append(clone);
151 // Find where to add the field
152 $("#resultul li span.field").each(function() {
153 if (where == 0 && $(this).text() > field) {
158 $(where).parent().before(clone);
163 // Else, we remove it from the results tab
164 $("ul#resultul li#k" + key).remove();
169 // When a field is checked / unchecked
170 $('input.fieldpick').click(function() {
172 // (un)check all subfields
173 var ischecked = this.checked;
174 $(this).parent().find("input.subfieldpick").each(function() {
175 this.checked = ischecked;
179 // When a field or subfield is checked / unchecked
180 $("input.subfieldpick").click(function() {
184 [% BLOCK mergesource %]
185 <div id="tabs" class="toptabs">
186 <h2>Source records</h2>
188 <li><a href="#tabrecord1">[% recordid1 %]</a></li>
189 <li><a href="#tabrecord2">[% recordid2 %]</a></li>
191 [% PROCESS sourcetab records=record1 recordnumber=1 defaultrecord=1 %]
192 [% PROCESS sourcetab records=record2 recordnumber=2 defaultrecord=0 %]
193 </div> <!-- // #tabs -->
195 [% BLOCK mergetarget %]
197 <h2>Destination record</h2>
198 <div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
200 [% FOREACH record IN record1 %]
201 [% FOREACH fiel IN record.field %]<li id="k[% fiel.key %]">
202 <span class="field">[% fiel.tag %]</span>
203 <input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" />
204 <input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" />
205 [% IF ( fiel.value ) %] /
207 <input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" />
208 <input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" />
211 [% IF ( fiel.subfield ) %]
213 [% FOREACH subfiel IN fiel.subfield %]
214 <li id="k[% subfiel.subkey %]">
215 <span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %]
216 <input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" />
217 <input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" />
226 </div> <!-- // #result -->