From db86f0e7ab6f18f019c7c9d6235614d3c1fd3a78 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 27 Dec 2018 20:16:39 +0100 Subject: [PATCH 1/6] Changes styles to tabs on processes key dates --- .../stylesheets/legislation_process.scss | 122 +++++++++++------- 1 file changed, 76 insertions(+), 46 deletions(-) diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index 0bfff8b23..c870b0e32 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -44,68 +44,98 @@ // 02. Legislation process navigation // ---------------------------------- -.legislation-process-categories { - position: relative; +.legislation-process-list { + border-bottom: 1px solid $border; +} - .legislation-process-list { - border-bottom: 1px solid $medium-gray; - margin: 0 rem-calc(16) rem-calc(16); +.key-dates { + list-style-type: none; + margin: 0 rem-calc(-10); - ul { - list-style: none; - margin: 0 auto; + @include breakpoint(medium) { + margin: 0; + } + + li { + border: 1px solid $border; + display: block; + margin: rem-calc(-1) 0; + position: relative; + + @include breakpoint(medium) { + background: #fafafa; + display: inline-block; + border-bottom: 0; + border-top-left-radius: rem-calc(6); + border-top-right-radius: rem-calc(6); margin-bottom: 0; - padding-left: 0; + margin-right: $line-height / 4; + margin-top: 0; + + &:hover:not(.is-active) { + background: $highlight; + } + + &::after { + content: '' !important; + } } - li { - border-bottom: 2px solid transparent; - cursor: pointer; - display: inline-block; - margin-bottom: $line-height; - margin-right: $line-height; - transition: all 0.4s; - - @include breakpoint(medium) { - margin-bottom: 0; - } - - &:hover, - &:active, - &:focus { - border-bottom: 2px solid $brand; - } - - a, - h4 { - display: block; - color: #6d6d6d; - margin-bottom: 0; - } + &::after { + content: '\63'; + font-family: "icons" !important; + font-size: rem-calc(24); + pointer-events: none; + position: absolute; + right: 12px; + top: 12px; } a { - &:hover, - &:active { + display: block; + padding: $line-height / 4 $line-height / 2; + + @include breakpoint(medium) { + display: inline-block; + } + + &:hover { text-decoration: none; } - p { + h4 { margin-bottom: 0; + } + } + } - @include breakpoint(medium) { - margin-bottom: rem-calc(16); - } + span { + color: $text-medium; + font-size: $small-font-size; + } + + .is-active { + background: $highlight; + position: relative; + + @include breakpoint(medium) { + background: none; + border: 1px solid $border; + border-bottom: 0; + + &::after { + border-bottom: 1px solid #fefefe; + bottom: -1px; + content: '' !important; + left: 0; + position: absolute; + width: 100%; } } - .is-active { - border-bottom: 2px solid $brand; - - a, - h4 { - color: $brand; - } + &::after { + content: '\61'; + color: $link; } } } From 2ac3406a989855dd52b358d850073aab24034741 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 27 Dec 2018 20:17:38 +0100 Subject: [PATCH 2/6] Updates key dates i18n --- config/locales/en/legislation.yml | 2 +- config/locales/es-AR/legislation.yml | 2 +- config/locales/es-BO/legislation.yml | 2 +- config/locales/es-CL/legislation.yml | 2 +- config/locales/es-CO/legislation.yml | 2 +- config/locales/es-CR/legislation.yml | 2 +- config/locales/es-DO/legislation.yml | 2 +- config/locales/es-EC/legislation.yml | 2 +- config/locales/es-GT/legislation.yml | 2 +- config/locales/es-HN/legislation.yml | 2 +- config/locales/es-MX/legislation.yml | 2 +- config/locales/es-NI/legislation.yml | 2 +- config/locales/es-PA/legislation.yml | 2 +- config/locales/es-PE/legislation.yml | 2 +- config/locales/es-PR/legislation.yml | 2 +- config/locales/es-PY/legislation.yml | 2 +- config/locales/es-SV/legislation.yml | 2 +- config/locales/es-UY/legislation.yml | 2 +- config/locales/es-VE/legislation.yml | 2 +- config/locales/es/legislation.yml | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/config/locales/en/legislation.yml b/config/locales/en/legislation.yml index ed142fd49..e1c71f6c6 100644 --- a/config/locales/en/legislation.yml +++ b/config/locales/en/legislation.yml @@ -82,7 +82,7 @@ en: see_latest_comments: See latest comments see_latest_comments_title: Comment on this process shared: - key_dates: Key dates + key_dates: Participation phases debate_dates: Debate draft_publication_date: Draft publication allegations_dates: Comments diff --git a/config/locales/es-AR/legislation.yml b/config/locales/es-AR/legislation.yml index 846e74d5a..92714dc19 100644 --- a/config/locales/es-AR/legislation.yml +++ b/config/locales/es-AR/legislation.yml @@ -73,7 +73,7 @@ es-AR: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-BO/legislation.yml b/config/locales/es-BO/legislation.yml index 1b5d5ed55..852470826 100644 --- a/config/locales/es-BO/legislation.yml +++ b/config/locales/es-BO/legislation.yml @@ -73,7 +73,7 @@ es-BO: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-CL/legislation.yml b/config/locales/es-CL/legislation.yml index ab17069ee..2a254f7f7 100644 --- a/config/locales/es-CL/legislation.yml +++ b/config/locales/es-CL/legislation.yml @@ -73,7 +73,7 @@ es-CL: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-CO/legislation.yml b/config/locales/es-CO/legislation.yml index aaae703d3..1b8a17637 100644 --- a/config/locales/es-CO/legislation.yml +++ b/config/locales/es-CO/legislation.yml @@ -73,7 +73,7 @@ es-CO: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-CR/legislation.yml b/config/locales/es-CR/legislation.yml index db9d5cda4..c262a9e53 100644 --- a/config/locales/es-CR/legislation.yml +++ b/config/locales/es-CR/legislation.yml @@ -73,7 +73,7 @@ es-CR: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-DO/legislation.yml b/config/locales/es-DO/legislation.yml index 5492300ec..9d737a8dd 100644 --- a/config/locales/es-DO/legislation.yml +++ b/config/locales/es-DO/legislation.yml @@ -73,7 +73,7 @@ es-DO: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-EC/legislation.yml b/config/locales/es-EC/legislation.yml index ec08d9ed0..cad9eb51d 100644 --- a/config/locales/es-EC/legislation.yml +++ b/config/locales/es-EC/legislation.yml @@ -73,7 +73,7 @@ es-EC: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-GT/legislation.yml b/config/locales/es-GT/legislation.yml index 03328bcfb..2a672648f 100644 --- a/config/locales/es-GT/legislation.yml +++ b/config/locales/es-GT/legislation.yml @@ -73,7 +73,7 @@ es-GT: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-HN/legislation.yml b/config/locales/es-HN/legislation.yml index 1184bda4b..8b10aa0e4 100644 --- a/config/locales/es-HN/legislation.yml +++ b/config/locales/es-HN/legislation.yml @@ -73,7 +73,7 @@ es-HN: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-MX/legislation.yml b/config/locales/es-MX/legislation.yml index cd64b6353..81697e493 100644 --- a/config/locales/es-MX/legislation.yml +++ b/config/locales/es-MX/legislation.yml @@ -73,7 +73,7 @@ es-MX: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-NI/legislation.yml b/config/locales/es-NI/legislation.yml index d364ccb00..c112c516c 100644 --- a/config/locales/es-NI/legislation.yml +++ b/config/locales/es-NI/legislation.yml @@ -73,7 +73,7 @@ es-NI: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-PA/legislation.yml b/config/locales/es-PA/legislation.yml index bfade7487..59fc865ce 100644 --- a/config/locales/es-PA/legislation.yml +++ b/config/locales/es-PA/legislation.yml @@ -73,7 +73,7 @@ es-PA: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-PE/legislation.yml b/config/locales/es-PE/legislation.yml index 8732d96eb..1a6088a98 100644 --- a/config/locales/es-PE/legislation.yml +++ b/config/locales/es-PE/legislation.yml @@ -73,7 +73,7 @@ es-PE: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-PR/legislation.yml b/config/locales/es-PR/legislation.yml index 7aa3e0aa0..a8a8daad1 100644 --- a/config/locales/es-PR/legislation.yml +++ b/config/locales/es-PR/legislation.yml @@ -73,7 +73,7 @@ es-PR: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-PY/legislation.yml b/config/locales/es-PY/legislation.yml index 60b9864fa..6d18bb589 100644 --- a/config/locales/es-PY/legislation.yml +++ b/config/locales/es-PY/legislation.yml @@ -73,7 +73,7 @@ es-PY: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-SV/legislation.yml b/config/locales/es-SV/legislation.yml index 528d2ce5e..dae905caa 100644 --- a/config/locales/es-SV/legislation.yml +++ b/config/locales/es-SV/legislation.yml @@ -73,7 +73,7 @@ es-SV: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-UY/legislation.yml b/config/locales/es-UY/legislation.yml index 548cf6f5e..1917fb92e 100644 --- a/config/locales/es-UY/legislation.yml +++ b/config/locales/es-UY/legislation.yml @@ -73,7 +73,7 @@ es-UY: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es-VE/legislation.yml b/config/locales/es-VE/legislation.yml index 38d51b1f7..79528f093 100644 --- a/config/locales/es-VE/legislation.yml +++ b/config/locales/es-VE/legislation.yml @@ -73,7 +73,7 @@ es-VE: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador result_publication_date: Publicación resultados diff --git a/config/locales/es/legislation.yml b/config/locales/es/legislation.yml index 766089a43..18bd8d5ef 100644 --- a/config/locales/es/legislation.yml +++ b/config/locales/es/legislation.yml @@ -82,7 +82,7 @@ es: see_latest_comments: Ver últimas aportaciones see_latest_comments_title: Aportar a este proceso shared: - key_dates: Fechas clave + key_dates: Fases de participación debate_dates: Debate previo draft_publication_date: Publicación borrador allegations_dates: Comentarios From dd8e2d63114b8c7ca12b8b481afc626e2eb700b6 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 27 Dec 2018 20:18:34 +0100 Subject: [PATCH 3/6] Shows participation phases only if there is a phase enabled --- app/models/legislation/process.rb | 4 + .../legislation/processes/_key_dates.html.erb | 110 +++++++++--------- spec/factories/legislations.rb | 19 +++ spec/features/legislation/processes_spec.rb | 17 ++- 4 files changed, 94 insertions(+), 56 deletions(-) diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index e9bfe02a4..be8cc74c3 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -80,6 +80,10 @@ class Legislation::Process < ActiveRecord::Base Legislation::Process::Publication.new(result_publication_date, result_publication_enabled) end + def enabled_phases? + PHASES_AND_PUBLICATIONS.any? { |process| send(process).enabled? } + end + def enabled_phases_and_publications_count PHASES_AND_PUBLICATIONS.count { |process| send(process).enabled? } end diff --git a/app/views/legislation/processes/_key_dates.html.erb b/app/views/legislation/processes/_key_dates.html.erb index 6fbea5053..7181e68cf 100644 --- a/app/views/legislation/processes/_key_dates.html.erb +++ b/app/views/legislation/processes/_key_dates.html.erb @@ -1,65 +1,65 @@ - diff --git a/spec/factories/legislations.rb b/spec/factories/legislations.rb index 79a617d67..e911f574e 100644 --- a/spec/factories/legislations.rb +++ b/spec/factories/legislations.rb @@ -100,6 +100,25 @@ FactoryBot.define do end_date { 1.week.from_now } end + trait :empty do + start_date { Date.current - 5.days } + end_date { Date.current + 5.days } + debate_start_date nil + debate_end_date nil + draft_publication_date nil + allegations_start_date nil + allegations_end_date nil + proposals_phase_start_date nil + proposals_phase_end_date nil + result_publication_date nil + debate_phase_enabled false + allegations_phase_enabled false + proposals_phase_enabled false + draft_publication_enabled false + result_publication_enabled false + published true + end + end factory :legislation_draft_version, class: 'Legislation::DraftVersion' do diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb index 4b71a0ccd..6d732bfd1 100644 --- a/spec/features/legislation/processes_spec.rb +++ b/spec/features/legislation/processes_spec.rb @@ -47,17 +47,32 @@ feature 'Legislation' do end end - scenario 'Key dates are displayed on current locale' do + scenario 'Participation phases are displayed only if there is a phase enabled' do + process = create(:legislation_process, :empty) + process_debate = create(:legislation_process) + + visit legislation_process_path(process) + + expect(page).not_to have_content("Participation phases") + + visit legislation_process_path(process_debate) + + expect(page).to have_content("Participation phases") + end + + scenario 'Participation phases are displayed on current locale' do process = create(:legislation_process, proposals_phase_start_date: Date.new(2018, 01, 01), proposals_phase_end_date: Date.new(2018, 12, 01)) visit legislation_process_path(process) + expect(page).to have_content("Participation phases") expect(page).to have_content("Proposals") expect(page).to have_content("01 Jan 2018 - 01 Dec 2018") visit legislation_process_path(process, locale: "es") + expect(page).to have_content("Fases de participación") expect(page).to have_content("Propuestas") expect(page).to have_content("01 ene 2018 - 01 dic 2018") end From 6a580ede5b68f11c4980172ee0e6c202bf8dbac8 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 27 Dec 2018 20:19:08 +0100 Subject: [PATCH 4/6] Improves layout of admin legislation homepage form --- app/views/admin/legislation/homepages/_form.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/legislation/homepages/_form.html.erb b/app/views/admin/legislation/homepages/_form.html.erb index e6b7cf2f4..aa3ee4151 100644 --- a/app/views/admin/legislation/homepages/_form.html.erb +++ b/app/views/admin/legislation/homepages/_form.html.erb @@ -11,7 +11,7 @@ <%= f.translatable_fields do |translations_form| %> -
+
<%= translations_form.cktext_area :homepage, language: I18n.locale, @@ -22,7 +22,7 @@
<% end %> -
+
<%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
<% end %> From 6b58a71f3fbab597df91bf0d2dca431d3d7fbfcf Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 28 Dec 2018 16:18:11 +0100 Subject: [PATCH 5/6] Shows tabs only on large screens Also moves ::after styles inside breakpoint(large down) to avoid use !important --- .../stylesheets/legislation_process.scss | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index c870b0e32..fd75187f8 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -52,7 +52,7 @@ list-style-type: none; margin: 0 rem-calc(-10); - @include breakpoint(medium) { + @include breakpoint(large) { margin: 0; } @@ -62,7 +62,20 @@ margin: rem-calc(-1) 0; position: relative; - @include breakpoint(medium) { + @include breakpoint(large down) { + + &::after { + content: '\63'; + font-family: "icons" !important; + font-size: rem-calc(24); + pointer-events: none; + position: absolute; + right: 12px; + top: 12px; + } + } + + @include breakpoint(large) { background: #fafafa; display: inline-block; border-bottom: 0; @@ -77,25 +90,15 @@ } &::after { - content: '' !important; + content: ''; } } - &::after { - content: '\63'; - font-family: "icons" !important; - font-size: rem-calc(24); - pointer-events: none; - position: absolute; - right: 12px; - top: 12px; - } - a { display: block; padding: $line-height / 4 $line-height / 2; - @include breakpoint(medium) { + @include breakpoint(large) { display: inline-block; } @@ -118,7 +121,15 @@ background: $highlight; position: relative; - @include breakpoint(medium) { + @include breakpoint(large down) { + + &::after { + content: '\61'; + color: $link; + } + } + + @include breakpoint(large) { background: none; border: 1px solid $border; border-bottom: 0; @@ -126,17 +137,12 @@ &::after { border-bottom: 1px solid #fefefe; bottom: -1px; - content: '' !important; + content: ''; left: 0; position: absolute; width: 100%; } } - - &::after { - content: '\61'; - color: $link; - } } } From 5924a7038559c649ff8d006c34e8626714dd66a9 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 28 Dec 2018 19:36:18 +0100 Subject: [PATCH 6/6] Removes arrow icon on active process phase --- app/assets/stylesheets/legislation_process.scss | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index fd75187f8..990581236 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -121,14 +121,6 @@ background: $highlight; position: relative; - @include breakpoint(large down) { - - &::after { - content: '\61'; - color: $link; - } - } - @include breakpoint(large) { background: none; border: 1px solid $border; @@ -137,12 +129,15 @@ &::after { border-bottom: 1px solid #fefefe; bottom: -1px; - content: ''; left: 0; position: absolute; width: 100%; } } + + &::after { + content: ''; + } } }