From ddaa92821540cb2384d091cd417e81bf1575751c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 23 Sep 2022 08:48:05 +0000 Subject: [PATCH] Bug 30982: (QA follow-up) Remove redundancy from template The template now contains two lists for both status and type: a TT list and a JS list. The type list already proves that redundancy leads to bugs. We miss three types at one side: Unknown job type 'stage_marc_for_import' Unknown job type 'marc_import_commit_batch' Unknown job type 'marc_import_revert_batch' This patch removes the TT list. And gets the status and type via an additional js call. For that reason I hide the fieldset until document ready. This can be improved later when needed. Test plan: Look at status and type on both job list and detail view. Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/admin/background_jobs.tt | 78 ++++++------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt index 70bfd32b81..1432cbdc2a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt @@ -3,54 +3,6 @@ [% USE Asset %] [% USE KohaDates %] [% SET footerjs = 1 %] -[% BLOCK show_job_status %] - [% SWITCH job.status %] - [% CASE "new" %] - New - [% CASE "cancelled" %] - Cancelled - [% CASE "finished" %] - Finished - [% CASE "started" %] - Started - [% CASE "running" %] - Running - [% CASE "failed" %] - Failed - [% CASE # Default case %] - [% job.status | html %] - [% END -%] -[% END %] -[% BLOCK show_job_type %] - [% SWITCH job_type %] - [% CASE 'batch_biblio_record_modification' %] - Batch bibliographic record modification - [% CASE 'batch_biblio_record_deletion' %] - Batch bibliographic record record deletion - [% CASE 'batch_authority_record_modification' %] - Batch authority record modification - [% CASE 'batch_authority_record_deletion' %] - Batch authority record deletion - [% CASE 'batch_item_record_modification' %] - Batch item record modification - [% CASE 'batch_item_record_deletion' %] - Batch item record deletion - [% CASE "batch_hold_cancel" %] - Batch hold cancellation - [% CASE 'update_elastic_index' %] - Update Elasticsearch index - [% CASE 'update_holds_queue_for_biblios' %] - Holds queue update - [% CASE 'stage_marc_for_import' %] - Staged MARC records for import - [% CASE 'marc_import_commit_batch' %] - Import MARC records - [% CASE 'marc_import_revert_batch' %] - Revert import MARC records - [% CASE %]Unknown job type '[% job_type | html %]' - [% END %] - -[% END %] [% INCLUDE 'doc-head-open.inc' %] [% IF op == 'view' %] @@ -118,17 +70,17 @@ [% PROCESS "background_jobs/${job.type}.inc" %] - <fieldset class="rows"> + <fieldset class="rows" style="display:none;"> <ol> <li><span class="label">Job ID: </span>[% job.id | html %]</li> <li> <label for="job_status">Status: </label> - [% PROCESS show_job_status %] + <span id="job_status_description"></span> </li> <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li> <li> <label for="job_type">Type: </label> - [% PROCESS show_job_type job_type => job.type %] + <span id="job_type_description"></span> </li> <li> <label for="job_enqueued_on">Queued: </label> @@ -249,13 +201,25 @@ '_str': _("Batch hold cancellation") }, { - '_id': 'update_elastic_index' - , '_str': _("Update Elasticsearch index") + '_id': 'update_elastic_index', + '_str': _("Update Elasticsearch index") }, { '_id': 'update_holds_queue_for_biblios', '_str': _("Holds queue update") - } + }, + { + '_id': 'stage_marc_for_import', + '_str': _("Staged MARC records for import") + }, + { + '_id': 'marc_import_commit_batch', + '_str': _("Import MARC records") + }, + { + '_id': 'marc_import_revert_batch', + '_str': _("Revert import MARC records") + }, ]; function get_job_type (job_type) { @@ -267,6 +231,12 @@ } $(document).ready(function() { + [% IF op == 'view' %] + $("#job_status_description").html( get_job_status("[% job.status | html %]") ); + $("#job_type_description").html( get_job_type("[% job.type | html %]") ); + $("fieldset.rows").show(); + [% END %] + let additional_filters = { started_on: function(){ let now = new Date(); -- 2.39.5