Project

General

Profile

« Previous | Next » 

Revision 019a239c

Added by Shlomi Zadok over 8 years ago

Fixes #13386 - Adds taxonomy parameters objects

View differences:

app/models/taxonomy.rb
def parent_params(include_source = false)
hash = {}
ids = ancestor_ids
# need to pull out the locations to ensure they are sorted first,
# otherwise we might be overwriting the hash in the wrong order.
elements = self.class.sort_by_ancestry(self.class.includes("#{type.downcase}_parameters".to_sym).find(ids))
elements = parents_with_params
elements.each do |el|
el.send("#{type.downcase}_parameters".to_sym).each {|p| hash[p.name] = include_source ? {:value => p.value, :source => sti_name, :safe_value => p.safe_value, :source_name => el.title} : p.value }
end
......
hash
end
def parents_with_params
self.class.sort_by_ancestry(self.class.includes("#{type.downcase}_parameters".to_sym).find(ancestor_ids))
end
def taxonomy_inherited_params_objects
# need to pull out the locations to ensure they are sorted first,
# otherwise we might be overwriting the hash in the wrong order.
parents = parents_with_params
parents_parameters = []
parents.each do |parent|
parents_parameters << parent.send("#{parent.type.downcase}_parameters".to_sym)
end
parents_parameters
end
def params_objects
(self.send("#{type.downcase}_parameters".to_sym) + taxonomy_inherited_params_objects.to_a.reverse!).uniq {|param| param.name}
end
private
delegate :need_to_be_selected_ids, :selected_ids, :used_and_selected_ids, :mismatches, :missing_ids, :check_for_orphans,

Also available in: Unified diff