Newer
Older
dmpopidor / app / views / api / v0 / guidance_groups / index.json.jbuilder
@DigitalCurationCentre DigitalCurationCentre on 27 Jun 2016 649 bytes Master (#7)
# builds a json response to api query for a list of guidance groups
json.prettify!

json.guidance_group @all_viewable_groups do |guidance_group|
  json.name       guidance_group.name
  json.id         guidance_group.id

  # for each template associated with the guidance group, list the template name
  @templates = guidance_group.dmptemplates
  # if the template is empty, instead use all avalable templates
  if @templates.empty?
    @templates = Dmptemplate.all
  end
  json.templates @templates do |template|
    json.title    template.title
  end
  json.optional   guidance_group.optional_subset
  json.updated    guidance_group.updated_at
end