diff --git a/app/admin/operator_document.rb b/app/admin/operator_document.rb index 7fb341cb..6e75fc58 100644 --- a/app/admin/operator_document.rb +++ b/app/admin/operator_document.rb @@ -152,7 +152,7 @@ def perform_qc_params index do selectable_column column :public - tag_column :status + tag_column :status, &:detailed_status column :id column I18n.t("activerecord.models.country.one") do |od| od.required_operator_document.country @@ -196,6 +196,8 @@ def perform_qc_params column I18n.t("active_admin.operator_documents_page.attachment") do |od| if od&.document_file&.attachment link_to od.document_file.attachment.identifier, od.document_file.attachment.url + elsif od.reason.present? + I18n.t("active_admin.operator_documents_page.non_applicable") end end column I18n.t("active_admin.operator_documents_page.annexes") do |od| @@ -271,7 +273,7 @@ def perform_qc_params show title: proc { "#{resource.operator.name} - #{resource.required_operator_document.name}" } do attributes_table do row :public - tag_row :status + tag_row :status, &:detailed_status row(I18n.t("active_admin.operator_documents_page.reason_label"), &:reason) if resource.reason.present? row :admin_comment if resource.admin_comment.present? row :required_operator_document @@ -279,7 +281,11 @@ def perform_qc_params row :fmu, unless: resource.is_a?(OperatorDocumentCountry) row :uploaded_by row I18n.t("active_admin.operator_documents_page.attachment") do |r| - link_to r.document_file&.attachment&.identifier, r.document_file&.attachment&.url, target: "_blank", rel: "noopener" if r.document_file&.attachment&.present? + if r.document_file&.attachment&.present? + link_to r.document_file&.attachment&.identifier, r.document_file&.attachment&.url, target: "_blank", rel: "noopener" + elsif r.reason.present? + I18n.t("active_admin.operator_documents_page.non_applicable") + end end row :start_date row :expire_date diff --git a/app/admin/operator_document_history.rb b/app/admin/operator_document_history.rb index e43a2c14..c711edfd 100644 --- a/app/admin/operator_document_history.rb +++ b/app/admin/operator_document_history.rb @@ -65,7 +65,7 @@ index do column :public - tag_column :status + tag_column :status, &:detailed_status column :id column :admin_comment column :operator_document do |od| @@ -171,7 +171,7 @@ # link_to history.id, admin_operator_document_history_path(history) link_to history.operator_document_updated_at.to_datetime.to_fs(:long), admin_operator_document_history_path(history) end - tag_column :status + tag_column :status, &:detailed_status end end end @@ -186,7 +186,7 @@ end end row :public - tag_row :status + tag_row :status, &:detailed_status row(I18n.t("active_admin.operator_documents_page.reason_label"), &:reason) if resource.reason.present? row :admin_comment if resource.admin_comment.present? row :required_operator_document diff --git a/app/assets/javascripts/quality_controls.js b/app/assets/javascripts/quality_controls.js index f768c98b..611073ea 100644 --- a/app/assets/javascripts/quality_controls.js +++ b/app/assets/javascripts/quality_controls.js @@ -1,8 +1,10 @@ $(document).ready(function() { - updateQCFields(); - $('input[name="quality_control[decision]"]').on('change', function(){ + if ($('input[name="quality_control[decision]"]').length) { updateQCFields(); - }) + $('input[name="quality_control[decision]"]').on('change', function(){ + updateQCFields(); + }) + } }) function updateQCFields() { diff --git a/app/assets/stylesheets/active_admin.scss b/app/assets/stylesheets/active_admin.scss index 0a157e3e..35b633d1 100644 --- a/app/assets/stylesheets/active_admin.scss +++ b/app/assets/stylesheets/active_admin.scss @@ -59,6 +59,7 @@ $to-be-reviewed: #99AA99; &.rejected { background: $rejected-color; } &.approved { background: $approved-color; } &.doc_pending { background: $pending-color; } + &.doc_pending_non_applicable { background: $pending-color; } &.doc_invalid { background: $rejected-color; } &.doc_valid { background: $approved-color; } &.doc_expired { background: $expired-color; } diff --git a/app/models/operator_document.rb b/app/models/operator_document.rb index bcac5461..0df03f39 100644 --- a/app/models/operator_document.rb +++ b/app/models/operator_document.rb @@ -155,6 +155,12 @@ def name_with_fmu "#{required_operator_document.name} (#{fmu.name})" end + def detailed_status + return "doc_pending_non_applicable" if doc_pending? && reason.present? + + status + end + def destroy # rubocop:disable Rails/ActiveRecordOverride # It only allows for (soft) deletion of the operator documents when: # 1 - The Operator was deleted (destroyed_by_association) diff --git a/app/models/operator_document_history.rb b/app/models/operator_document_history.rb index c89b0dab..5ec76944 100644 --- a/app/models/operator_document_history.rb +++ b/app/models/operator_document_history.rb @@ -64,6 +64,12 @@ def needs_authorization_before_downloading? true end + def detailed_status + return "doc_pending_non_applicable" if doc_pending? && reason.present? + + status + end + # Returns the collection of OperatorDocumentHistory for a given operator at a point in time # # @param String operator_id The operator id diff --git a/config/locales/en.yml b/config/locales/en.yml index e735474f..6e581f9a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -376,6 +376,7 @@ en: operator_document_id: 'Operator Document ID' with_deleted: 'With deleted' reason_label: "Reason for putting document as “non applicable”" + non_applicable: "Non applicable" operator_document_annexes_page: approved: 'Annex approved' not_approved: 'Annex could not be approved' diff --git a/config/locales/es.yml b/config/locales/es.yml index 56d5e779..e2b5d68c 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -390,6 +390,7 @@ es: operator_document_id: 'ID de Documento del Operador' with_deleted: 'Con eliminados' reason_label: "Razón para marcar documento como \"no aplicable\"" + non_applicable: "No aplicable" operator_document_annexes_page: approved: 'Anexo aprobado' not_approved: 'No se pudo aprobar el anexo' diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 36dd99f4..e30b723a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -383,6 +383,7 @@ fr: operator_document_id: "ID de document de l'opérateur" with_deleted: 'Avec supprimé' reason_label: "Le document a été mis comme non applicable avec l'explication suivante" + non_applicable: "Non applicable" operator_document_annexes_page: approved: 'Annexe approuvée' not_approved: "L'annexe n'a pas pu être approuvée"