<% if questionnaire.questions_editable? %>
<% if questionnaire.answers.any? && !questionnaire.published? %>
<%= cell("decidim/announcement", t(".unpublished_warning"), callout_class: "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 %>
<%= cell("decidim/announcement", t(".already_answered_warning"), callout_class: "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 %>
<%= append_javascript_pack_tag "decidim_forms_admin" %>
<% if questionnaire.questions_editable? %>
<% end %>