render custom_fields in rabl views

eagerly load custom field translations
pull/523/head
Markus Kahl 11 years ago
parent 5737a13a27
commit 26b8c50835
  1. 3
      app/controllers/api/v2/planning_elements_controller.rb
  2. 3
      app/controllers/api/v2/projects_controller.rb
  3. 3
      app/views/api/v2/planning_elements/_planning_element.api.rabl
  4. 3
      app/views/api/v2/projects/_project.api.rabl

@ -80,7 +80,8 @@ module Api
end
def show
@planning_element = @project.work_packages.find(params[:id])
@planning_element = @project.work_packages.find params[:id],
:include => [{:custom_values => [{:custom_field => :translations}]}]
respond_to do |format|
format.api

@ -80,7 +80,8 @@ module Api
protected
def find_project
@project = Project.find(params[:id])
@project = Project.find params[:id],
:include => [{:custom_values => [{:custom_field => :translations}]}]
end
def build_associations

@ -75,6 +75,9 @@ node :assigned_to, if: lambda{|pe| pe.assigned_to.present?} do |pe|
end
end
node :custom_fields do
partial "api/v2/custom_fields/values", :object => (locals[:object] || @planning_element).custom_values
end
node :journals, if: lambda{|pe| include_journals?} do |pe|
pe.journals.map do |journal|

@ -82,3 +82,6 @@ node :parent, if: lambda{|project| visible_parent_project(project).present?} do
{ id: parent.id, name: parent.name, identifier: parent.identifier }
end
node :custom_fields do
partial "api/v2/custom_fields/values", :object => (locals[:object] || @project).custom_values
end

Loading…
Cancel
Save