decidim-templates 0.30.3 → 0.31.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/app/commands/decidim/templates/admin/questionnaire_copier.rb +13 -12
 - data/app/controllers/decidim/templates/admin/block_user_templates_controller.rb +2 -2
 - data/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb +2 -2
 - data/app/controllers/decidim/templates/admin/questionnaire_templates_controller.rb +2 -2
 - data/app/packs/entrypoints/decidim_templates.scss +1 -1
 - data/app/packs/src/decidim/templates/admin/block_user_template_chooser.js +1 -1
 - data/app/packs/src/decidim/templates/admin/choose_template.js +59 -5
 - data/app/packs/src/decidim/templates/admin/proposal_answer_template_chooser.js +1 -1
 - data/app/packs/stylesheets/decidim/templates/templates.scss +7 -3
 - data/app/views/decidim/templates/admin/block_user_templates/index.html.erb +48 -14
 - data/app/views/decidim/templates/admin/proposal_answer_templates/index.html.erb +53 -16
 - data/app/views/decidim/templates/admin/questionnaire_templates/_choose.html.erb +33 -14
 - data/app/views/decidim/templates/admin/questionnaire_templates/_preview.html.erb +15 -15
 - data/app/views/decidim/templates/admin/questionnaire_templates/index.html.erb +51 -16
 - data/config/assets.rb +2 -2
 - data/config/locales/ar.yml +0 -1
 - data/config/locales/bg.yml +0 -3
 - data/config/locales/ca-IT.yml +6 -4
 - data/config/locales/ca.yml +6 -4
 - data/config/locales/cs.yml +6 -4
 - data/config/locales/de.yml +6 -4
 - data/config/locales/en.yml +6 -4
 - data/config/locales/es-MX.yml +6 -4
 - data/config/locales/es-PY.yml +6 -4
 - data/config/locales/es.yml +6 -4
 - data/config/locales/eu.yml +6 -4
 - data/config/locales/fi-plain.yml +6 -4
 - data/config/locales/fi.yml +6 -4
 - data/config/locales/fr-CA.yml +6 -4
 - data/config/locales/fr.yml +6 -4
 - data/config/locales/ga-IE.yml +0 -2
 - data/config/locales/gl.yml +0 -3
 - data/config/locales/hu.yml +0 -3
 - data/config/locales/it.yml +0 -3
 - data/config/locales/ja.yml +6 -4
 - data/config/locales/lt.yml +0 -3
 - data/config/locales/nl.yml +0 -3
 - data/config/locales/no.yml +0 -3
 - data/config/locales/pl.yml +0 -3
 - data/config/locales/pt-BR.yml +0 -3
 - data/config/locales/pt.yml +0 -3
 - data/config/locales/ro-RO.yml +6 -3
 - data/config/locales/sv.yml +0 -3
 - data/config/locales/tr-TR.yml +0 -3
 - data/config/locales/zh-CN.yml +0 -3
 - data/config/locales/zh-TW.yml +0 -3
 - data/db/seeds.rb +4 -4
 - data/lib/decidim/templates/admin_engine.rb +1 -1
 - data/lib/decidim/templates/engine.rb +1 -1
 - data/lib/decidim/templates/test/shared_examples/copies_all_questionnaire_contents_examples.rb +6 -6
 - data/lib/decidim/templates/test/shared_examples/uses_questionnaire_templates.rb +9 -8
 - data/lib/decidim/templates/version.rb +1 -1
 - metadata +15 -15
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fabe61a63b3f48ea3d46f16df01efcc3d396c222569e5cabeeab3250a739aa8d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 73df7ecbdeaac7c8ebd54ea897e7cbbb2d08af79202eb32a24999f79ddbed99b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5d3b6d8b08726ef8ad3b00417cfc2af3fb9f1cc963197a0b112dcdf227be5b2aa835f4a41f7f999fd9fc2e904b51000eb7dd29d20f400316fb64d103ea63b8bc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 16637aabd6f058599aa9bfbd83dbde92e26e05bd887953fc1c265fc6f76e782ea5cd048f6e1e1be3eb81cc6d3b14b31efb24eb0eb4955726c22c2e51d58a2c22
         
     | 
| 
         @@ -7,18 +7,18 @@ module Decidim 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  module QuestionnaireCopier
         
     | 
| 
       8 
8 
     | 
    
         
             
                    def copy_questionnaire_questions(original_questionnaire, new_questionnaire)
         
     | 
| 
       9 
9 
     | 
    
         
             
                      # start by copying the questions so that they already exist when cross referencing them in the conditions
         
     | 
