diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 3fbb1ed..dcb5af5 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -219,7 +219,7 @@ class CustomField < ActiveRecord::Base # to move in project_custom_field def self.for_all - where(:is_for_all => true).order('position').to_a + RequestStore.store["#{self.class.name}_for_all"] ||= where(:is_for_all => true).order('position').to_a end def type_name diff --git a/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_entity_custom_attribute.rb b/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_entity_custom_attribute.rb index e41e5d5..fe1f595 100644 --- a/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_entity_custom_attribute.rb +++ b/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_entity_custom_attribute.rb @@ -20,7 +20,7 @@ class EasyEntityCustomAttribute < EasyEntityAttribute return nil if entity.nil? if (entity.respond_to?(:project) && @custom_field.visible_by?(entity.project, User.current)) || !entity.respond_to?(:project) - cv = entity.custom_values.enabled.select {|v| v.custom_field_id == @custom_field.id} + cv = entity.custom_values.select {|v| v.custom_field_id == @custom_field.id} cv.size > 1 ? cv.sort {|a,b| a.value.to_s <=> b.value.to_s} : cv.first else nil diff --git a/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_project_query.rb b/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_project_query.rb index 3c474c8..4ecccb2 100644 --- a/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_project_query.rb +++ b/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_project_query.rb @@ -15,7 +15,7 @@ class EasyProjectQuery < EasyQuery def query_after_initialize super - self.additional_statement = Project.allowed_to_condition(User.current, :view_project) + # self.additional_statement = Project.allowed_to_condition(User.current, :view_project) self.display_filter_sort_on_edit = false end @@ -96,7 +96,7 @@ class EasyProjectQuery < EasyQuery EasyQueryColumn.new(:root), EasyQueryColumn.new(:description, :sortable => "#{Project.table_name}.description"), EasyQueryColumn.new(:status), - EasyQueryColumn.new(:author, :groupable => true, :sortable => lambda { User.fields_for_order_statement('authors') }), + EasyQueryColumn.new(:author, :groupable => true, :sortable => lambda { User.fields_for_order_statement('authors') }, preload: [:author]), EasyQueryColumn.new(:users, :caption => :field_member), EasyQueryColumn.new(:start_date), EasyQueryColumn.new(:due_date), @@ -168,6 +168,12 @@ class EasyProjectQuery < EasyQuery [['lft', 'asc']] end + def default_find_preload + preloads = [:parent, :enabled_modules] + preloads << [:project_custom_fields] if has_custom_field_column? + preloads + end + def sortable_columns {'lft' => "#{Project.table_name}.lft"}.merge(super) end @@ -192,7 +198,7 @@ class EasyProjectQuery < EasyQuery ) ).join_sources - root_info = merge_scope(Project, options) + root_info = merge_scope(Project.visible, options) .select('projects.id AS root_id, Count(children.id) AS children_count') .joins(join_sources) .where("( (#{statement}) OR (#{children_statement}) ) AND projects.parent_id IS NULL") diff --git a/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_query.rb b/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_query.rb index e7753cb..e467ccf 100644 --- a/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_query.rb +++ b/plugins/easyproject/easy_plugins/easy_extensions/app/models/easy_queries/easy_query.rb @@ -1231,7 +1231,7 @@ class EasyQuery < ActiveRecord::Base end def has_custom_field_column? - columns.any? { |column| column.is_a? QueryCustomFieldColumn } + columns.any? { |column| column.is_a? EasyQueryCustomFieldColumn } end def has_default_columns?