From fc1a0f33e76d42d0cee18b2e0ed0d11d034db7e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 21 Apr 2021 14:15:02 +0200 Subject: [PATCH] Add draft info on unpublished budgets Before commit 28caabecd, it was clear which budgets were in draft mode because their phase was "drafting". Now the phase isn't "drafting" anymore, so we have to make it clear somehow that the budget is a draft. I'm using styles similar to the ones we added in commit 2f636eaf7 for completed budgets but at the same time making them slightly different so it's easy to differenciate completed and drafting budgets. --- .../stylesheets/admin/budgets/index.scss | 19 +++++++++++++++++-- .../admin/budgets/index_component.rb | 10 ++++++++-- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 1 + spec/system/admin/budgets_spec.rb | 11 +++++++---- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/admin/budgets/index.scss b/app/assets/stylesheets/admin/budgets/index.scss index 1ce224b76..6de3c0a0b 100644 --- a/app/assets/stylesheets/admin/budgets/index.scss +++ b/app/assets/stylesheets/admin/budgets/index.scss @@ -1,7 +1,7 @@ .admin .budgets-table { - .budget-completed { - @include has-fa-icon(lock, solid); + .budget-completed, + .budget-draft { padding-left: calc(1em + #{rem-calc(10)}); position: relative; @@ -18,10 +18,25 @@ font-size: $tiny-font-size; font-weight: bold; line-height: rem-calc(12); + } + } + + .budget-completed { + @include has-fa-icon(lock, solid); + + span { text-transform: uppercase; } } + .budget-draft { + @include has-fa-icon(pencil-alt, solid); + + span { + font-style: italic; + } + } + td time:last-of-type::after, td small::before { content: ""; diff --git a/app/components/admin/budgets/index_component.rb b/app/components/admin/budgets/index_component.rb index cf6212610..1bf411989 100644 --- a/app/components/admin/budgets/index_component.rb +++ b/app/components/admin/budgets/index_component.rb @@ -31,11 +31,17 @@ class Admin::Budgets::IndexComponent < ApplicationComponent end def status_html_class(budget) - "budget-completed" if budget.finished? + if budget.drafting? + "budget-draft" + elsif budget.finished? + "budget-completed" + end end def status_text(budget) - if budget.finished? + if budget.drafting? + tag.span t("admin.budgets.index.table_draft") + elsif budget.finished? tag.span t("admin.budgets.index.table_completed") end end diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index c101d1bb3..e0f3f20ca 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -80,6 +80,7 @@ en: help: "Participatory budgets allow citizens to propose and decide directly how to spend part of the budget, with monitoring and rigorous evaluation of proposals by the institution." budget_investments: Manage projects table_completed: Completed + table_draft: "Draft" table_duration: "Duration" table_name: Name table_phase: Phase diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index fe424a138..3e6db5a74 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -80,6 +80,7 @@ es: help: "Los presupuestos participativos permiten que los ciudadanos propongan y decidan de manera directa cómo gastar parte del presupuesto, con un seguimiento y evaluación riguroso de las propuestas por parte de la institución." budget_investments: Gestionar proyectos de gasto table_completed: Completado + table_draft: "Borrador" table_duration: "Duración" table_name: Nombre table_phase: Fase diff --git a/spec/system/admin/budgets_spec.rb b/spec/system/admin/budgets_spec.rb index fa9fa8dfa..e6c22ed6b 100644 --- a/spec/system/admin/budgets_spec.rb +++ b/spec/system/admin/budgets_spec.rb @@ -27,7 +27,7 @@ describe "Admin budgets", :admin do end scenario "Filters by phase" do - create(:budget, :drafting, name: "Drafting budget") + create(:budget, :drafting, name: "Unpublished budget") create(:budget, :accepting, name: "Accepting budget") create(:budget, :selecting, name: "Selecting budget") create(:budget, :balloting, name: "Balloting budget") @@ -35,18 +35,21 @@ describe "Admin budgets", :admin do visit admin_budgets_path - expect(page).to have_content "Drafting budget" expect(page).to have_content "Accepting budget" expect(page).to have_content "Selecting budget" expect(page).to have_content "Balloting budget" + within "tr", text: "Unpublished budget" do + expect(page).to have_content "Draft" + end + within "tr", text: "Finished budget" do expect(page).to have_content "COMPLETED" end click_link "Finished" - expect(page).not_to have_content "Drafting budget" + expect(page).not_to have_content "Unpublished budget" expect(page).not_to have_content "Accepting budget" expect(page).not_to have_content "Selecting budget" expect(page).not_to have_content "Balloting budget" @@ -54,7 +57,7 @@ describe "Admin budgets", :admin do click_link "Open" - expect(page).to have_content "Drafting budget" + expect(page).to have_content "Unpublished budget" expect(page).to have_content "Accepting budget" expect(page).to have_content "Selecting budget" expect(page).to have_content "Balloting budget"