Bug 26080: Some refactoring

A new include file is created per background job to avoid
background_jobs.tt to grow too much

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-07-29 12:12:59 +02:00
parent 6e4182c4fc
commit 7adae4930b
4 changed files with 159 additions and 141 deletions

View file

@ -0,0 +1,39 @@
[% BLOCK report %]
[% SET report = job.report %]
[% IF report %]
[% IF report.total_records == report.total_success %]
<div class="dialog message">
All records have successfully been modified! <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
</div>
[% ELSE %]
<div class="dialog message">
[% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred.
[% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %]
<a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
</div>
[% END %]
[% END %]
[% END %]
[% BLOCK detail %]
[% FOR m IN job.messages %]
<div class="dialog message">
[% IF m.type == 'success' %]
<i class="fa fa-check success"></i>
[% ELSIF m.type == 'warning' %]
<i class="fa fa-warning warn"></i>
[% ELSIF m.type == 'error' %]
<i class="fa fa-exclamation error"></i>
[% END %]
[% SWITCH m.code %]
[% CASE 'authority_not_modified' %]
Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% m.authid | uri %]">[% m.authid | html %]</a> has not been modified. An error occurred on modifying it[% IF m.error %] ([% m.error %])[% END %].
[% CASE 'authority_modified' %]
Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% m.authid | uri %]">[% m.authid | html %]</a> has successfully been modified..
[% END %]
</div>
[% END %]
[% END %]
[% BLOCK js %]
[% END %]

View file

@ -0,0 +1,49 @@
[% BLOCK report %]
[% SET report = job.report %]
[% IF report %]
[% IF report.total_records == report.total_success %]
<div class="dialog message">
All records have been deleted successfully!
</div>
[% ELSIF report.total_success == 0 %]
<div class="dialog message">
No record has been deleted. An error occurred.
</div>
[% ELSE %]
<div class="dialog message">
[% report.total_success | html %] / [% report.total_records | html %] records have been deleted successfully but some errors occurred.
</div>
[% END %]
[% END %]
[% END %]
[% BLOCK detail %]
[% FOR m IN job.messages %]
<div class="dialog message">
[% IF m.type == 'success' %]
<i class="fa fa-check success"></i>
[% ELSIF m.type == 'warning' %]
<i class="fa fa-warning warn"></i>
[% ELSIF m.type == 'error' %]
<i class="fa fa-exclamation error"></i>
[% END %]
[% SWITCH m.code %]
[% CASE 'biblio_not_exists' %]
The biblionumber [% m.biblionumber | html %] does not exist in the database.
[% CASE 'item_issued' %]
At least one item is checked out on bibliographic record [% m.biblionumber | html %].
[% CASE 'reserve_not_cancelled' %]
Bibliographic record [% m.biblionumber | html %] was not deleted. A hold could not be canceled (reserve_id [% m.reserve_id | html %]).
[% CASE 'item_not_deleted' %]
The bibliographic record [% m.biblionumber | html %] was not deleted. An error was encountered when deleting an item (itemnumber [% m.itemnumber | html %]).
[% CASE 'biblio_not_deleted' %]
Bibliographic record [% m.biblionumber | html %] was not deleted. An error occurred.
[% CASE 'biblio_deleted' %]
Bibliographic record [% m.biblionumber | html %] has been deleted successfully.
[% END %]
</div>
[% END %]
[% END %]
[% BLOCK js %]
[% END %]

View file