| 
       10 
     | 
    
         
            -
                      original_questionnaire.reload.questions.includes(: 
     | 
| 
      
 10 
     | 
    
         
            +
                      original_questionnaire.reload.questions.includes(:response_options, :matrix_rows, :display_conditions)
         
     | 
| 
       11 
11 
     | 
    
         
             
                      original_questionnaire.questions.each do |original_question|
         
     | 
| 
       12 
12 
     | 
    
         
             
                        new_question = original_question.dup
         
     | 
| 
       13 
13 
     | 
    
         
             
                        new_question.questionnaire = new_questionnaire
         
     | 
| 
       14 
14 
     | 
    
         
             
                        new_question.assign_attributes(
         
     | 
| 
       15 
     | 
    
         
            -
                           
     | 
| 
      
 15 
     | 
    
         
            +
                          response_options_count: 0,
         
     | 
| 
       16 
16 
     | 
    
         
             
                          matrix_rows_count: 0,
         
     | 
| 
       17 
17 
     | 
    
         
             
                          display_conditions_count: 0,
         
     | 
| 
       18 
18 
     | 
    
         
             
                          display_conditions_for_other_questions_count: 0
         
     | 
| 
       19 
19 
     | 
    
         
             
                        )
         
     | 
| 
       20 
20 
     | 
    
         
             
                        new_question.save!
         
     | 
| 
       21 
     | 
    
         
            -
                         
     | 
| 
      
 21 
     | 
    
         
            +
                        copy_questionnaire_response_options(original_question, new_question)
         
     | 
| 
       22 
22 
     | 
    
         
             
                        copy_questionnaire_matrix_rows(original_question, new_question)
         
     | 
| 
       23 
23 
     | 
    
         
             
                      end
         
     | 
| 
       24 
24 
     | 
    
         
             
                      # once all questions are copied, copy display conditions
         
     | 
| 
         @@ -27,11 +27,11 @@ module Decidim 
     | 
|
| 
       27 
27 
     | 
    
         
             
                      end
         
     | 
| 
       28 
28 
     | 
    
         
             
                    end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
                    def  
     | 
| 
       31 
     | 
    
         
            -
                      original_question. 
     | 
| 
       32 
     | 
    
         
            -
                         
     | 
| 
       33 
     | 
    
         
            -
                         
     | 
| 
       34 
     | 
    
         
            -
                         
     | 
| 
      
 30 
     | 
    
         
            +
                    def copy_questionnaire_response_options(original_question, new_question)
         
     | 
| 
      
 31 
     | 
    
         
            +
                      original_question.response_options.each do |original_response_option|
         
     | 
| 
      
 32 
     | 
    
         
            +
                        new_response_option = original_response_option.dup
         
     | 
| 
      
 33 
     | 
    
         
            +
                        new_response_option.question = new_question
         
     | 
| 
      
 34 
     | 
    
         
            +
                        new_response_option.save!
         
     | 
| 
       35 
35 
     | 
    
         
             
                      end
         
     | 
| 
       36 
36 
     | 
    
         
             
                    end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
         @@ -51,8 +51,9 @@ module Decidim 
     | 
|
| 
       51 
51 
     | 
    
         
             
                        destination_question_to_be_checked = find_question_by_position(destination_question.questionnaire.questions, original_display_condition.condition_question.position)
         
     | 
| 
       52 
52 
     | 
    
         
             
                        new_display_condition.condition_question = destination_question_to_be_checked
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
                        if original_display_condition. 
     | 
| 
       55 
     | 
    
         
            -
                          new_display_condition. 
     | 
| 
      
 54 
     | 
    
         
            +
                        if original_display_condition.response_option
         
     | 
| 
      
 55 
     | 
    
         
            +
                          new_display_condition.response_option = find_response_option_by_body(destination_question_to_be_checked.response_options,
         
     | 
| 
      
 56 
     | 
    
         
            +
                                                                                               original_display_condition.response_option.body)
         
     | 
| 
       56 
57 
     | 
    
         
             
                        end
         
     | 
| 
       57 
58 
     | 
    
         
             
                        new_display_condition.save!
         
     | 
| 
       58 
59 
     | 
    
         
             
                        destination_question.display_conditions << new_display_condition
         
     | 
| 
         @@ -63,8 +64,8 @@ module Decidim 
     | 
|
| 
       63 
64 
     | 
    
         
             
                      questions.to_a.find { |q| q.position == position }
         
     | 
| 
       64 
65 
     | 
    
         
             
                    end
         
     | 
| 
       65 
66 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
                    def  
     | 
| 
       67 
     | 
    
         
            -
                       
     | 
| 
      
 67 
     | 
    
         
            +
                    def find_response_option_by_body(response_options, body)
         
     | 
| 
      
 68 
     | 
    
         
            +
                      response_options.to_a.find { |ao| ao.body == body }
         
     | 
| 
       68 
69 
     | 
    
         
             
                    end
         
     | 
| 
       69 
70 
     | 
    
         
             
                  end
         
     | 
| 
       70 
71 
     | 
    
         
             
                end
         
     | 
| 
         @@ -62,7 +62,7 @@ module Decidim 
     | 
|
| 
       62 
62 
     | 
    
         
             
                        on(:invalid) do |template|
         
     | 
| 
       63 
63 
     | 
    
         
             
                          @template = template
         
     | 
| 
       64 
64 
     | 
    
         
             
                          flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
         
     | 
| 
       65 
     | 
    
         
            -
                          render action: :edit
         
     | 
| 
      
 65 
     | 
    
         
            +
                          render action: :edit, status: :unprocessable_entity
         
     | 
| 
       66 
66 
     | 
    
         
             
                        end
         
     | 
| 
       67 
67 
     | 
    
         
             
                      end
         
     | 
| 
       68 
68 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -85,7 +85,7 @@ module Decidim 
     | 
|
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         
             
                        on(:invalid) do
         
     | 
| 
       87 
87 
     | 
    
         
             
                          flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
         
     | 
| 
       88 
     | 
    
         
            -
                          render :new
         
     | 
| 
      
 88 
     | 
    
         
            +
                          render :new, status: :unprocessable_entity
         
     | 
| 
       89 
89 
     | 
    
         
             
                        end
         
     | 
| 
       90 
90 
     | 
    
         
             
                      end
         
     | 
| 
       91 
91 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -39,7 +39,7 @@ module Decidim 
     | 
|
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                        on(:invalid) do
         
     | 
| 
       41 
41 
     | 
    
         
             
                          flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
         
     | 
| 
       42 
     | 
    
         
            -
                          render :new
         
     | 
| 
      
 42 
     | 
    
         
            +
                          render :new, status: :unprocessable_entity
         
     | 
| 
       43 
43 
     | 
    
         
             
                        end
         
     | 
| 
       44 
44 
     | 
    
         
             
                      end
         
     | 
| 
       45 
45 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -86,7 +86,7 @@ module Decidim 
     | 
|
| 
       86 
86 
     | 
    
         
             
                        on(:invalid) do |template|
         
     | 
| 
       87 
87 
     | 
    
         
             
                          @template = template
         
     | 
| 
       88 
88 
     | 
    
         
             
                          flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
         
     | 
| 
       89 
     | 
    
         
            -
                          render action: :edit
         
     | 
| 
      
 89 
     | 
    
         
            +
                          render action: :edit, status: :unprocessable_entity
         
     | 
| 
       90 
90 
     | 
    
         
             
                        end
         
     | 
| 
       91 
91 
     | 
    
         
             
                      end
         
     | 
| 
       92 
92 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -48,7 +48,7 @@ module Decidim 
     | 
|
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                        on(:invalid) do
         
     | 
| 
       50 
50 
     | 
    
         
             
                          flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
         
     | 
| 
       51 
     | 
    
         
            -
                          render :new
         
     | 
| 
      
 51 
     | 
    
         
            +
                          render :new, status: :unprocessable_entity
         
     | 
| 
       52 
52 
     | 
    
         
             
                        end
         
     | 
| 
       53 
53 
     | 
    
         
             
                      end
         
     | 
| 
       54 
54 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -87,7 +87,7 @@ module Decidim 
     | 
|
| 
       87 
87 
     | 
    
         
             
                        on(:invalid) do |template|
         
     | 
| 
       88 
88 
     | 
    
         
             
                          @template = template
         
     | 
| 
       89 
89 
     | 
    
         
             
                          flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
         
     | 
| 
       90 
     | 
    
         
            -
                          render action: :edit
         
     | 
| 
      
 90 
     | 
    
         
            +
                          render action: :edit, status: :unprocessable_entity
         
     | 
| 
       91 
91 
     | 
    
         
             
                        end
         
     | 
| 
       92 
92 
     | 
    
         
             
                      end
         
     | 
| 
       93 
93 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            @ 
     | 
| 
      
 1 
     | 
    
         
            +
            @use "stylesheets/decidim/templates/templates";
         
     | 
| 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            // Choose a Block User Message template, get it by AJAX and add the Template in the justification textarea
         
     | 
| 
       2 
     | 
    
         
            -
            document.addEventListener(" 
     | 
| 
      
 2 
     | 
    
         
            +
            document.addEventListener("turbo:load", () => {
         
     | 
| 
       3 
3 
     | 
    
         
             
              const blockTemplateChooser = document.getElementById("block_template_chooser");
         
     | 
| 
       4 
4 
     | 
    
         
             
              if (blockTemplateChooser) {
         
     | 
| 
       5 
5 
     | 
    
         
             
                blockTemplateChooser.addEventListener("change", () => {
         
     | 
| 
         @@ -1,13 +1,63 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import { datalistSelect } from "src/decidim/datalist_select";
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
              const  
     | 
| 
       5 
     | 
    
         
            -
              if (! 
     | 
| 
      
 3 
     | 
    
         
            +
            document.addEventListener("turbo:load", () => {
         
     | 
| 
      
 4 
     | 
    
         
            +
              const chooseTemplateForm = document.querySelector("[data-choose-questionnaire-templates]");
         
     | 
| 
      
 5 
     | 
    
         
            +
              if (!chooseTemplateForm) {
         
     | 
| 
       6 
6 
     | 
    
         
             
                return;
         
     | 
| 
       7 
7 
     | 
    
         
             
              }
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
              const chooseTemplateWrapper = document.querySelector("#choose-template");
         
     | 
| 
      
 10 
     | 
    
         
            +
              if (!chooseTemplateWrapper) {
         
     | 
| 
      
 11 
     | 
    
         
            +
                return;
         
     | 
| 
      
 12 
     | 
    
         
            +
              }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              const createNewFormButton = document.querySelector("[data-create-new-form-button]");
         
     | 
| 
      
 15 
     | 
    
         
            +
              const withTemplateButton = document.querySelector("[data-with-template-button]");
         
     | 
| 
      
 16 
     | 
    
         
            +
              const disabledContinueButton = document.querySelector("[data-disabled-button]");
         
     | 
| 
      
 17 
     | 
    
         
            +
              const questionnaireTemplatePreview = document.querySelector("[data-questionnaire-template-preview]");
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              const toggleElementsOnChange = () => {
         
     | 
| 
      
 20 
     | 
    
         
            +
                const radios = document.querySelectorAll("input[name='template']");
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                radios.forEach((radio) => {
         
     | 
| 
      
 23 
     | 
    
         
            +
                  radio.addEventListener("change", function() {
         
     | 
| 
      
 24 
     | 
    
         
            +
                    switch (radio.value) {
         
     | 
| 
      
 25 
     | 
    
         
            +
                    case "create_new_form":
         
     | 
| 
      
 26 
     | 
    
         
            +
                      disabledContinueButton.classList.add("!hidden");
         
     | 
| 
      
 27 
     | 
    
         
            +
                      withTemplateButton.classList.add("!hidden");
         
     | 
| 
      
 28 
     | 
    
         
            +
                      createNewFormButton.classList.remove("!hidden");
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                      chooseTemplateWrapper.classList.add("hidden");
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                      questionnaireTemplatePreview.classList.add("hidden");
         
     | 
| 
      
 33 
     | 
    
         
            +
                      break;
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    case "select_template":
         
     | 
| 
      
 36 
     | 
    
         
            +
                      disabledContinueButton.classList.remove("!hidden");
         
     | 
| 
      
 37 
     | 
    
         
            +
                      createNewFormButton.classList.add("!hidden");
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                      chooseTemplateWrapper.classList.remove("hidden");
         
     | 
| 
      
 40 
     | 
    
         
            +
                      questionnaireTemplatePreview.classList.remove("hidden");
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                      // Clean-up old values in case the admin is changing between the options after filling 'Select template'
         
     | 
| 
      
 43 
     | 
    
         
            +
                      // chooseTemplateWrapper.classList.add("hide");
         
     | 
| 
      
 44 
     | 
    
         
            +
                      document.querySelector("#questionnaire_questionnaire_template_id").value = "";
         
     | 
| 
      
 45 
     | 
    
         
            +
                      document.querySelector("input[name=select-template]").value = "";
         
     | 
| 
      
 46 
     | 
    
         
            +
                      document.querySelector("[data-template-name]").innerHTML = "";
         
     | 
| 
      
 47 
     | 
    
         
            +
                      document.querySelector("[data-template-description]").innerHTML = "";
         
     | 
| 
      
 48 
     | 
    
         
            +
                      document.querySelector("[data-choose-template-preview]").innerHTML = "";
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                      break;
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    default:
         
     | 
| 
      
 53 
     | 
    
         
            +
                      console.error("Unknown template type for choosing a questionnaire template");
         
     | 
| 
      
 54 
     | 
    
         
            +
                    }
         
     | 
| 
      
 55 
     | 
    
         
            +
                  });
         
     | 
| 
      
 56 
     | 
    
         
            +
                });
         
     | 
| 
      
 57 
     | 
    
         
            +
              }
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       9 
59 
     | 
    
         
             
              const preview = (id) => {
         
     | 
| 
       10 
     | 
    
         
            -
                const options =  
     | 
| 
      
 60 
     | 
    
         
            +
                const options = chooseTemplateWrapper.dataset;
         
     | 
| 
       11 
61 
     | 
    
         
             
                const previewURL = options.previewurl;
         
     | 
| 
       12 
62 
     | 
    
         
             
                if (!previewURL) {
         
     | 
| 
       13 
63 
     | 
    
         
             
                  return;
         
     | 
| 
         @@ -18,7 +68,11 @@ $(() => { 
     | 
|
| 
       18 
68 
     | 
    
         
             
                  type: "GET",
         
     | 
| 
       19 
69 
     | 
    
         
             
                  error: (data) => (console.error(data))
         
     | 
| 
       20 
70 
     | 
    
         
             
                });
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                disabledContinueButton.classList.add("!hidden");
         
     | 
| 
      
 73 
     | 
    
         
            +
                withTemplateButton.classList.remove("!hidden");
         
     | 
| 
       21 
74 
     | 
    
         
             
              }
         
     | 
| 
       22 
75 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
              datalistSelect( 
     | 
| 
      
 76 
     | 
    
         
            +
              datalistSelect(chooseTemplateWrapper, preview)
         
     | 
| 
      
 77 
     | 
    
         
            +
              toggleElementsOnChange();
         
     | 
| 
       24 
78 
     | 
    
         
             
            })
         
     | 
| 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            // Choose a Proposal Answer template, get it by AJAX and add the Template in the Proposal Answer textarea
         
     | 
| 
       2 
     | 
    
         
            -
            document.addEventListener(" 
     | 
| 
      
 2 
     | 
    
         
            +
            document.addEventListener("turbo:load", () => {
         
     | 
| 
       3 
3 
     | 
    
         
             
              const proposalAnswerTemplateChooser = document.getElementById("proposal_answer_template_chooser");
         
     | 
| 
       4 
4 
     | 
    
         
             
              if (proposalAnswerTemplateChooser) {
         
     | 
| 
       5 
5 
     | 
    
         
             
                proposalAnswerTemplateChooser.addEventListener("change", () => {
         
     | 
| 
         @@ -1,5 +1,9 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            .questionnaire- 
     | 
| 
       2 
     | 
    
         
            -
              . 
     | 
| 
       3 
     | 
    
         
            -
                @apply  
     | 
| 
      
 1 
     | 
    
         
            +
            .questionnaire-template__form {
         
     | 
| 
      
 2 
     | 
    
         
            +
              .form__wrapper input[type="radio"] {
         
     | 
| 
      
 3 
     | 
    
         
            +
                @apply mt-0;
         
     | 
| 
      
 4 
     | 
    
         
            +
              }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              &-card {
         
     | 
| 
      
 7 
     | 
    
         
            +
                @apply p-4 block border border-background rounded-lg cursor-pointer has-[:checked]:border-secondary has-[:checked]:border-2;
         
     | 
| 
       4 
8 
     | 
    
         
             
              }
         
     | 
| 
       5 
9 
     | 
    
         
             
            }
         
     | 
| 
         @@ -9,31 +9,65 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
                </h1>
         
     | 
| 
       10 
10 
     | 
    
         
             
              </div>
         
     | 
| 
       11 
11 
     | 
    
         
             
              <% if @templates.any? %>
         
     | 
| 
       12 
     | 
    
         
            -
                <div class="table- 
     | 
| 
      
 12 
     | 
    
         
            +
                <div class="table-stacked">
         
     | 
| 
       13 
13 
     | 
    
         
             
                  <table class="table-list user_block-templates">
         
     | 
| 
       14 
14 
     | 
    
         
             
                    <thead>
         
     | 
| 
       15 
15 
     | 
    
         
             
                    <tr>
         
     | 
| 
       16 
16 
     | 
    
         
             
                      <th><%= t("template.name", scope: "decidim.models") %></th>
         
     | 
| 
       17 
17 
     | 
    
         
             
                      <th><%= t("template.fields.created_at", scope: "decidim.models") %></th>
         
     | 
| 
       18 
     | 
    
         
            -
                      <th 
     | 
| 
      
 18 
     | 
    
         
            +
                      <th><%= t("decidim.admin.actions.actions") %></th>
         
     | 
| 
       19 
19 
     | 
    
         
             
                    </tr>
         
     | 
| 
       20 
20 
     | 
    
         
             
                    </thead>
         
     | 
| 
       21 
21 
     | 
    
         
             
                    <tbody>
         
     | 
| 
       22 
22 
     | 
    
         
             
                    <% @templates.each do |template| %>
         
     | 
| 
       23 
23 
     | 
    
         
             
                      <tr data-questionnaire_template-id="<%= template.id %>">
         
     | 
| 
       24 
     | 
    
         
            -
                        <td 
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                        <td class="table-list__actions">
         
     | 
| 
       27 
     | 
    
         
            -
                          <% if allowed_to?(:update, :template, questionnaire_template: template) %>
         
     | 
| 
       28 
     | 
    
         
            -
                            <%= icon_link_to "pencil-line", edit_block_user_template_path(template), t("actions.edit", scope: "decidim.admin"), class: "edit" %>
         
     | 
| 
       29 
     | 
    
         
            -
                          <% end %>
         
     | 
| 
       30 
     | 
    
         
            -
                          <% if allowed_to?(:copy, :template, questionnaire_template: template) %>
         
     | 
| 
       31 
     | 
    
         
            -
                            <%= icon_link_to "file-copy-line", copy_block_user_template_path(template), t("actions.duplicate", scope: "decidim.admin"), method: :post %>
         
     | 
| 
       32 
     | 
    
         
            -
                          <% end %>
         
     | 
| 
       33 
     | 
    
         
            -
                          <% if allowed_to?(:destroy, :template, questionnaire_template: template) %>
         
     | 
| 
       34 
     | 
    
         
            -
                            <%= icon_link_to "delete-bin-line", block_user_template_path(template), t("actions.destroy", scope: "decidim.admin"), method: :delete, data: { confirm: t(".confirm_delete") }, class: "action-icon--remove" %>
         
     | 
| 
       35 
     | 
    
         
            -
                          <% end %>
         
     | 
| 
      
 24 
     | 
    
         
            +
                        <td data-label="<%= t("template.name", scope: "decidim.models") %>">
         
     | 
| 
      
 25 
     | 
    
         
            +
                          <%= link_to translated_attribute(template.name), edit_block_user_template_path(template) %>
         
     | 
| 
       36 
26 
     | 
    
         
             
                        </td>
         
     | 
| 
      
 27 
     | 
    
         
            +
                        <td data-label="<%= t("template.fields.created_at", scope: "decidim.models") %>">
         
     | 
| 
      
 28 
     | 
    
         
            +
                          <%= l template.created_at, format: :long %>
         
     | 
| 
      
 29 
     | 
    
         
            +
                        </td>
         
     | 
| 
      
 30 
     | 
    
         
            +
                        <td data-label="<%= t("decidim.admin.actions.actions") %>" class="table-list__actions">
         
     | 
| 
      
 31 
     | 
    
         
            +
                          <button type="button" data-controller="dropdown" data-target="actions-block-user-template-<%= template.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: template.name) %>">
         
     | 
| 
      
 32 
     | 
    
         
            +
                            <%= icon "more-fill", class: "text-secondary" %>
         
     | 
| 
      
 33 
     | 
    
         
            +
                          </button>
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                          <div class="inline-block relative">
         
     | 
| 
      
 36 
     | 
    
         
            +
                            <ul id="actions-block-user-template-<%= template.id %>" class="dropdown dropdown__action" aria-hidden="true">
         
     | 
| 
      
 37 
     | 
    
         
            +
                              <% if allowed_to?(:update, :template, questionnaire_template: template) %>
         
     | 
| 
      
 38 
     | 
    
         
            +
                                <li class="dropdown__item">
         
     | 
| 
      
 39 
     | 
    
         
            +
                                  <%= link_to edit_block_user_template_path(template), class: "dropdown__button edit" do %>
         
     | 
| 
      
 40 
     | 
    
         
            +
                                    <%= icon "pencil-line" %>
         
     | 
| 
      
 41 
     | 
    
         
            +
                                    <%= t("actions.edit", scope: "decidim.admin") %>
         
     | 
| 
      
 42 
     | 
    
         
            +
                                  <% end %>
         
     | 
| 
      
 43 
     | 
    
         
            +
                                </li>
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                                <hr>
         
     | 
| 
      
 46 
     | 
    
         
            +
                              <% end %>
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                              <% if allowed_to?(:copy, :template, questionnaire_template: template) %>
         
     | 
| 
      
 49 
     | 
    
         
            +
                                <li class="dropdown__item">
         
     | 
| 
      
 50 
     | 
    
         
            +
                                  <%= link_to copy_block_user_template_path(template), method: :post, class: "dropdown__button" do %>
         
     | 
| 
      
 51 
     | 
    
         
            +
                                    <%= icon "file-copy-line" %>
         
     | 
| 
      
 52 
     | 
    
         
            +
                                    <%= t("actions.duplicate", scope: "decidim.admin") %>
         
     | 
| 
      
 53 
     | 
    
         
            +
                                  <% end %>
         
     | 
| 
      
 54 
     | 
    
         
            +
                                </li>
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                                <hr>
         
     | 
| 
      
 57 
     | 
    
         
            +
                              <% end %>
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                              <% if allowed_to?(:destroy, :template, questionnaire_template: template) %>
         
     | 
| 
      
 60 
     | 
    
         
            +
                                <li class="dropdown__item">
         
     | 
| 
      
 61 
     | 
    
         
            +
                                  <%= link_to block_user_template_path(template), method: :delete, data: { confirm: t(".confirm_delete") }, class: "dropdown__button" do %>
         
     | 
| 
      
 62 
     | 
    
         
            +
                                    <%= icon "delete-bin-line" %>
         
     | 
| 
      
 63 
     | 
    
         
            +
                                    <%= t("actions.destroy", scope: "decidim.admin") %>
         
     | 
| 
      
 64 
     | 
    
         
            +
                                  <% end %>
         
     | 
| 
      
 65 
     | 
    
         
            +
                                </li>
         
     | 
| 
      
 66 
     | 
    
         
            +
                              <% end %>
         
     | 
| 
      
 67 
     | 
    
         
            +
                            </ul>
         
     | 
| 
      
 68 
     | 
    
         
            +
                          </div>
         
     | 
| 
      
 69 
     | 
    
         
            +
                        </td>
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
       37 
71 
     | 
    
         
             
                      </tr>
         
     | 
| 
       38 
72 
     | 
    
         
             
                    <% end %>
         
     | 
| 
       39 
73 
     | 
    
         
             
                    </tbody>
         
     | 
| 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
                </h1>
         
     | 
| 
       11 
11 
     | 
    
         
             
              </div>
         
     | 
| 
       12 
12 
     | 
    
         
             
              <% if @templates.any? %>
         
     | 
| 
       13 
     | 
    
         
            -
                <div class="table- 
     | 
| 
      
 13 
     | 
    
         
            +
                <div class="table-stacked">
         
     | 
| 
       14 
14 
     | 
    
         
             
                  <table class="table-list">
         
     | 
| 
       15 
15 
     | 
    
         
             
                    <thead>
         
     | 
| 
       16 
16 
     | 
    
         
             
                      <tr>
         
     | 
| 
         @@ -18,28 +18,65 @@ 
     | 
|
| 
       18 
18 
     | 
    
         
             
                        <th><%= t(".proposal_state_id") %></th>
         
     | 
| 
       19 
19 
     | 
    
         
             
                        <th><%= t(".component_constraint") %></th>
         
     | 
| 
       20 
20 
     | 
    
         
             
                        <th><%= t("template.fields.created_at", scope: "decidim.models") %></th>
         
     | 
| 
       21 
     | 
    
         
            -
                        <th 
     | 
| 
      
 21 
     | 
    
         
            +
                        <th><%= t("decidim.admin.actions.actions") %></th>
         
     | 
| 
       22 
22 
     | 
    
         
             
                      </tr>
         
     | 
| 
       23 
23 
     | 
    
         
             
                    </thead>
         
     | 
| 
       24 
24 
     | 
    
         
             
                    <tbody>
         
     | 
| 
       25 
25 
     | 
    
         
             
                      <% @templates.each do |template| %>
         
     | 
| 
       26 
26 
     | 
    
         
             
                        <tr data-proposal_answer-id="<%= template.id %>">
         
     | 
| 
       27 
     | 
    
         
            -
                          <td 
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                           
     | 
| 
       30 
     | 
    
         
            -
                          <td 
     | 
| 
      
 27 
     | 
    
         
            +
                          <td data-label="<%= t("template.name", scope: "decidim.models") %>">
         
     | 
| 
      
 28 
     | 
    
         
            +
                            <%= link_to_if allowed_to?(:update, :template, template: template), translated_attribute(template.name), edit_proposal_answer_template_path(template) %>
         
     | 
| 
      
 29 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 30 
     | 
    
         
            +
                          <td data-label="<%= t(".proposal_state_id") %>">
         
     | 
| 
      
 31 
     | 
    
         
            +
                            <%= proposal_state(template) %>
         
     | 
| 
      
 32 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 33 
     | 
    
         
            +
                          <td data-label="<%= t(".component_constraint") %>">
         
     | 
| 
      
 34 
     | 
    
         
            +
                            <%= availability_option_as_text(template) %>
         
     | 
| 
      
 35 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 36 
     | 
    
         
            +
                          <td data-label="<%= t("template.fields.created_at", scope: "decidim.models") %>">
         
     | 
| 
      
 37 
     | 
    
         
            +
                            <%= l template.created_at, format: :long %>
         
     | 
| 
      
 38 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 39 
     | 
    
         
            +
                          <td data-label="<%= t("decidim.admin.actions.actions") %>" class="table-list__actions">
         
     | 
| 
      
 40 
     | 
    
         
            +
                            <button type="button" data-controller="dropdown" data-target="actions-proposal-answer-template-<%= template.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: template.name) %>">
         
     | 
| 
      
 41 
     | 
    
         
            +
                              <%= icon "more-fill", class: "text-secondary" %>
         
     | 
| 
      
 42 
     | 
    
         
            +
                            </button>
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                            <div class="inline-block relative">
         
     | 
| 
      
 45 
     | 
    
         
            +
                              <ul id="actions-proposal-answer-template-<%= template.id %>" class="dropdown dropdown__action" aria-hidden="true">
         
     | 
| 
      
 46 
     | 
    
         
            +
                                <% if allowed_to?(:update, :template, template: template) %>
         
     | 
| 
      
 47 
     | 
    
         
            +
                                  <li class="dropdown__item">
         
     | 
| 
      
 48 
     | 
    
         
            +
                                    <%= link_to edit_proposal_answer_template_path(template), class: "dropdown__button edit" do %>
         
     | 
| 
      
 49 
     | 
    
         
            +
                                      <%= icon "pencil-line" %>
         
     | 
| 
      
 50 
     | 
    
         
            +
                                      <%= t("actions.edit", scope: "decidim.admin") %>
         
     | 
| 
      
 51 
     | 
    
         
            +
                                    <% end %>
         
     | 
| 
      
 52 
     | 
    
         
            +
                                  </li>
         
     | 
| 
       31 
53 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
                                  <hr>
         
     | 
| 
      
 55 
     | 
    
         
            +
                                <% end %>
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                                <% if allowed_to?(:copy, :template, template: template) %>
         
     | 
| 
      
 58 
     | 
    
         
            +
                                  <li class="dropdown__item">
         
     | 
| 
      
 59 
     | 
    
         
            +
                                    <%= link_to copy_proposal_answer_template_path(template), method: :post, class: "dropdown__button" do %>
         
     | 
| 
      
 60 
     | 
    
         
            +
                                      <%= icon "file-copy-line" %>
         
     | 
| 
      
 61 
     | 
    
         
            +
                                      <%= t("actions.duplicate", scope: "decidim.admin") %>
         
     | 
| 
      
 62 
     | 
    
         
            +
                                    <% end %>
         
     | 
| 
      
 63 
     | 
    
         
            +
                                  </li>
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                                  <hr>
         
     | 
| 
      
 66 
     | 
    
         
            +
                                <% end %>
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                                <% if allowed_to?(:destroy, :template, template: template) %>
         
     | 
| 
      
 69 
     | 
    
         
            +
                                  <li class="dropdown__item">
         
     | 
| 
      
 70 
     | 
    
         
            +
                                    <%= link_to proposal_answer_template_path(template), method: :delete, data: { confirm: t(".confirm_delete") }, class: "dropdown__button" do %>
         
     | 
| 
      
 71 
     | 
    
         
            +
                                      <%= icon "delete-bin-line" %>
         
     | 
| 
      
 72 
     | 
    
         
            +
                                      <%= t("actions.destroy", scope: "decidim.admin") %>
         
     | 
| 
      
 73 
     | 
    
         
            +
                                    <% end %>
         
     | 
| 
      
 74 
     | 
    
         
            +
                                  </li>
         
     | 
| 
      
 75 
     | 
    
         
            +
                                <% end %>
         
     | 
| 
      
 76 
     | 
    
         
            +
                              </ul>
         
     | 
| 
      
 77 
     | 
    
         
            +
                            </div>
         
     | 
| 
       42 
78 
     | 
    
         
             
                          </td>
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
       43 
80 
     | 
    
         
             
                        </tr>
         
     | 
| 
       44 
81 
     | 
    
         
             
                      <% end %>
         
     | 
| 
       45 
82 
     | 
    
         
             
                    </tbody>
         
     | 
| 
         @@ -1,42 +1,61 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <div class="item_show__header">
         
     | 
| 
       2 
2 
     | 
    
         
             
              <h1 class="item_show__header-title">
         
     | 
| 
       3 
3 
     | 
    
         
             
                <%= form_title %>
         
     | 
| 
       4 
     | 
    
         
            -
                <div class="ml-auto">
         
     | 
| 
       5 
     | 
    
         
            -
                  <%= link_to t(".skip_template"), decidim_admin_templates.skip_questionnaire_templates_path(questionnaire_id: questionnaire, url: request.url), class: "button button__sm button__secondary", method: :post %>
         
     | 
| 
       6 
     | 
    
         
            -
                </div>
         
     | 
| 
       7 
4 
     | 
    
         
             
              </h1>
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              <% if show_buttons %>
         
     | 
| 
      
 7 
     | 
    
         
            +
                <%= button_tag t("continue", scope: "decidim.templates.admin.questionnaire_templates.choose"), class: "main-tabs-menu__cta-button disabled", data: { disabled_button: true } %>
         
     | 
| 
      
 8 
     | 
    
         
            +
                <%= link_to t("continue", scope: "decidim.templates.admin.questionnaire_templates.choose"), decidim_admin_templates.skip_questionnaire_templates_path(questionnaire_id: questionnaire, url: request.url), class: "main-tabs-menu__cta-button hidden", data: { create_new_form_button: true }, method: :post %>
         
     | 
| 
      
 9 
     | 
    
         
            +
                <%= button_tag t("continue", scope: "decidim.templates.admin.questionnaire_templates.choose"), class: "main-tabs-menu__cta-button hidden", data: { with_template_button: true }, form: "choose-template-form" %>
         
     | 
| 
      
 10 
     | 
    
         
            +
              <% end %>
         
     | 
| 
       8 
11 
     | 
    
         
             
            </div>
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            <div class="grid-cols-1">
         
     | 
| 
      
 14 
     | 
    
         
            +
              <div class="item__edit-form questionnaire-template__form">
         
     | 
| 
      
 15 
     | 
    
         
            +
                <%= decidim_form_for([questionnaire], url: decidim_admin_templates.apply_questionnaire_templates_url(questionnaire_id: questionnaire, url: request.url),
         
     | 
| 
      
 16 
     | 
    
         
            +
                                                      method: :post,
         
     | 
| 
      
 17 
     | 
    
         
            +
                                                      html: { id: "choose-template-form", class: "form form-defaults choose_questionnaire_templates", "data-choose-questionnaire-templates": true }) do |form| %>
         
     | 
| 
       12 
18 
     | 
    
         
             
                  <div class="form__wrapper">
         
     | 
| 
       13 
     | 
    
         
            -
                    <div class=" 
     | 
| 
      
 19 
     | 
    
         
            +
                    <div class="p-4 ">
         
     | 
| 
       14 
20 
     | 
    
         
             
                      <%= t(".description") %>
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                      <div class="grid grid-cols-2 gap-4 my-4">
         
     | 
| 
      
 23 
     | 
    
         
            +
                        <%= label_tag :template_create_new_form, class: "questionnaire-template__form-card" do %>
         
     | 
| 
      
 24 
     | 
    
         
            +
                          <%= radio_button_tag :template, :create_new_form, false, class: "hidden peer" %>
         
     | 
| 
      
 25 
     | 
    
         
            +
                          <span class="text-lg font-normal">
         
     | 
| 
      
 26 
     | 
    
         
            +
                            <%= t(".options.create_new_form") %>
         
     | 
| 
      
 27 
     | 
    
         
            +
                          </span>
         
     | 
| 
      
 28 
     | 
    
         
            +
                        <% end %>
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                        <%= label_tag :template_select_template, class: "questionnaire-template__form-card" do %>
         
     | 
| 
      
 31 
     | 
    
         
            +
                          <%= radio_button_tag :template, :select_template, false, class: "hidden peer" %>
         
     | 
| 
      
 32 
     | 
    
         
            +
                          <span class="text-lg font-normal">
         
     | 
| 
      
 33 
     | 
    
         
            +
                            <%= t(".options.select_template") %>
         
     | 
| 
      
 34 
     | 
    
         
            +
                          </span>
         
     | 
| 
      
 35 
     | 
    
         
            +
                        <% end %>
         
     | 
| 
      
 36 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
       15 
38 
     | 
    
         
             
                      <%= datalist_select(templates,
         
     | 
| 
       16 
39 
     | 
    
         
             
                                          {
         
     | 
| 
       17 
40 
     | 
    
         
             
                                            id: "choose-template",
         
     | 
| 
       18 
41 
     | 
    
         
             
                                            list: "template-list",
         
     | 
| 
       19 
42 
     | 
    
         
             
                                            label: t(".label"),
         
     | 
| 
       20 
43 
     | 
    
         
             
                                            name: "select-template",
         
     | 
| 
      
 44 
     | 
    
         
            +
                                            class: "hidden",
         
     | 
| 
       21 
45 
     | 
    
         
             
                                            placeholder: t("placeholder", scope: "decidim.templates.admin.questionnaire_templates.choose"),
         
     | 
| 
       22 
46 
     | 
    
         
             
                                            data: {
         
     | 
| 
       23 
47 
     | 
    
         
             
                                              previewurl: decidim_admin_templates.preview_questionnaire_templates_url(format: :js)
         
     | 
| 
       24 
48 
     | 
    
         
             
                                            }
         
     | 
| 
       25 
49 
     | 
    
         
             
                                          }
         
     | 
| 
       26 
50 
     | 
    
         
             
                      ) { form.hidden_field :questionnaire_template_id } %>
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                      <div class="card-section questionnaire-template-preview pt-4 hide" data-questionnaire-template-preview="true">
         
     | 
| 
       28 
53 
     | 
    
         
             
                        <h2 class="item_show__header-title" data-template-name></h2>
         
     | 
| 
       29 
54 
     | 
    
         
             
                        <p class="py-4" data-template-description></p>
         
     | 
| 
       30 
55 
     | 
    
         
             
                        <div class="row column" data-choose-template-preview></div>
         
     | 
| 
       31 
56 
     | 
    
         
             
                      </div>
         
     | 
| 
       32 
57 
     | 
    
         
             
                    </div>
         
     | 
| 
       33 
58 
     | 
    
         
             
                  </div>
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                  <div class="item__edit-sticky">
         
     | 
| 
       36 
     | 
    
         
            -
                    <div class="item__edit-sticky-container">
         
     | 
| 
       37 
     | 
    
         
            -
                      <%= form.submit t(".create_from_template"), class: "button button__sm button__secondary" %>
         
     | 
| 
       38 
     | 
    
         
            -
                    </div>
         
     | 
| 
       39 
     | 
    
         
            -
                  </div>
         
     | 
| 
       40 
59 
     | 
    
         
             
                <% end %>
         
     | 
| 
       41 
60 
     | 
    
         
             
              </div>
         
     | 
| 
       42 
61 
     | 
    
         
             
            </div>
         
     | 
| 
         @@ -6,11 +6,11 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            </div>
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            <div class="row columns">
         
     | 
| 
       9 
     | 
    
         
            -
              <%= decidim_form_for(@preview_form, url: "", method: :post, authenticity_token: !defined?(skip_authenticity_token), html: { class: "form form-defaults  
     | 
| 
      
 9 
     | 
    
         
            +
              <%= decidim_form_for(@preview_form, url: "", method: :post, authenticity_token: !defined?(skip_authenticity_token), html: { class: "form form-defaults response-questionnaire" }, data: { "safe-path" => "" }) do |form| %>
         
     | 
| 
       10 
10 
     | 
    
         
             
                <%= invisible_captcha %>
         
     | 
| 
       11 
     | 
    
         
            -
                <%  
     | 
| 
       12 
     | 
    
         
            -
                <%  
     | 
| 
       13 
     | 
    
         
            -
                <% @preview_form.responses_by_step.each_with_index do | 
     | 
| 
      
 11 
     | 
    
         
            +
                <% response_idx = 0 %>
         
     | 
| 
      
 12 
     | 
    
         
            +
                <% cleaned_response_idx = 0 %>
         
     | 
| 
      
 13 
     | 
    
         
            +
                <% @preview_form.responses_by_step.each_with_index do |step_responses, step_index| %>
         
     | 
| 
       14 
14 
     | 
    
         
             
                  <div id="step-<%= step_index %>" class="<%= step_index.zero? ? "questionnaire-step" : "questionnaire-step hide" %>" data-toggler=".hide">
         
     | 
| 
       15 
15 
     | 
    
         
             
                    <div class="form__wrapper">
         
     | 
| 
       16 
16 
     | 
    
         
             
                      <% if @preview_form.total_steps > 1 %>
         
     | 
| 
         @@ -19,23 +19,23 @@ 
     | 
|
| 
       19 
19 
     | 
    
         
             
                        </h4>
         
     | 
| 
       20 
20 
     | 
    
         
             
                      <% end %>
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                      <%  
     | 
| 
       23 
     | 
    
         
            -
                        <div class="mb-4  
     | 
| 
       24 
     | 
    
         
            -
                          <%= fields_for "questionnaire[responses][#{ 
     | 
| 
      
 22 
     | 
    
         
            +
                      <% step_responses.each do |response| %>
         
     | 
| 
      
 23 
     | 
    
         
            +
                        <div class="mb-4 response" data-max-choices="<%= response.question.max_choices %>">
         
     | 
| 
      
 24 
     | 
    
         
            +
                          <%= fields_for "questionnaire[responses][#{response_idx}]", response do |response_form| %>
         
     | 
| 
       25 
25 
     | 
    
         
             
                            <%= render(
         
     | 
| 
       26 
     | 
    
         
            -
                              "decidim/forms/questionnaires/ 
     | 
| 
       27 
     | 
    
         
            -
                               
     | 
| 
       28 
     | 
    
         
            -
                               
     | 
| 
       29 
     | 
    
         
            -
                               
     | 
| 
       30 
     | 
    
         
            -
                               
     | 
| 
      
 26 
     | 
    
         
            +
                              "decidim/forms/questionnaires/response",
         
     | 
| 
      
 27 
     | 
    
         
            +
                              response_form:,
         
     | 
| 
      
 28 
     | 
    
         
            +
                              response:,
         
     | 
| 
      
 29 
     | 
    
         
            +
                              response_idx:,
         
     | 
| 
      
 30 
     | 
    
         
            +
                              cleaned_response_idx:,
         
     | 
| 
       31 
31 
     | 
    
         
             
                              disabled: false
         
     | 
| 
       32 
32 
     | 
    
         
             
                            ) %>
         
     | 
| 
       33 
33 
     | 
    
         
             
                          <% end %>
         
     | 
| 
       34 
34 
     | 
    
         
             
                        </div>
         
     | 
| 
       35 
     | 
    
         
            -
                        <% if ! 
     | 
| 
       36 
     | 
    
         
            -
                          <%  
     | 
| 
      
 35 
     | 
    
         
            +
                        <% if !response.question.separator? %>
         
     | 
| 
      
 36 
     | 
    
         
            +
                          <% cleaned_response_idx += 1 %>
         
     | 
| 
       37 
37 
     | 
    
         
             
                        <% end %>
         
     | 
| 
       38 
     | 
    
         
            -
                        <%  
     | 
| 
      
 38 
     | 
    
         
            +
                        <% response_idx += 1 %>
         
     | 
| 
       39 
39 
     | 
    
         
             
                      <% end %>
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                      <% if step_index + 1 == @preview_form.total_steps %>
         
     | 
| 
         @@ -9,7 +9,7 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
                </h1>
         
     | 
| 
       10 
10 
     | 
    
         
             
              </div>
         
     | 
| 
       11 
11 
     | 
    
         
             
              <% if @templates.any? %>
         
     | 
| 
       12 
     | 
    
         
            -
                <div class="table- 
     | 
| 
      
 12 
     | 
    
         
            +
                <div class="table-stacked">
         
     | 
| 
       13 
13 
     | 
    
         
             
                  <table class="table-list questionnaire-templates">
         
     | 
| 
       14 
14 
     | 
    
         
             
                    <thead>
         
     | 
| 
       15 
15 
     | 
    
         
             
                      <tr>
         
     | 
| 
         @@ -17,28 +17,63 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
                        <th><%= t("questionnaire_template.fields.title", scope: "decidim.models") %></th>
         
     | 
| 
       18 
18 
     | 
    
         
             
                        <th><%= t("questionnaire_template.fields.questions", scope: "decidim.models") %></th>
         
     | 
| 
       19 
19 
     | 
    
         
             
                        <th><%= t("template.fields.created_at", scope: "decidim.models") %></th>
         
     | 
| 
       20 
     | 
    
         
            -
                        <th 
     | 
| 
      
 20 
     | 
    
         
            +
                        <th><%= t("decidim.admin.actions.actions") %></th>
         
     | 
| 
       21 
21 
     | 
    
         
             
                      </tr>
         
     | 
| 
       22 
22 
     | 
    
         
             
                    </thead>
         
     | 
| 
       23 
23 
     | 
    
         
             
                    <tbody>
         
     | 
| 
       24 
24 
     | 
    
         
             
                      <% @templates.each do |template| %>
         
     | 
| 
       25 
25 
     | 
    
         
             
                        <tr data-questionnaire_template-id="<%= template.id %>">
         
     | 
| 
       26 
     | 
    
         
            -
                          <td 
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                           
     | 
| 
       29 
     | 
    
         
            -
                          <td 
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                             
     | 
| 
      
 26 
     | 
    
         
            +
                          <td data-label="<%= t("template.name", scope: "decidim.models") %>">
         
     | 
| 
      
 27 
     | 
    
         
            +
                            <%= link_to translated_attribute(template.name), edit_questionnaire_template_path(template) %>
         
     | 
| 
      
 28 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 29 
     | 
    
         
            +
                          <td data-label="<%= t("questionnaire_template.fields.title", scope: "decidim.models") %>">
         
     | 
| 
      
 30 
     | 
    
         
            +
                            <%= link_to translated_attribute(template.templatable.title), edit_questionnaire_path(template) %>
         
     | 
| 
      
 31 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 32 
     | 
    
         
            +
                          <td data-label="<%= t("questionnaire_template.fields.questions", scope: "decidim.models") %>">
         
     | 
| 
      
 33 
     | 
    
         
            +
                            <%= template.templatable.questions.count.to_i %>
         
     | 
| 
      
 34 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 35 
     | 
    
         
            +
                          <td data-label="<%= t("template.fields.created_at", scope: "decidim.models") %>">
         
     | 
| 
      
 36 
     | 
    
         
            +
                            <%= l template.created_at, format: :long %>
         
     | 
| 
      
 37 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 38 
     | 
    
         
            +
                          <td data-label="<%= t("decidim.admin.actions.actions") %>" class="table-list__actions">
         
     | 
| 
      
 39 
     | 
    
         
            +
                            <button type="button" data-controller="dropdown" data-target="actions-template-<%= template.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: template.name) %>">
         
     | 
| 
      
 40 
     | 
    
         
            +
                              <%= icon "more-fill", class: "text-secondary" %>
         
     | 
| 
      
 41 
     | 
    
         
            +
                            </button>
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                            <div class="inline-block relative">
         
     | 
| 
      
 44 
     | 
    
         
            +
                              <ul id="actions-template-<%= template.id %>" class="dropdown dropdown__action" aria-hidden="true">
         
     | 
| 
      
 45 
     | 
    
         
            +
                                <% if allowed_to?(:update, :template, questionnaire_template: template) %>
         
     | 
| 
      
 46 
     | 
    
         
            +
                                  <li class="dropdown__item">
         
     | 
| 
      
 47 
     | 
    
         
            +
                                    <%= link_to edit_questionnaire_template_path(template), class: "dropdown__button edit" do %>
         
     | 
| 
      
 48 
     | 
    
         
            +
                                      <%= icon "pencil-line" %>
         
     | 
| 
      
 49 
     | 
    
         
            +
                                      <%= t("actions.edit", scope: "decidim.admin") %>
         
     | 
| 
      
 50 
     | 
    
         
            +
                                    <% end %>
         
     | 
| 
      
 51 
     | 
    
         
            +
                                  </li>
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                                  <hr>
         
     | 
| 
      
 54 
     | 
    
         
            +
                                <% end %>
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                                <% if allowed_to?(:copy, :template, questionnaire_template: template) %>
         
     | 
| 
      
 57 
     | 
    
         
            +
                                  <li class="dropdown__item">
         
     | 
| 
      
 58 
     | 
    
         
            +
                                    <%= link_to copy_questionnaire_template_path(template), method: :post, class: "dropdown__button" do %>
         
     | 
| 
      
 59 
     | 
    
         
            +
                                      <%= icon "file-copy-line" %>
         
     | 
| 
      
 60 
     | 
    
         
            +
                                      <%= t("actions.duplicate", scope: "decidim.admin") %>
         
     | 
| 
      
 61 
     | 
    
         
            +
                                    <% end %>
         
     | 
| 
      
 62 
     | 
    
         
            +
                                  </li>
         
     | 
| 
       34 
63 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                            <% end %>
         
     | 
| 
      
 64 
     | 
    
         
            +
                                  <hr>
         
     | 
| 
      
 65 
     | 
    
         
            +
                                <% end %>
         
     | 
| 
       38 
66 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
                                <% if allowed_to?(:destroy, :template, questionnaire_template: template) %>
         
     | 
| 
      
 68 
     | 
    
         
            +
                                  <li class="dropdown__item">
         
     | 
| 
      
 69 
     | 
    
         
            +
                                    <%= link_to questionnaire_template_path(template), method: :delete, data: { confirm: t(".confirm_delete") }, class: "dropdown__button" do %>
         
     | 
| 
      
 70 
     | 
    
         
            +
                                      <%= icon "delete-bin-line" %>
         
     | 
| 
      
 71 
     | 
    
         
            +
                                      <%= t("actions.destroy", scope: "decidim.admin") %>
         
     | 
| 
      
 72 
     | 
    
         
            +
                                    <% end %>
         
     | 
| 
      
 73 
     | 
    
         
            +
                                  </li>
         
     | 
| 
      
 74 
     | 
    
         
            +
                                <% end %>
         
     | 
| 
      
 75 
     | 
    
         
            +
                              </ul>
         
     | 
| 
      
 76 
     | 
    
         
            +
                            </div>
         
     | 
| 
       42 
77 
     | 
    
         
             
                          </td>
         
     | 
| 
       43 
78 
     | 
    
         
             
                        </tr>
         
     | 
| 
       44 
79 
     | 
    
         
             
                      <% end %>
         
     |