99
1010 active_admin_paranoia
1111
12- # To include the deleted operator document annexes
13- scope_to do
14- Class . new do
15- def self . operator_document_annexes
16- OperatorDocumentAnnex . unscoped . distinct
17- end
18- end
19- end
20-
2112 controller do
2213 def scoped_collection
2314 end_of_association_chain . includes ( [ :user , annex_documents : [ documentable : [ :operator , required_operator_document : :translations ] ] ] )
@@ -45,11 +36,7 @@ def scoped_collection
4536 :attachment , :uploaded_by
4637
4738 csv do
48- column I18n . t ( "active_admin.required_operator_document_page.exists" ) do |annex |
49- annex . deleted_at . nil?
50- end
5139 column :status
52-
5340 column I18n . t ( "active_admin.operator_page.documents" ) do |annex |
5441 documents = [ ]
5542 annex . annex_documents . each do |ad |
@@ -60,7 +47,6 @@ def scoped_collection
6047 column I18n . t ( "active_admin.dashboard_page.columns.operator" ) do |annex |
6148 annex . annex_documents . first &.documentable &.operator &.name
6249 end
63-
6450 column I18n . t ( "activerecord.models.user" ) do |annex |
6551 annex . user &.name
6652 end
@@ -71,9 +57,6 @@ def scoped_collection
7157 end
7258
7359 index do
74- bool_column I18n . t ( "active_admin.required_operator_document_page.exists" ) do |od |
75- od . deleted_at . nil?
76- end
7760 tag_column :status
7861 column I18n . t ( "active_admin.operator_page.documents" ) do |od |
7962 next if od . annex_document . nil?
@@ -93,17 +76,24 @@ def scoped_collection
9376 fmu = doc . documentable_type . constantize . unscoped . find ( doc . documentable_id ) . fmu
9477 link_to ( fmu . name , admin_fmu_path ( fmu . id ) ) if fmu
9578 end
96-
9779 column :user , sortable : "users.name"
9880 column :expire_date
9981 column :start_date
10082 column :created_at
10183 column :uploaded_by
10284 column :attachment do |o |
103- link_to o . attachment &.identifier , o . attachment &.url
85+ if o . attachment &.identifier . present?
86+ name = o . attachment . identifier
87+ name += " (Missing file)" if o . attachment . blank?
88+ link_to name , o . attachment . url
89+ end
90+ end
91+ if params [ :scope ] == "archived"
92+ column :deleted_at
93+ else
94+ column ( I18n . t ( "active_admin.approve" ) ) { |annex | link_to I18n . t ( "active_admin.approve" ) , approve_admin_operator_document_annex_path ( annex ) , method : :put }
95+ column ( I18n . t ( "active_admin.reject" ) ) { |annex | link_to I18n . t ( "active_admin.reject" ) , reject_admin_operator_document_annex_path ( annex ) , method : :put }
10496 end
105- column ( I18n . t ( "active_admin.approve" ) ) { |annex | link_to I18n . t ( "active_admin.approve" ) , approve_admin_operator_document_annex_path ( annex ) , method : :put }
106- column ( I18n . t ( "active_admin.reject" ) ) { |annex | link_to I18n . t ( "active_admin.reject" ) , reject_admin_operator_document_annex_path ( annex ) , method : :put }
10797 actions
10898 end
10999
0 commit comments