<%= edit_questionnaire_title %>
<% unless template? questionnaire.questionnaire_for %>
<% if allowed_to? :preview, :questionnaire %>
<%= link_to t(".preview"), public_url, class: "button tiny button--simple", target: :_blank %>
<% end %>
<% if questionnaire.answers.any? %>
<%= export_dropdown(current_component, questionnaire.id) if allowed_to? :export_answers, :questionnaire %>
<% if allowed_to? :show, :questionnaire_answers %>
<%= link_to t("actions.show", scope: "decidim.forms.admin.questionnaires"), questionnaire_participants_url, class: "button tiny button--title new" %>
<% end %>
<% else %>
<% end %>
<% end %>
<%= form.translated :text_field, :title, autofocus: true %>
<%= form.translated :editor, :description, toolbar: :full, lines: 30, label: t("models.components.description", scope: "decidim.forms.admin") %>
<%= form.translated :editor, :tos, toolbar: :content, lines: 10, label: t("models.components.tos", scope: "decidim.forms.admin") %>
<% if questionnaire.questions_editable? %>
<% if questionnaire.answers.any? && !questionnaire.published? %>
<%= t(".unpublished_warning") %>
<% end %>
<%= fields_for "questionnaire[questions][#{blank_question.to_param}]", blank_question do |question_form| %>
<%= render "decidim/forms/admin/questionnaires/answer_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "answer-option-template-dummy" %>
<%= render "decidim/forms/admin/questionnaires/display_condition_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "display-condition-template-dummy" %>
<%= render "decidim/forms/admin/questionnaires/matrix_row_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "matrix-row-template-dummy" %>
<% end %>
<% else %>
<%= t(".already_answered_warning") %>
<% end %>
<% @form.questions.each_with_index do |question, index| %>
<%= fields_for "questionnaire[questions][]", question do |question_form| %>
<% if question.separator? %>
<%= render "decidim/forms/admin/questionnaires/separator",
form: question_form,
id: tabs_id_for_question(question),
editable: questionnaire.questions_editable? %>
<% elsif question.title_and_description? %>
<%= render "decidim/forms/admin/questionnaires/title_and_description",
form: question_form,
id: tabs_id_for_question(question),
editable: questionnaire.questions_editable? %>
<% else %>
<%= render "decidim/forms/admin/questionnaires/question",
form: question_form,
id: tabs_id_for_question(question),
editable: questionnaire.questions_editable?,
display_condition_template_selector: "#display-condition-template-#{index}",
answer_option_template_selector: "#answer-option-template-#{index}",
matrix_row_template_selector: "#matrix-row-template-#{index}" %>
<%= render "decidim/forms/admin/questionnaires/display_condition_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "display-condition-template-#{index}" %>
<%= render "decidim/forms/admin/questionnaires/answer_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "answer-option-template-#{index}" %>
<%= render "decidim/forms/admin/questionnaires/matrix_row_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "matrix-row-template-#{index}" %>
<% end %>
<% end %>
<% end %>
<% if questionnaire.questions_editable? %>
<% end %>
<%= javascript_pack_tag "decidim_forms_admin", defer: false %>
<% if questionnaire.questions_editable? %>
<% end %>