@ -0,0 +1,64 @@
[% BLOCK report %]
[% SET report = job.report %]
[% IF report %]
[% IF report.total_records == report.total_success %]
<div class="dialog message">
All records have successfully been modified! <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
[% IF lists.count %]
<br />
Add modified records to the following list:
<select name="add_bibs_to_list" id="add_bibs_to_list">
<option value="">Select a list</option>
[% FOREACH list IN lists %]
<option class="shelf" value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
[% END %]
</select>
[% END %]
</div>
[% ELSE %]
<div class="dialog message">
[% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred.
[% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %]
<a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
</div>
[% END %]
[% END %]
[% END %]
[% BLOCK detail %]
[% FOR m IN job.messages %]
<div class="dialog message">
[% IF m.type == 'success' %]
<i class="fa fa-check success"></i>
[% ELSIF m.type == 'warning' %]
<i class="fa fa-warning warn"></i>
[% ELSIF m.type == 'error' %]
<i class="fa fa-exclamation error"></i>
[% END %]
[% SWITCH m.code %]
[% CASE 'biblio_not_modified' %]
Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.biblionumber | uri %]">[% m.biblionumber | html %]</a> has not been modified. An error occurred on modifying it.[% IF m.error %] ([% m.error | html %])[% END %].
[% CASE 'biblio_modified' %]
Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.biblionumber | uri %]">[% m.biblionumber | html %]</a> has successfully been modified.
[% END %]
</div>
[% END %]
[% END %]
[% BLOCK js %]
$("#add_bibs_to_list").change(function(){
var selected = $("#add_bibs_to_list").find("option:selected");
if ( selected.attr("class") == "shelf" ){
var shelfnumber = selected.attr("value");
var bibs = new Array();
[% FOREACH message IN job.messages %]
[% IF message.code == 'biblio_modified' %]
bibs.push("biblionumber="+[% message.biblionumber | html %]);
[% END %]
[% END %]
var bibstring = bibs.join("&");
window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&'+bibstring, 'popup', 'width=500,height=500,toolbar=false,scrollbars=yes,resizeable=yes');
return false;
}
});
[% END %]

View file

