Created
October 27, 2012 01:39
-
-
Save mverzilli/3962611 to your computer and use it in GitHub Desktop.
Compute columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@columns = [] | |
ConditionCodeProperty.select('property, format, field_name').select('GROUP_CONCAT(condition_code) as conditions').group('property, format, field_name').where(condition_code: current_user.condition_codes).each do |condition_code_property| | |
unless Result.is_common(condition_code_property.property) | |
common = Result.is_extended_common(condition_code_property.property) | |
column = { | |
property_name: condition_code_property.property, | |
value_accessor: condition_code_property.property, | |
human_name: Result.human_name_for(condition_code_property.property), | |
field_name: condition_code_property.field_name, | |
extended: !common, | |
selected: common, | |
condition_codes: JSON.parse("[#{condition_code_property.conditions}]"), | |
format: condition_code_property.format, | |
aliases: [] | |
} | |
@columns.push column | |
end | |
end | |
Result::ExtendedCommonColumns.values.each do |property| | |
unless @columns.any? {|column| column[:property_name] == property } | |
column = { | |
property_name: property, | |
value_accessor: property, | |
human_name: Result.human_name_for(property), | |
extended: false, | |
selected: true, | |
aliases: [] | |
} | |
@columns.push column | |
end | |
end | |
Result::CommonColumns.each do |property| | |
column = { | |
property_name: property, | |
value_accessor: property, | |
human_name: Result.human_name_for(property), | |
extended: false, | |
selected: true, | |
aliases: [] | |
} | |
@columns.push column | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment