Skip to content

Commit 30ba5cb

Browse files
authored
Merge pull request #582 from wri/feature/pending-non-applicable
Distinguish document pending and pending non applicable in the Backoffice
2 parents d67adbc + d4ef693 commit 30ba5cb

9 files changed

Lines changed: 33 additions & 9 deletions

File tree

app/admin/operator_document.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def perform_qc_params
152152
index do
153153
selectable_column
154154
column :public
155-
tag_column :status
155+
tag_column :status, &:detailed_status
156156
column :id
157157
column I18n.t("activerecord.models.country.one") do |od|
158158
od.required_operator_document.country
@@ -196,6 +196,8 @@ def perform_qc_params
196196
column I18n.t("active_admin.operator_documents_page.attachment") do |od|
197197
if od&.document_file&.attachment
198198
link_to od.document_file.attachment.identifier, od.document_file.attachment.url
199+
elsif od.reason.present?
200+
I18n.t("active_admin.operator_documents_page.non_applicable")
199201
end
200202
end
201203
column I18n.t("active_admin.operator_documents_page.annexes") do |od|
@@ -271,15 +273,19 @@ def perform_qc_params
271273
show title: proc { "#{resource.operator.name} - #{resource.required_operator_document.name}" } do
272274
attributes_table do
273275
row :public
274-
tag_row :status
276+
tag_row :status, &:detailed_status
275277
row(I18n.t("active_admin.operator_documents_page.reason_label"), &:reason) if resource.reason.present?
276278
row :admin_comment if resource.admin_comment.present?
277279
row :required_operator_document
278280
row :operator
279281
row :fmu, unless: resource.is_a?(OperatorDocumentCountry)
280282
row :uploaded_by
281283
row I18n.t("active_admin.operator_documents_page.attachment") do |r|
282-
link_to r.document_file&.attachment&.identifier, r.document_file&.attachment&.url, target: "_blank", rel: "noopener" if r.document_file&.attachment&.present?
284+
if r.document_file&.attachment&.present?
285+
link_to r.document_file&.attachment&.identifier, r.document_file&.attachment&.url, target: "_blank", rel: "noopener"
286+
elsif r.reason.present?
287+
I18n.t("active_admin.operator_documents_page.non_applicable")
288+
end
283289
end
284290
row :start_date
285291
row :expire_date

app/admin/operator_document_history.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
index do
6767
column :public
68-
tag_column :status
68+
tag_column :status, &:detailed_status
6969
column :id
7070
column :admin_comment
7171
column :operator_document do |od|
@@ -171,7 +171,7 @@
171171
# link_to history.id, admin_operator_document_history_path(history)
172172
link_to history.operator_document_updated_at.to_datetime.to_fs(:long), admin_operator_document_history_path(history)
173173
end
174-
tag_column :status
174+
tag_column :status, &:detailed_status
175175
end
176176
end
177177
end
@@ -186,7 +186,7 @@
186186
end
187187
end
188188
row :public
189-
tag_row :status
189+
tag_row :status, &:detailed_status
190190
row(I18n.t("active_admin.operator_documents_page.reason_label"), &:reason) if resource.reason.present?
191191
row :admin_comment if resource.admin_comment.present?
192192
row :required_operator_document

app/assets/javascripts/quality_controls.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
$(document).ready(function() {
2-
updateQCFields();
3-
$('input[name="quality_control[decision]"]').on('change', function(){
2+
if ($('input[name="quality_control[decision]"]').length) {
43
updateQCFields();
5-
})
4+
$('input[name="quality_control[decision]"]').on('change', function(){
5+
updateQCFields();
6+
})
7+
}
68
})
79

810
function updateQCFields() {

app/assets/stylesheets/active_admin.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ $to-be-reviewed: #99AA99;
5959
&.rejected { background: $rejected-color; }
6060
&.approved { background: $approved-color; }
6161
&.doc_pending { background: $pending-color; }
62+
&.doc_pending_non_applicable { background: $pending-color; }
6263
&.doc_invalid { background: $rejected-color; }
6364
&.doc_valid { background: $approved-color; }
6465
&.doc_expired { background: $expired-color; }

app/models/operator_document.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ def name_with_fmu
155155
"#{required_operator_document.name} (#{fmu.name})"
156156
end
157157

158+
def detailed_status
159+
return "doc_pending_non_applicable" if doc_pending? && reason.present?
160+
161+
status
162+
end
163+
158164
def destroy # rubocop:disable Rails/ActiveRecordOverride
159165
# It only allows for (soft) deletion of the operator documents when:
160166
# 1 - The Operator was deleted (destroyed_by_association)

app/models/operator_document_history.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ def needs_authorization_before_downloading?
6464
true
6565
end
6666

67+
def detailed_status
68+
return "doc_pending_non_applicable" if doc_pending? && reason.present?
69+
70+
status
71+
end
72+
6773
# Returns the collection of OperatorDocumentHistory for a given operator at a point in time
6874
#
6975
# @param String operator_id The operator id

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ en:
376376
operator_document_id: 'Operator Document ID'
377377
with_deleted: 'With deleted'
378378
reason_label: "Reason for putting document as “non applicable”"
379+
non_applicable: "Non applicable"
379380
operator_document_annexes_page:
380381
approved: 'Annex approved'
381382
not_approved: 'Annex could not be approved'

config/locales/es.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ es:
390390
operator_document_id: 'ID de Documento del Operador'
391391
with_deleted: 'Con eliminados'
392392
reason_label: "Razón para marcar documento como \"no aplicable\""
393+
non_applicable: "No aplicable"
393394
operator_document_annexes_page:
394395
approved: 'Anexo aprobado'
395396
not_approved: 'No se pudo aprobar el anexo'

config/locales/fr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ fr:
383383
operator_document_id: "ID de document de l'opérateur"
384384
with_deleted: 'Avec supprimé'
385385
reason_label: "Le document a été mis comme non applicable avec l'explication suivante"
386+
non_applicable: "Non applicable"
386387
operator_document_annexes_page:
387388
approved: 'Annexe approuvée'
388389
not_approved: "L'annexe n'a pas pu être approuvée"

0 commit comments

Comments
 (0)