From cd99f2a5ebdfe62543a3ed8d9e0eebbe9c9d2716 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Sep 2022 11:02:14 +0200 Subject: [PATCH 1/3] Replace legislation question textarea to text field --- app/views/admin/legislation/questions/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/legislation/questions/_form.html.erb b/app/views/admin/legislation/questions/_form.html.erb index e5338389b280..9db27765e9be 100644 --- a/app/views/admin/legislation/questions/_form.html.erb +++ b/app/views/admin/legislation/questions/_form.html.erb @@ -7,7 +7,7 @@
<%= f.translatable_fields do |translations_form| %>
- <%= translations_form.text_area :title, rows: 5 %> + <%= translations_form.text_field :title %>
<% end %>
From 800027728a784ba2f8be8f7413292c831d783bc9 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 27 Sep 2022 11:26:45 +0200 Subject: [PATCH 2/3] Add description to legislation questions --- app/models/legislation/question.rb | 1 + .../admin/legislation/questions/_form.html.erb | 4 ++++ app/views/legislation/questions/show.html.erb | 1 + ...cription_to_legislation_question_translations.rb | 5 +++++ db/schema.rb | 1 + spec/system/admin/legislation/questions_spec.rb | 5 ++++- spec/system/legislation/questions_spec.rb | 13 ++++++++++--- 7 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20220924224924_add_description_to_legislation_question_translations.rb diff --git a/app/models/legislation/question.rb b/app/models/legislation/question.rb index 89515d9437d2..c0ea9152766d 100644 --- a/app/models/legislation/question.rb +++ b/app/models/legislation/question.rb @@ -4,6 +4,7 @@ class Legislation::Question < ApplicationRecord include Notifiable translates :title, touch: true + translates :description, touch: true include Globalizable belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :legislation_questions diff --git a/app/views/admin/legislation/questions/_form.html.erb b/app/views/admin/legislation/questions/_form.html.erb index 9db27765e9be..d0a0e646d227 100644 --- a/app/views/admin/legislation/questions/_form.html.erb +++ b/app/views/admin/legislation/questions/_form.html.erb @@ -9,6 +9,10 @@
<%= translations_form.text_field :title %>
+ +
+ <%= translations_form.text_area :description, class: "html-area admin" %> +
<% end %> diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb index dc4939f29c67..5544ef163aef 100644 --- a/app/views/legislation/questions/show.html.erb +++ b/app/views/legislation/questions/show.html.erb @@ -29,6 +29,7 @@

<%= @question.title %>

