Lines 1-3
Link Here
|
|
|
1 |
[% PROCESS 'merge-record.inc' %] |
1 |
[% INCLUDE 'doc-head-open.inc' %] |
2 |
[% INCLUDE 'doc-head-open.inc' %] |
2 |
<title>Koha › Cataloging › Merging records</title> |
3 |
<title>Koha › Cataloging › Merging records</title> |
3 |
[% INCLUDE 'greybox.inc' %] |
4 |
[% INCLUDE 'greybox.inc' %] |
Lines 16-167
div#result { margin-top: 1em; }
Link Here
|
16 |
$("ul#ulrecord2").remove(); |
17 |
$("ul#ulrecord2").remove(); |
17 |
} |
18 |
} |
18 |
|
19 |
|
19 |
|
|
|
20 |
$(document).ready(function(){ |
20 |
$(document).ready(function(){ |
21 |
// Creating tabs |
|
|
22 |
$("#tabs").tabs(); |
23 |
|
24 |
// Getting marc structure via ajax |
21 |
// Getting marc structure via ajax |
25 |
tagslib = []; |
22 |
tagslib = []; |
26 |
$.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) { |
23 |
$.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) { |
27 |
tagslib = json; |
24 |
tagslib = json; |
28 |
}); |
25 |
}); |
29 |
|
26 |
[% PROCESS mergejs %] |
30 |
|
|
|
31 |
// Toggle a field / subfield |
32 |
function toggleField(pField) { |
33 |
|
34 |
// Getting the key of the clicked checkbox |
35 |
var ckid = $(pField).attr("id"); |
36 |
var tab = ckid.split('_'); |
37 |
var source = tab[1]; // From which record the click came from |
38 |
var key = tab[2]; |
39 |
var type = $(pField).attr("class"); |
40 |
|
41 |
// Getting field/subfield |
42 |
var field; |
43 |
var subfield; |
44 |
if (type == "subfieldpick") { |
45 |
|
46 |
field = $(pField).parent().parent().parent().find("span.field").text(); |
47 |
subfield = $(pField).parent().find("span.subfield").text(); |
48 |
} else { |
49 |
|
50 |
field = $(pField).parent().find("span.field").text(); |
51 |
} |
52 |
|
53 |
// If the field has just been checked |
54 |
if (pField.checked) { |
55 |
|
56 |
// We check for repeatability |
57 |
var canbeadded = true; |
58 |
if (type == "subfieldpick") { |
59 |
var repeatable = 1; |
60 |
var alreadyexists = 0; |
61 |
if (tagslib[field] && tagslib[field][subfield]) { |
62 |
repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number |
63 |
// TODO : Checking for subfields |
64 |
} |
65 |
} else { |
66 |
if (tagslib[field]) { |
67 |
repeatable = tagslib[field].repeatable; |
68 |
alreadyexists = $("#resultul span.field:contains(" + field + ")"); |
69 |
if (repeatable == 0 && alreadyexists.length != 0) { |
70 |
canbeadded = false; |
71 |
} |
72 |
} |
73 |
} |
74 |
// If the field is not repeatable, we check if it already exists in the result table |
75 |
if (canbeadded == false) { |
76 |
alert(_("The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.")); |
77 |
pField.checked = 0; |
78 |
} else { |
79 |
|
80 |
// Cloning the field or subfield we picked |
81 |
var clone = $(pField).parent().clone(); |
82 |
|
83 |
// Removing the checkboxes from it |
84 |
$(clone).find("input.subfieldpick, input.fieldpick").each(function() { |
85 |
$(this).remove(); |
86 |
}); |
87 |
|
88 |
|
89 |
// If we are a subfield |
90 |
if (type == "subfieldpick") { |
91 |
// then we need to find who is our parent field... |
92 |
fieldkey = $(pField).parent().parent().parent().attr("id"); |
93 |
|
94 |
// Find where to add the subfield |
95 |
|
96 |
// First, check if the field is not already in the destination record |
97 |
if ($("#resultul li#" + fieldkey).length > 0) { |
98 |
// If so, we add our field to it |
99 |
$("#resultul li#" + fieldkey + " ul").append(clone); |
100 |
} else { |
101 |
// If not, we add the subfield to the first matching field |
102 |
var where = 0; |
103 |
$("#resultul li span.field").each(function() { |
104 |
if (where == 0 && $(this).text() == field) { |
105 |
where = this; |
106 |
} |
107 |
}); |
108 |
|
109 |
// If there is no matching field in the destination record |
110 |
if (where == 0) { |
111 |
|
112 |
// TODO: |
113 |
// We select the whole field and removing non-selected subfields, instead of... |
114 |
|
115 |
// Alerting the user |
116 |
alert(_("This subfield cannot be added: there is no") + " " + field + " " + _("field in the destination record.")); |
117 |
pField.checked = false; |
118 |
|
119 |
} else { |
120 |
$(where).nextAll("ul").append(clone); |
121 |
} |
122 |
|
123 |
} |
124 |
|
125 |
|
126 |
|
127 |
} else { |
128 |
// If we are a field |
129 |
var where = 0; |
130 |
// Find where to add the field |
131 |
$("#resultul li span.field").each(function() { |
132 |
if (where == 0 && $(this).text() > field) { |
133 |
where = this; |
134 |
} |
135 |
}); |
136 |
|
137 |
$(where).parent().before(clone); |
138 |
} |
139 |
} |
140 |
} else { |
141 |
|
142 |
// Else, we remove it from the results tab |
143 |
$("ul#resultul li#k" + key).remove(); |
144 |
} |
145 |
} |
146 |
|
147 |
|
148 |
// When a field is checked / unchecked |
149 |
$('input.fieldpick').click(function() { |
150 |
toggleField(this); |
151 |
// (un)check all subfields |
152 |
var ischecked = this.checked; |
153 |
$(this).parent().find("input.subfieldpick").each(function() { |
154 |
this.checked = ischecked; |
155 |
}); |
156 |
}); |
157 |
|
158 |
// When a field or subfield is checked / unchecked |
159 |
$("input.subfieldpick").click(function() { |
160 |
toggleField(this); |
161 |
}); |
162 |
|
163 |
}); |
27 |
}); |
164 |
|
28 |
|
|
|
29 |
|
165 |
function changeFramework(fw) { |
30 |
function changeFramework(fw) { |
166 |
$("#Frameworks").val(fw); |
31 |
$("#Frameworks").val(fw); |
167 |
} |
32 |
} |
Lines 253-379
function changeFramework(fw) {
Link Here
|
253 |
|
118 |
|
254 |
<div class="yui-g"> |
119 |
<div class="yui-g"> |
255 |
<div class="yui-u first"> |
120 |
<div class="yui-u first"> |
256 |
<div id="tabs" class="toptabs"> |
121 |
[% PROCESS mergesource recordid1=biblio1 recordid2=biblio2 %] |
257 |
<h2>Source records</h2> |
|
|
258 |
<ul> |
259 |
<li><a href="#tabrecord1">[% biblio1 %]</a></li> |
260 |
<li><a href="#tabrecord2">[% biblio2 %]</a></li> |
261 |
</ul> |
262 |
<div id="tabrecord1"> |
263 |
[% IF ( record1 ) %] |
264 |
|
265 |
<div class="record"> |
266 |
<ul id="ulrecord1"> |
267 |
[% FOREACH record IN record1 %] |
268 |
[% FOREACH fiel IN record.field %] |
269 |
<li id="k[% fiel.key %]"> |
270 |
<input type="checkbox" checked="checked" class="fieldpick" id="rec_1_[% fiel.key %]" /> |
271 |
<span class="field">[% fiel.tag %]</span> |
272 |
|
273 |
<input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" /> |
274 |
<input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" /> |
275 |
[% IF ( fiel.value ) %] / [% fiel.value %] |
276 |
<input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" /> |
277 |
<input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value %]" /> |
278 |
[% END %] |
279 |
|
280 |
[% IF ( fiel.subfield ) %] |
281 |
<ul> |
282 |
[% FOREACH subfiel IN fiel.subfield %] |
283 |
<li id="k[% subfiel.subkey %]"> |
284 |
<input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_[% subfiel.subkey %]" /> |
285 |
<span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %] |
286 |
<input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" /> |
287 |
<input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" /> |
288 |
</li> |
289 |
[% END %] |
290 |
</ul> |
291 |
[% END %] |
292 |
[% END %] |
293 |
</li> |
294 |
[% END %] |
295 |
</ul> |
296 |
</div><!-- /div.record --> |
297 |
[% END %] |
298 |
</div><!-- /div#tabrecord1 --> |
299 |
<div id="tabrecord2"> |
300 |
[% IF ( record2 ) %] |
301 |
|
302 |
<div class="record"> |
303 |
<ul id="ulrecord2"> |
304 |
[% FOREACH record IN record2 %] |
305 |
[% FOREACH fiel IN record.field %] |
306 |
<li id="k[% fiel.key %]"> |
307 |
<input type="checkbox" class="fieldpick" id="rec_2_[% fiel.key %]" /> |
308 |
<span class="field">[% fiel.tag %]</span> |
309 |
|
310 |
<input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" /> |
311 |
<input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" /> |
312 |
[% IF ( fiel.value ) %] / [% fiel.value %] |
313 |
<input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" /> |
314 |
<input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" /> |
315 |
[% END %] |
316 |
|
317 |
[% IF ( fiel.subfield ) %] |
318 |
<ul> |
319 |
[% FOREACH subfiel IN fiel.subfield %] |
320 |
<li id="k[% subfiel.subkey %]"> |
321 |
<input type="checkbox" class="subfieldpick" id="rec_2_[% subfiel.subkey %]" /> |
322 |
<span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %] |
323 |
<input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" /> |
324 |
<input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" /> |
325 |
</li> |
326 |
[% END %] |
327 |
</ul> |
328 |
[% END %] |
329 |
[% END %] |
330 |
</li> |
331 |
[% END %] |
332 |
</ul> |
333 |
</div> |
334 |
<!-- /div.record --> |
335 |
|
336 |
|
337 |
|
338 |
|
339 |
[% END %] |
340 |
</div><!-- /div#tabrecord2 --> |
341 |
</div> <!-- // #tabs --> |
342 |
</div> |
122 |
</div> |
343 |
<div class="yui-u"> |
123 |
<div class="yui-u"> |
344 |
<div id="result"> |
124 |
[% PROCESS mergetarget %] |
345 |
<h2>Destination record</h2> |
|
|
346 |
<div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;"> |
347 |
<ul id="resultul"> |
348 |
[% FOREACH record IN record1 %] |
349 |
[% FOREACH fiel IN record.field %]<li id="k[% fiel.key %]"><span class="field">[% fiel.tag %]</span> |
350 |
<input type="hidden" name="tag_[% fiel.tag %]_indicator1_[% fiel.key %]" value="[% fiel.indicator1 %]" /> |
351 |
<input type="hidden" name="tag_[% fiel.tag %]_indicator2_[% fiel.key %]" value="[% fiel.indicator2 %]" /> |
352 |
[% IF ( fiel.value ) %] / |
353 |
[% fiel.value %] |
354 |
<input type="hidden" name="tag_[% fiel.tag %]_code_00_[% fiel.key %]" value="00" /> |
355 |
<input type="hidden" name="tag_[% fiel.tag %]_subfield_00_[% fiel.key %]" value="[% fiel.value |html%]" /> |
356 |
[% END %] |
357 |
|
358 |
[% IF ( fiel.subfield ) %] |
359 |
<ul> |
360 |
[% FOREACH subfiel IN fiel.subfield %] |
361 |
<li id="k[% subfiel.subkey %]"> |
362 |
<span class="subfield">[% subfiel.subtag %]</span> / [% subfiel.value %] |
363 |
<input type="hidden" name="tag_[% subfiel.tag %]_code_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.subtag %]" /> |
364 |
<input type="hidden" name="tag_[% subfiel.tag %]_subfield_[% subfiel.subtag %]_[% subfiel.key %]_[% subfiel.subkey %]" value="[% subfiel.value |html%]" /> |
365 |
</li> |
366 |
[% END %] |
367 |
</ul> |
368 |
[% END %] |
369 |
|
370 |
[% END %] |
371 |
</li> |
372 |
[% END %] |
373 |
|
374 |
</ul> |
375 |
</div> |
376 |
</div> <!-- // #result --> |
377 |
</div> <!-- .yui-u --> |
125 |
</div> <!-- .yui-u --> |
378 |
|
126 |
|
379 |
<input type="hidden" name="biblio1" value="[% biblio1 %]" /> |
127 |
<input type="hidden" name="biblio1" value="[% biblio1 %]" /> |