Bug 31891: (bug 27421 follow-up) Remove one additional click

From comment 0
"""
Moving marc batch import actions to background jobs has introduced some confusing
clicks to the process. Before this change, after staging a batch one was taken
to a "MARC staging results" page with details of how the staging went and, most
importantly, a link straight to the batch you'd just staged
(at manage-marc-import.pl?import_batch_id).

Now, however, one must click the status bar to get to details of the job
and then click "View batch" from there. Not only is that an extra click
and page load, but neither of those links are particularly large or
obvious.
"""

Test plan:
- Stage a record for import, notice that the "View batch" link appears
when the job is finished
- Add order to basket from a new file, select a file and import
Notice that the "Add staged files to basket" link is displayed when the
job is finished

Note for QA: We should have a js_callback in the background_job include
file instead.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-11-16 07:40:59 +01:00 committed by Tomas Cohen Arazi
parent a40532b1ce
commit 5e51279ce9
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 16 additions and 5 deletions

View File

@ -79,6 +79,7 @@
<p>The job has been enqueued! It will be processed as soon as possible.</p>
[% INCLUDE "job_progress.inc" job_id=job_id %]
<p><a class="job_details" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a>
<div id="job_callback"></div>
</div>
[% ELSE %]
<h1>Stage MARC records for import</h1>
@ -105,8 +106,7 @@
<div id="fileuploadpanel">
<div id="fileuploadstatus" class="progress_panel">Upload progress:
<progress id="fileuploadprogress" max="100" value="0">
</progress>
<progress id="fileuploadprogress" max="100" value="0"></progress>
<span class="fileuploadpercent">0</span>%
</div>
<div id="fileuploadfailed"></div>
@ -428,7 +428,17 @@
})
});
[% IF job_enqueued %]
updateProgress([% job_id | html %]);
updateProgress([% job_id | html %], function(){
$.getJSON('/api/v1/jobs/[% job_id | html %]', function(job){
let import_batch_id = job.data.report.import_batch_id;
$('<p><a href="/cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=%s">%s</a></p>'.format(import_batch_id, _("View batch"))).appendTo("#job_callback");
let basket_id = job.data.report.basket_id;
let vendor_id = job.data.report.vendor_id;
if ( basket_id && vendor_id ) {
$('<p><a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=%s&basketno=%s&booksellerid=%s">%s</a></p>'.format(import_batch_id, basket_id, vendor_id, _("Add staged files to basket"))).appendTo("#job_callback");
}
});
});
[% END %]
});

View File

@ -1,4 +1,4 @@
function updateProgress(job_id) {
function updateProgress(job_id, callback) {
$.getJSON('/api/v1/jobs/' + job_id, function(job){
let recheck = true;
@ -19,6 +19,7 @@ function updateProgress(job_id) {
$('#progress-bar-' + job_id).addClass("progress-bar-success");
$('#progress-bar-' + job_id).attr('aria-valuenow', 100).css("width", "100%");
recheck = false;
callback();
} else if ( job.status == "failed" ) {
$('#job-percent-' + job_id).text(0);
$('#job-status-' + job_id).text(JOB_PROGRESS_FAILED);
@ -28,7 +29,7 @@ function updateProgress(job_id) {
}
if ( recheck ) {
setTimeout(function(){updateProgress(job_id)}, 1 * 1000);
setTimeout(function(){updateProgress(job_id, callback)}, 1 * 1000);
}
});
}