Browse Source

choose year based on which case logs are downloaded

pull/842/head
Kat 3 years ago
parent
commit
edb4c7414d
  1. 5
      app/models/case_log.rb

5
app/models/case_log.rb

@ -480,7 +480,10 @@ class CaseLog < ApplicationRecord
def self.order_csv_attributes(initial_attributes) def self.order_csv_attributes(initial_attributes)
attributes = initial_attributes.clone attributes = initial_attributes.clone
ordered_default_form_questions = move_checkbox_answer_options(FormHandler.instance.forms.first.second.questions) downloaded_form_years = all.map(&:collection_start_year).uniq.compact
downloaded_form_fields = if downloaded_form_years.count == 1 && downloaded_form_years[0].present? ? FormHandler.instance.get_form("#{downloaded_form_years[0]}_#{downloaded_form_years[0] + 1}").questions : FormHandler.instance.forms.first.second.questions
ordered_default_form_questions = move_checkbox_answer_options(downloaded_form_fields)
attributes = (ordered_default_form_questions & attributes) + (attributes - ordered_default_form_questions) attributes = (ordered_default_form_questions & attributes) + (attributes - ordered_default_form_questions)
attributes = move_metadata_fields_to_front(attributes) attributes = move_metadata_fields_to_front(attributes)

Loading…
Cancel
Save