Bug 10648 - In records merge greatest field can not be added

When merging 2 records (/cgi-bin/koha/cataloguing/merge.pl), the destination record is build using the fields and subfields checked in source records.
When a field is checked, the javascript code searches in destination record a field with a greater tag number to insert new field before.
When the new field tag number is greater than all existing field tag numbers, the field is not added.

This patch corrects this by adding at end if no greater field tag number exists. Also adds a sort of fields by tag number because all mergo code is based on this.

Test plan :
- Add to a framework a repeatable field with the greater non existing tag number. For example 998.
- Edit 2 records with this framework and add them a value in this tag.
- Put those 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 the greatest tag number. for example 998.
=> The field is added at the end of destination record

Signed-off-by: Nick Clemens <nick@quecheelibrary.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Works as described, no regressions.
This commit is contained in:
Fridolyn SOMERS 2013-07-26 17:02:01 +02:00 committed by Tomas Cohen Arazi
parent d3ece36015
commit 7a5eac3a51

View file

@ -79,8 +79,9 @@ function toggleField(pField) {
// If not, we add the subfield to the first matching field // If not, we add the subfield to the first matching field
var where = 0; var where = 0;
$("#resultul li span.field").each(function() { $("#resultul li span.field").each(function() {
if (where == 0 && $(this).text() == field) { if ($(this).text() == field) {
where = this; where = this;
return false; // break each()
} }
}); });
@ -102,14 +103,19 @@ function toggleField(pField) {
} else { } else {
// If we are a field // If we are a field
var where = 0; var where = 0;
// Find where to add the field // Find a greater field to add before
$("#resultul li span.field").each(function() { $("#resultul li span.field").each(function() {
if (where == 0 && $(this).text() > field) { if ($(this).text() > field) {
where = this; where = this;
return false; // break each()
} }
}); });
if (where) {
$(where).parent().before(clone); $(where).parent().before(clone);
} else {
// No greater field, add to the end
$("#resultul").append(clone);
}
} }
} }
} else { } else {