class Decidim::Meetings::Admin::CreateAgenda

def create_agenda_item(form_agenda_item)

def create_agenda_item(form_agenda_item)
  agenda_item_attributes = {
    title: form_agenda_item.title,
    description: form_agenda_item.description,
    position: form_agenda_item.position,
    duration: form_agenda_item.duration,
    parent_id: form_agenda_item.parent_id,
    agenda: @agenda
  }
  create_nested_model(form_agenda_item, agenda_item_attributes, @form.agenda_items) do |agenda_item|
    form_agenda_item.agenda_item_children.each do |form_agenda_item_child|
      agenda_item_child_attributes = {
        title: form_agenda_item_child.title,
        description: form_agenda_item_child.description,
        position: form_agenda_item_child.position,
        duration: form_agenda_item_child.duration,
        parent_id: agenda_item.id,
        agenda: @agenda
      }
      create_nested_model(form_agenda_item_child, agenda_item_child_attributes, agenda_item.agenda_item_children)
    end
  end
end