@ -93,6 +93,8 @@
[% IF op == 'view' %]
<h1>Details of job #[% job.id | html %]</h1>
[% PROCESS "background_jobs/${job.type}.inc" %]
<fieldset class="rows">
<ol>
<li><span class="label">Job ID: </span>[% job.id | html %]</li>
@ -118,134 +120,10 @@
[% job.ended_on | $KohaDates with_hours = 1 %]
</li>
<li><label for="job_data">Report: </label>
[% SWITCH job.type %]
[% CASE 'batch_biblio_record_modification' %]
[% SET report = job.report %]
[% IF report %]
[% IF report.total_records == report.total_success %]
<div class="dialog message">
All records have successfully been modified! <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
[% IF lists.count %]
<br />
Add modified records to the following list:
<select name="add_bibs_to_list" id="add_bibs_to_list">
<option value="">Select a list</option>
[% FOREACH list IN lists %]
<option class="shelf" value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
[% END %]
</select>
[% END %]
</div>
[% ELSE %]
<div class="dialog message">
[% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred.
[% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %]
<a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
</div>
[% END %]
[% END %]
[% CASE 'batch_authority_record_modification' %]
[% SET report = job.report %]
[% IF report %]
[% IF report.total_records == report.total_success %]
<div class="dialog message">
All records have successfully been modified! <a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
</div>
[% ELSE %]
<div class="dialog message">
[% report.total_success | html %] / [% report.total_records | html %] records have successfully been modified. Some errors occurred.
[% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %]
<a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a>
</div>
[% END %]
[% END %]
[% CASE 'batch_biblio_record_deletion' %]
[% SET report = job.report %]
[% IF report %]
[% IF report.total_records == report.total_success %]
<div class="dialog message">
All records have been deleted successfully!
</div>
[% ELSIF report.total_success == 0 %]
<div class="dialog message">
No record has been deleted. An error occurred.
</div>
[% ELSE %]
<div class="dialog message">
[% report.total_success | html %] / [% report.total_records | html %] records have been deleted successfully but some errors occurred.
</div>
[% END %]
[% END %]
[% CASE %]Job type "[% job.type | html %]" not handled in the template
[% END %]
[% PROCESS 'report' %]
</li>
<li><label for="job_data">Detailed messages: </label>
[% SWITCH job.type %]
[% CASE 'batch_biblio_record_modification' %]
[% FOR m IN job.messages %]
<div class="dialog message">
[% IF m.type == 'success' %]
<i class="fa fa-check success"></i>
[% ELSIF m.type == 'warning' %]
<i class="fa fa-warning warn"></i>
[% ELSIF m.type == 'error' %]
<i class="fa fa-exclamation error"></i>
[% END %]
[% SWITCH m.code %]
[% CASE 'biblio_not_modified' %]
Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.biblionumber | uri %]">[% m.biblionumber | html %]</a> has not been modified. An error occurred on modifying it.[% IF m.error %] ([% m.error | html %])[% END %].
[% CASE 'biblio_modified' %]
Bibliographic record <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.biblionumber | uri %]">[% m.biblionumber | html %]</a> has successfully been modified.
[% END %]
</div>
[% END %]
[% CASE 'batch_authority_record_modification' %]
[% FOR m IN job.messages %]
<div class="dialog message">
[% IF m.type == 'success' %]
<i class="fa fa-check success"></i>
[% ELSIF m.type == 'warning' %]
<i class="fa fa-warning warn"></i>
[% ELSIF m.type == 'error' %]
<i class="fa fa-exclamation error"></i>
[% END %]
[% SWITCH m.code %]
[% CASE 'authority_not_modified' %]
Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% m.authid | uri %]">[% m.authid | html %]</a> has not been modified. An error occurred on modifying it[% IF m.error %] ([% m.error | html %])[% END %].
[% CASE 'authority_modified' %]
Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% m.authid | uri %]">[% m.authid | html %]</a> has successfully been modified.
[% END %]
</div>
[% END %]
[% CASE 'batch_biblio_record_deletion' %]
[% FOR m IN job.messages %]
<div class="dialog message">
[% IF m.type == 'success' %]
<i class="fa fa-check success"></i>
[% ELSIF m.type == 'warning' %]
<i class="fa fa-warning warn"></i>
[% ELSIF m.type == 'error' %]
<i class="fa fa-exclamation error"></i>
[% END %]
[% SWITCH m.code %]
[% CASE 'biblio_not_exists' %]
The biblionumber [% m.biblionumber | html %] does not exist in the database.
[% CASE 'item_issued' %]
At least one item is checked out on bibliographic record [% m.biblionumber | html %].
[% CASE 'reserve_not_cancelled' %]
Bibliographic record [% m.biblionumber | html %] was not deleted. A hold could not be canceled (reserve_id [% m.reserve_id | html %]).
[% CASE 'item_not_deleted' %]
The bibliographic record [% m.biblionumber | html %] was not deleted. An error was encountered when deleting an item (itemnumber [% m.itemnumber | html %]).
[% CASE 'biblio_not_deleted' %]
Bibliographic record [% m.biblionumber | html %] was not deleted. An error occurred.
[% CASE 'biblio_deleted' %]
Bibliographic record [% m.biblionumber | html %] has been deleted successfully.
[% END %]
</div>
[% END %]
[% CASE %]Job type "[% job.type | html %]" not handled in the template
[% END %]
[% PROCESS 'detail' %]
</li>
</ol>
</fieldset>
@ -335,21 +213,9 @@
"sPaginationType": "full_numbers"
}));
$("#add_bibs_to_list").change(function(){
var selected = $("#add_bibs_to_list").find("option:selected");
if ( selected.attr("class") == "shelf" ){
var shelfnumber = selected.attr("value");
var bibs = new Array();
[% FOREACH message IN job.messages %]
[% IF message.code == 'biblio_modified' %]
bibs.push("biblionumber="+[% message.biblionumber | html %]);
[% END %]
[% END %]
var bibstring = bibs.join("&");
window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&'+bibstring, 'popup', 'width=500,height=500,toolbar=false,scrollbars=yes,resizable=yes');
return false;
}
});
[% IF op == 'view' %]
[% PROCESS 'js' %]
[% END %]
});
</script>
[% END %]