Bug 28915: Add character position to MARC modification templates view

To test new form events:
1. Navigate to Cataloging > MARC modification templates > + New template (and provide any name)
2. Click + New action
3. Add "008" after "field(s)" and click tabulator or your mouse anywhere on the screen
4. Observe the second (sub)field input field disappearing
5. From dropdown "Delete", select "Update existing or add new"
6. Observe new text "starting from character position"
7. Select any other action from the dropdown from step 5
8. Observe the text "starting from character position" disappearing (unless action is to update or add new field)
9. Observe subfield input field missing (unless action is to update or add new field)

To test MARC modification with the new feature:
1. Add a new record
2. Modify record's 008 field character position 2-3 to "06" (indicating month June)
3. Navigate to Cataloging > MARC modification templates > + New template (name "Change June to September")
4. Click + New action
5. Add "008" after "field(s)"
6. From dropdown "Delete", select "Update existing or add new"
7. To the input field on the right of "starting from character position", enter value 2
8. To the input field on the right of "with value", enter 09
9. From the empty dropdown below, select "if"
10. To the input field on the right of "field", enter 008
11. From the dropdown on the right, select "matches"
12. Check "RegEx"
13. To the empty input field on the right, enter ^[0-9][0-9]06
14. Give any description you want (ex. Change 008 June to September)
15. Navigate to the record details you added in step 1
16. Click Edit > Modify record using template
17. Click "Show MARC"
18. Double check field 008 character position 2-3 is currently 06
19. Click "Close"
20. From dropdown "Select a template", select your new modification template from step 3
21. Click "Show MARC"
22. Observe field 008 character position 2-3 is now 09
23. Click "Modify selected records"
24. After job is completed, observe field 008 character positions 2-3 are now 09

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Anneli Österman <anneli.osterman@koha-suomi.fi>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Lari Taskula 2026-04-23 20:34:24 +03:00 committed by Pedro Amorim
parent 534c54f730
commit 6db0d42427
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 45 additions and 2 deletions

View File

@ -30,6 +30,10 @@
display: none;
}
#character_position {
display: none;
}
.action_line {
margin-bottom: 1em;
}
@ -269,7 +273,8 @@
</select>
</span>
field(s) <input type="text" name="from_field" id="from_field" size="3" maxlength="3" /> <input type="text" name="from_subfield" id="from_subfield" size="1" maxlength="1" title="let blank for the entire field" />
field(s) <input type="text" name="from_field" id="from_field" size="3" maxlength="3" /> <span id="character_position">starting from character position </span
><input type="text" name="from_subfield" id="from_subfield" size="1" maxlength="1" title="let blank for the entire field" />
<span name="with_value_block" id="with_value_block" style="display:none;"> with value <input type="text" name="field_value" id="field_value" /> </span>

View File

@ -56,7 +56,10 @@ $(document).ready(function () {
}
}
if (action == "update_field") {
if ($("#from_subfield").val().length <= 0) {
if (
$("#from_field").val() > 10 &&
$("#from_subfield").val().length <= 0
) {
alert(__("The source subfield should be filled for update."));
return false;
}
@ -103,6 +106,7 @@ $(document).ready(function () {
$("#conditional_field,#from_field").change(function () {
updateAllEvery();
toggleCharacterPositionField();
});
$("#cancel_edit").on("click", function (e) {
@ -177,6 +181,30 @@ $(document).ready(function () {
});
});
function toggleCharacterPositionField() {
if ($("#from_field").val().length > 0 && $("#from_field").val() < 10) {
if ($("#action").val() === "update_field") {
$("#from_subfield").show();
$("#character_position").show();
} else {
$("#from_subfield").val("");
$("#from_subfield").hide();
$("#character_position").hide();
}
} else {
$("#from_subfield").show();
$("#character_position").hide();
}
if (
$("#conditional_field").val().length > 0 &&
$("#conditional_field").val() < 10
) {
$("#conditional_subfield").val("");
$("#conditional_subfield").hide();
} else {
$("#conditional_subfield").show();
}
}
function updateAllEvery() {
if ($("#conditional_field").is(":visible")) {
if (
@ -202,12 +230,14 @@ function onActionChange(selectObj) {
show("field_number_block");
hide("with_value_block");
hide("to_field_block");
hide("character_position");
break;
case "add_field":
hide("field_number_block");
show("with_value_block");
hide("to_field_block");
hide("character_position");
break;
case "update_field":
@ -220,20 +250,25 @@ function onActionChange(selectObj) {
show("field_number_block");
hide("with_value_block");
show("to_field_block");
hide("character_position");
break;
case "copy_field":
show("field_number_block");
hide("with_value_block");
show("to_field_block");
hide("character_position");
break;
case "copy_and_replace_field":
show("field_number_block");
hide("with_value_block");
show("to_field_block");
hide("character_position");
break;
}
toggleCharacterPositionField();
}
function onConditionalChange(selectObj) {
@ -380,6 +415,8 @@ function editAction(mmta) {
window.action_submit_value = document.getElementById("action_submit").value;
document.getElementById("action_submit").value = __("Update action");
toggleCharacterPositionField();
}
function cancelEditAction() {
@ -421,6 +458,7 @@ function cancelEditAction() {
$("#no_defined_actions").show();
}
toggleCharacterPositionField();
$("#add_action").hide();
}