Skip to content

Commit

Permalink
Use Sample Attribute functions instead of conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed May 2, 2024
1 parent e02636e commit 991f687
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/helpers/dynamic_table_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def dt_cols(sample_type)
attribute = { title: a.title, name: sample_type.id.to_s, required: a.required, description: a.description,
is_title: a.is_title }
attribute.merge!({ cv_id: a.sample_controlled_vocab_id }) unless a.sample_controlled_vocab_id.blank?
is_seek_sample = a.sample_attribute_type.base_type == Seek::Samples::BaseType::SEEK_SAMPLE
is_seek_multi_sample = a.sample_attribute_type.base_type == Seek::Samples::BaseType::SEEK_SAMPLE_MULTI
is_cv_list = a.sample_attribute_type.base_type == Seek::Samples::BaseType::CV_LIST
is_seek_sample = a.sample_attribute_type.seek_sample?
is_seek_multi_sample = a.sample_attribute_type.seek_sample_multi?
is_cv_list = a.sample_attribute_type.seek_cv_list?
cv_allows_free_text = a.allow_cv_free_text
attribute.merge!({ multi_link: true, linked_sample_type: a.linked_sample_type_id }) if is_seek_multi_sample
attribute.merge!({ multi_link: false, linked_sample_type: a.linked_sample_type_id }) if is_seek_sample
Expand Down Expand Up @@ -158,12 +158,14 @@ def dt_cumulative_cols(sample_types)
s.sample_attributes.map do |a|
attribute = { title: a.title, name: s.id.to_s, required: a.required, description: a.description,
is_title: a.is_title }
condition = a.sample_attribute_type.base_type == Seek::Samples::BaseType::SEEK_SAMPLE_MULTI
is_cv_list = a.sample_attribute_type.base_type == Seek::Samples::BaseType::CV_LIST
attribute.merge!({ multi_link: true, linked_sample_type: a.linked_sample_type.id }) if condition
is_seek_sample_multi = a.sample_attribute_type.seek_sample_multi?
is_seek_sample = a.sample_attribute_type.seek_sample?
is_cv_list = a.sample_attribute_type.seek_cv_list?
attribute.merge!({ multi_link: true, linked_sample_type: a.linked_sample_type.id }) if is_seek_sample_multi
attribute.merge!({ multi_link: false, linked_sample_type: a.linked_sample_type.id }) if is_seek_sample
attribute.merge!({ is_cv_list: true }) if is_cv_list
attribute
end.unshift({ title: 'id' }, {title: 'uuid'})
end.unshift({ title: 'id' }, { title: 'uuid' })
end
end
end

0 comments on commit 991f687

Please sign in to comment.