Skip to content

Commit 5e51279

Browse files
joubutomascohen
authored andcommitted
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 <[email protected]> Signed-off-by: Marcel de Rooy <[email protected]> Signed-off-by: Tomas Cohen Arazi <[email protected]>
1 parent a40532b commit 5e51279

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<p>The job has been enqueued! It will be processed as soon as possible.</p>
8080
[% INCLUDE "job_progress.inc" job_id=job_id %]
8181
<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>
82+
<div id="job_callback"></div>
8283
</div>
8384
[% ELSE %]
8485
<h1>Stage MARC records for import</h1>
@@ -105,8 +106,7 @@
105106

106107
<div id="fileuploadpanel">
107108
<div id="fileuploadstatus" class="progress_panel">Upload progress:
108-
<progress id="fileuploadprogress" max="100" value="0">
109-
</progress>
109+
<progress id="fileuploadprogress" max="100" value="0"></progress>
110110
<span class="fileuploadpercent">0</span>%
111111
</div>
112112
<div id="fileuploadfailed"></div>
@@ -428,7 +428,17 @@
428428
})
429429
});
430430
[% IF job_enqueued %]
431-
updateProgress([% job_id | html %]);
431+
updateProgress([% job_id | html %], function(){
432+
$.getJSON('/api/v1/jobs/[% job_id | html %]', function(job){
433+
let import_batch_id = job.data.report.import_batch_id;
434+
$('<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");
435+
let basket_id = job.data.report.basket_id;
436+
let vendor_id = job.data.report.vendor_id;
437+
if ( basket_id && vendor_id ) {
438+
$('<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");
439+
}
440+
});
441+
});
432442
[% END %]
433443
});
434444

koha-tmpl/intranet-tmpl/prog/js/job_progess.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function updateProgress(job_id) {
1+
function updateProgress(job_id, callback) {
22
$.getJSON('/api/v1/jobs/' + job_id, function(job){
33
let recheck = true;
44

@@ -19,6 +19,7 @@ function updateProgress(job_id) {
1919
$('#progress-bar-' + job_id).addClass("progress-bar-success");
2020
$('#progress-bar-' + job_id).attr('aria-valuenow', 100).css("width", "100%");
2121
recheck = false;
22+
callback();
2223
} else if ( job.status == "failed" ) {
2324
$('#job-percent-' + job_id).text(0);
2425
$('#job-status-' + job_id).text(JOB_PROGRESS_FAILED);
@@ -28,7 +29,7 @@ function updateProgress(job_id) {
2829
}
2930

3031
if ( recheck ) {
31-
setTimeout(function(){updateProgress(job_id)}, 1 * 1000);
32+
setTimeout(function(){updateProgress(job_id, callback)}, 1 * 1000);
3233
}
3334
});
3435
}

0 commit comments

Comments
 (0)