+ <%= AdminWYSIWYGSanitizer.new.sanitize(@question.description) %>
<%= render "answer_form", process: @process, question: @question, answer: @answer %>
diff --git a/db/migrate/20220924224924_add_description_to_legislation_question_translations.rb b/db/migrate/20220924224924_add_description_to_legislation_question_translations.rb new file mode 100644 index 000000000000..d2321b70b3e1 --- /dev/null +++ b/db/migrate/20220924224924_add_description_to_legislation_question_translations.rb @@ -0,0 +1,5 @@ +class AddDescriptionToLegislationQuestionTranslations < ActiveRecord::Migration[6.0] + def change + add_column :legislation_question_translations, :description, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 7b3a7349d116..802fe82b0add 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -861,6 +861,7 @@ t.datetime "updated_at", null: false t.text "title" t.datetime "hidden_at" + t.text "description" t.index ["hidden_at"], name: "index_legislation_question_translations_on_hidden_at" t.index ["legislation_question_id"], name: "index_d34cc1e1fe6d5162210c41ce56533c5afabcdbd3" t.index ["locale"], name: "index_legislation_question_translations_on_locale" diff --git a/spec/system/admin/legislation/questions_spec.rb b/spec/system/admin/legislation/questions_spec.rb index 67601cb598a9..0fbe2a9ab563 100644 --- a/spec/system/admin/legislation/questions_spec.rb +++ b/spec/system/admin/legislation/questions_spec.rb @@ -32,6 +32,7 @@ click_link "Create question" fill_in "Question", with: "Question 3" + fill_in_ckeditor "Description", with: "A little description about question 3" click_button "Create question" expect(page).to have_content "Question 3" @@ -40,7 +41,7 @@ context "Update" do scenario "Valid legislation question" do - create(:legislation_question, title: "Question 2", process: process) + create(:legislation_question, title: "Question 2", description: "Description 2", process: process) visit admin_root_path @@ -57,9 +58,11 @@ click_link "Question 2" fill_in "Question", with: "Question 2b" + fill_in_ckeditor "Description", with: "Description 2b" click_button "Save changes" expect(page).to have_content "Question 2b" + expect(page).to have_ckeditor "Description", with: "Description 2b" end end diff --git a/spec/system/legislation/questions_spec.rb b/spec/system/legislation/questions_spec.rb index b217ad7f44ba..41570c6a603b 100644 --- a/spec/system/legislation/questions_spec.rb +++ b/spec/system/legislation/questions_spec.rb @@ -9,9 +9,9 @@ end before do - create(:legislation_question, process: process, title: "Question 1") - create(:legislation_question, process: process, title: "Question 2") - create(:legislation_question, process: process, title: "Question 3") + create(:legislation_question, process: process, title: "Question 1", description: "Description 1") + create(:legislation_question, process: process, title: "Question 2", description: "Description 2") + create(:legislation_question, process: process, title: "Question 3", description: "Description 3") end scenario "shows question list" do @@ -24,16 +24,19 @@ click_link "Question 1" expect(page).to have_content("Question 1") + expect(page).to have_content("Description 1") expect(page).to have_content("NEXT QUESTION") click_link "Next question" expect(page).to have_content("Question 2") + expect(page).to have_content("Description 2") expect(page).to have_content("NEXT QUESTION") click_link "Next question" expect(page).to have_content("Question 3") + expect(page).to have_content("Description 3") expect(page).not_to have_content("NEXT QUESTION") end @@ -41,6 +44,7 @@ visit legislation_process_question_path(process, process.questions.first) expect(page).to have_content("Question 1") + expect(page).to have_content("Description 1") expect(page).to have_content("Open answers (0)") end @@ -48,16 +52,19 @@ visit legislation_process_question_path(process, process.questions.first) expect(page).to have_content("Question 1") + expect(page).to have_content("Description 1") expect(page).to have_content("NEXT QUESTION") click_link "Next question" expect(page).to have_content("Question 2") + expect(page).to have_content("Description 2") expect(page).to have_content("NEXT QUESTION") click_link "Next question" expect(page).to have_content("Question 3") + expect(page).to have_content("Description 3") expect(page).not_to have_content("NEXT QUESTION") end From 3aac39208e98484a66526216f40768041288efec Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 22 Feb 2023 08:53:21 +0100 Subject: [PATCH 3/3] Adjust styles Since we're now allowing

and

tags in the description, we remove the broken

tag from quiz-question class. Since its content is also in the element, and in order to be consistent with other show actions in the public area, we change this tag to <h1>. We add <h2> tag in the "Share" heading and we replace the broken <h4> tag above adding new styles. --- app/assets/stylesheets/legislation_process.scss | 12 +++++++----- app/views/legislation/questions/show.html.erb | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index 3cd63e889b85..4a19453bb2ed 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -191,13 +191,15 @@ margin-bottom: 0; text-transform: uppercase; } - } - h4 a { - @include brand-color; + a { + @include brand-color; + font-size: rem-calc(18); + font-weight: 700; - &:hover { - text-decoration: none; + &:hover { + text-decoration: none; + } } } diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb index 5544ef163aef..1f25ef3e12eb 100644 --- a/app/views/legislation/questions/show.html.erb +++ b/app/views/legislation/questions/show.html.erb @@ -5,7 +5,7 @@ <div class="small-12 medium-9 column"> <div class="quiz-title"> <p class="quiz-header-title"><%= t("legislation.questions.show.title") %></p> - <h4><%= link_to @process.title, @process %></h4> + <%= link_to @process.title, @process %> </div> </div> <div class="small-12 medium-3 column"> @@ -28,7 +28,7 @@ </div> <div class="row"> <div class="small-12 medium-9 column"> - <h3 class="quiz-question"><%= @question.title %></h3> + <h1 class="quiz-question"><%= @question.title %></h1> <%= AdminWYSIWYGSanitizer.new.sanitize(@question.description) %> <div class="debate-questions" id="legislation-answer-form"> <%= render "answer_form", process: @process, question: @question, answer: @answer %> @@ -37,7 +37,7 @@ <aside class="small-12 medium-3 column"> <div id="social-share" class="sidebar-divider"></div> - <h3><%= t("legislation.questions.show.share") %></h3> + <h2><%= t("legislation.questions.show.share") %></h2> <%= render "/shared/social_share", title: @question.title, url: legislation_process_question_url(@question.process, @question) %> </aside> </div>