From e21c19e170c35e42010f3af956fb5db988e32552 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 11 Oct 2023 08:38:57 +0000 Subject: [PATCH] Bug 30719: (QA follow-up) Updating remaining naming Update statuscode -> status_code on the js files Update remaining batch_id -> ill_batch_id Update batch object in Illrequest.pm strings_map Signed-off-by: Tomas Cohen Arazi --- Koha/IllbatchStatus.pm | 4 +-- Koha/Illrequest.pm | 9 +++--- api/v1/swagger/definitions/ill_request.yaml | 2 +- .../prog/en/includes/ill-batch-modal.inc | 6 ++-- .../prog/en/modules/ill/ill-requests.tt | 2 +- .../intranet-tmpl/prog/js/ill-batch-modal.js | 28 +++++++++---------- .../intranet-tmpl/prog/js/ill-batch-table.js | 14 +++++----- .../intranet-tmpl/prog/js/ill-list-table.js | 2 +- t/db_dependent/IllbatchStatuses.t | 6 ++-- 9 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Koha/IllbatchStatus.pm b/Koha/IllbatchStatus.pm index acd2a7ed64..e098762f90 100644 --- a/Koha/IllbatchStatus.pm +++ b/Koha/IllbatchStatus.pm @@ -124,8 +124,8 @@ sub delete_and_log { } # Update all batches that use this status to have status UNKNOWN - my $affected = Koha::Illbatches->search( { statuscode => $self->code } ); - $affected->update( { statuscode => 'UNKNOWN' } ); + my $affected = Koha::Illbatches->search( { status_code => $self->code } ); + $affected->update( { status_code => 'UNKNOWN' } ); my $logger = Koha::Illrequest::Logger->new; diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 6662b445a6..5db6762a76 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1909,6 +1909,7 @@ sub TO_JSON { sub to_api_mapping { return { accessurl => 'access_url', + batch_id => 'ill_batch_id', backend => 'ill_backend_id', borrowernumber => 'patron_id', branchcode => 'library_id', @@ -1997,12 +1998,12 @@ sub strings_map { my $batch = $self->batch; if ($batch) { $strings->{"batch"} = { - id => $batch->id, + ill_batch_id => $batch->ill_batch_id, name => $batch->name, backend => $batch->backend, - borrowernumber => $batch->borrowernumber, - branchcode => $batch->branchcode, - statuscode => $batch->statuscode + patron_id => $batch->patron_id, + library_id => $batch->library_id, + status_code => $batch->status_code }; } diff --git a/api/v1/swagger/definitions/ill_request.yaml b/api/v1/swagger/definitions/ill_request.yaml index 80f7e13b21..e25fc6f416 100644 --- a/api/v1/swagger/definitions/ill_request.yaml +++ b/api/v1/swagger/definitions/ill_request.yaml @@ -9,7 +9,7 @@ properties: - integer - "null" description: Internal bibliographic record identifier - batch_id: + ill_batch_id: type: - integer - "null" diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc index 15d104e277..8494005f50 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc @@ -28,9 +28,9 @@ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %] - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 18de16803f..e9fe937b87 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -669,7 +669,7 @@ [% IF request.batch > 0 %]
  • Batch: - + [% request.batch.name | html %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js index c7c302b1aa..0d229c77d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js @@ -25,7 +25,7 @@ var createProgressBar = document.getElementById("processed_progress_bar"); var identifierTable = document.getElementById('identifier-table'); var createRequestsButton = document.getElementById('create-requests-button'); - var statusesSelect = document.getElementById('statuscode'); + var statusesSelect = document.getElementById('status_code'); var cancelButton = document.getElementById('lhs').querySelector('button'); var cancelButtonOriginalText = cancelButton.innerHTML; @@ -49,7 +49,7 @@ backend: null, cardnumber: '', branchcode: '', - statuscode: 'NEW' + status_code: 'NEW' }; // The object that holds the batch we're working with @@ -307,7 +307,7 @@ } var payload = { - batch_id: batchId, + ill_batch_id: batchId, ill_backend_id: batch.data.backend, patron_id: batch.data.patron.patron_id, library_id: batch.data.library_id, @@ -378,7 +378,7 @@ var option = document.createElement('option') option.value = status.code; option.text = status.name; - if (batch.data.batch_id && batch.data.statuscode === status.code) { + if (batch.data.ill_batch_id && batch.data.status_code === status.code) { option.selected = true; } statusesSelect.add(option); @@ -479,7 +479,7 @@ updateBatch() .then(function () { $('#ill-batch-modal').modal({ show: false }); - location.href = '/cgi-bin/koha/ill/ill-requests.pl?batch_id=' + batch.data.batch_id; + location.href = '/cgi-bin/koha/ill/ill-requests.pl?batch_id=' + batch.data.ill_batch_id; }); }; @@ -509,12 +509,12 @@ }) .then(function (jsoned) { batch.data = { - batch_id: jsoned.batch_id, + ill_batch_id: jsoned.ill_batch_id, name: jsoned.name, backend: jsoned.backend, cardnumber: jsoned.cardnumber, library_id: jsoned.library_id, - statuscode: jsoned.statuscode + status_code: jsoned.status_code } return jsoned; }) @@ -540,7 +540,7 @@ backend: backend, cardnumber: cardnumberInput.value, library_id: selectedBranchcode, - statuscode: selectedStatuscode + status_code: selectedStatuscode }) }) .then(function (response) { @@ -550,14 +550,14 @@ return Promise.reject(response); }) .then(function (body) { - batchId = body.batch_id; + batchId = body.ill_batch_id; batch.data = { - batch_id: body.batch_id, + ill_batch_id: body.ill_batch_id, name: body.name, backend: body.backend, cardnumber: body.patron.cardnumber, library_id: body.library_id, - statuscode: body.statuscode, + status_code: body.status_code, patron: body.patron, status: body.status }; @@ -578,7 +578,7 @@ var selectedBranchcode = branchcodeSelect.selectedOptions[0].value; var selectedStatuscode = statusesSelect.selectedOptions[0].value; - return doBatchApiRequest('/' + batch.data.batch_id, { + return doBatchApiRequest('/' + batch.data.ill_batch_id, { method: 'PUT', headers: { 'Content-type': 'application/json' @@ -588,7 +588,7 @@ backend: batch.data.backend, cardnumber: batch.data.patron.cardnumber, library_id: selectedBranchcode, - statuscode: selectedStatuscode + status_code: selectedStatuscode }) }) .catch(function () { @@ -1045,7 +1045,7 @@ } function manageBatchItemsDisplay() { - batchItemsDisplay.style.display = batch.data.batch_id ? 'block' : 'none' + batchItemsDisplay.style.display = batch.data.ill_batch_id ? 'block' : 'none' }; function updateBatchInputs() { diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-table.js index dd2d400771..fe535ff16e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-table.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-table.js @@ -50,7 +50,7 @@ data: batchesProxy.data, columns: [ { - data: 'batch_id', + data: 'ill_batch_id', width: '10%' }, { @@ -92,13 +92,13 @@ // A render function for branch name var createBranch = function (x, y, data) { - return data._strings.branchname; + return data._strings.library_id.str; }; // A render function for batch name var createName = function (x, y, data) { var a = document.createElement('a'); - a.setAttribute('href', '/cgi-bin/koha/ill/ill-requests.pl?batch_id=' + data.batch_id); + a.setAttribute('href', '/cgi-bin/koha/ill/ill-requests.pl?batch_id=' + data.ill_batch_id); a.setAttribute('title', data.name); a.textContent = data.name; return a.outerHTML; @@ -106,7 +106,7 @@ // A render function for batch status var createStatus = function (x, y, data) { - return data._strings.status.name; + return data._strings.status_code.str; }; // A render function for our patron link @@ -122,13 +122,13 @@ var editButton = document.createElement('button'); editButton.setAttribute('type', 'button'); editButton.setAttribute('class', 'editButton btn btn-xs btn-default'); - editButton.setAttribute('data-batch-id', row.batch_id); + editButton.setAttribute('data-batch-id', row.ill_batch_id); editButton.appendChild(document.createTextNode(ill_batch_edit)); var deleteButton = document.createElement('button'); deleteButton.setAttribute('type', 'button'); deleteButton.setAttribute('class', 'deleteButton btn btn-xs btn-danger'); - deleteButton.setAttribute('data-batch-id', row.batch_id); + deleteButton.setAttribute('data-batch-id', row.ill_batch_id); deleteButton.appendChild(document.createTextNode(ill_batch_delete)); div.appendChild(editButton); @@ -200,7 +200,7 @@ // Remove a batch from our proxy data var removeBatch = function(id) { batchesProxy.data = batchesProxy.data.filter(function (batch) { - return batch.batch_id != id; + return batch.ill_batch_id != id; }); }; diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js index fa3ceb223f..f6255f74e7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js @@ -220,7 +220,7 @@ $(document).ready(function() { "render": function(data, type, row, meta) { return row.batch ? '' + row.batch.name + '' diff --git a/t/db_dependent/IllbatchStatuses.t b/t/db_dependent/IllbatchStatuses.t index c03e81a426..8748d73b56 100755 --- a/t/db_dependent/IllbatchStatuses.t +++ b/t/db_dependent/IllbatchStatuses.t @@ -197,7 +197,7 @@ my $batch = Koha::Illbatch->new( patron_id => $patron->borrowernumber, library_id => $library->branchcode, backend => "TEST", - statuscode => $status5->code + status_code => $status5->code } ); $batch->create_and_log; @@ -205,7 +205,7 @@ $batch->create_and_log; # Delete the batch status and ensure the batch's status has been changed # to UNKNOWN $status5->delete_and_log; -my $updated_code = Koha::Illbatches->find( { statuscode => "UNKNOWN" } ); -is( $updated_code->statuscode, "UNKNOWN", "batches attached to deleted status have status changed to UNKNOWN" ); +my $updated_code = Koha::Illbatches->find( { status_code => "UNKNOWN" } ); +is( $updated_code->status_code, "UNKNOWN", "batches attached to deleted status have status changed to UNKNOWN" ); $schema->storage->txn_rollback; -- 2.39.5