From c811fd46f07c678a8077e031f291d1bd89b24abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 13 Sep 2017 15:48:07 +0200 Subject: [PATCH] Proposals description migration and form - Added to legislation processes a new attribute called `proposals_description`. - Then created new views to show a form for the `@process` to edit this attribute **from in the proposals section**. - Completed translations for new views. --- .../admin/legislation/processes_controller.rb | 5 +-- .../legislation/processes/_subnav.html.erb | 5 ++- .../legislation/proposals/_form.html.erb | 36 +++++++++++++++++++ .../legislation/proposals/index.html.erb | 16 +++++++++ config/locales/en/admin.yml | 9 +++++ config/locales/es/admin.yml | 9 +++++ ...ls_description_to_legislation_processes.rb | 5 +++ db/schema.rb | 3 +- 8 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 app/views/admin/legislation/proposals/_form.html.erb create mode 100644 app/views/admin/legislation/proposals/index.html.erb create mode 100644 db/migrate/20170913130803_add_proposals_description_to_legislation_processes.rb diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index da27f9955..f316d9b65 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -20,7 +20,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll def update if @process.update(process_params) link = legislation_process_path(@process).html_safe - redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: link) + redirect_to :back, notice: t('admin.legislation.processes.update.notice', link: link) else flash.now[:error] = t('admin.legislation.processes.update.error') render :edit @@ -55,7 +55,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll :proposals_phase_enabled, :draft_publication_enabled, :result_publication_enabled, - :published + :published, + :proposals_description ) end end diff --git a/app/views/admin/legislation/processes/_subnav.html.erb b/app/views/admin/legislation/processes/_subnav.html.erb index 97640c4f4..56b668641 100644 --- a/app/views/admin/legislation/processes/_subnav.html.erb +++ b/app/views/admin/legislation/processes/_subnav.html.erb @@ -2,9 +2,12 @@
  • > <%= link_to t("admin.legislation.processes.subnav.info"), edit_admin_legislation_process_path(process) %>
  • -
  • > +
  • > <%= link_to t("admin.legislation.processes.subnav.questions"), admin_legislation_process_questions_path(process) %>
  • +
  • > + <%= link_to t("admin.legislation.processes.subnav.proposals"), admin_legislation_process_proposals_path(process) %> +
  • > <%= link_to t("admin.legislation.processes.subnav.draft_texts"), admin_legislation_process_draft_versions_path(process) %>
  • diff --git a/app/views/admin/legislation/proposals/_form.html.erb b/app/views/admin/legislation/proposals/_form.html.erb new file mode 100644 index 000000000..30f7f4950 --- /dev/null +++ b/app/views/admin/legislation/proposals/_form.html.erb @@ -0,0 +1,36 @@ +<%= form_for [:admin, @process], html: {data: {watch_changes: true}} do |f| %> + + <% if @process.errors.any? %> + +
    + + + + <%= @process.errors.count %> + <%= t("admin.legislation.processes.errors.form.error", count: @process.errors.count) %> + +
    + + <% end %> + +
    +
    + <%= label_tag t('admin.legislation.proposals.form.header_information') %> + <%= t('admin.legislation.proposals.form.header_information_description') %> +
    +
    + <%= f.text_area :proposals_description, + label: false, + rows: 5, + placeholder: t('admin.legislation.proposals.form.header_information_placeholder') %> +
    +
    + +
    +
    + <%= f.submit(class: "button expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %> +
    +
    +<% end %> diff --git a/app/views/admin/legislation/proposals/index.html.erb b/app/views/admin/legislation/proposals/index.html.erb new file mode 100644 index 000000000..162f3c8dd --- /dev/null +++ b/app/views/admin/legislation/proposals/index.html.erb @@ -0,0 +1,16 @@ +<% provide :title do %> + Admin - <%= t("admin.menu.legislation") %> - <%= @process.title %> - <%= t("admin.legislation.proposals.index.title") %> +<% end %> + +
    +
    + <%= back_link_to admin_legislation_processes_path, t("admin.legislation.proposals.index.back") %> + +

    <%= @process.title %>

    + + <%= render 'admin/legislation/processes/subnav', process: @process, active: 'proposals' %> + + <%= render "form" %> + +
    +
    diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 3793b75a8..275d628e5 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -291,6 +291,15 @@ en: info: Information draft_texts: Text questions: Debate + proposals: Proposals + proposals: + index: + title: Proposals + back: Back + form: + header_information: Information header + header_information_description: Provide information about the proposals. This text will be displayed as an alert in the Proposals section inside this Process. Use Markdown to format the text. + header_information_placeholder: Add information for the proposals' header draft_versions: create: notice: 'Draft created successfully. Click to visit' diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 27262845d..54ab2ce8f 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -291,6 +291,15 @@ es: info: Información draft_texts: Texto questions: Debate + proposals: Propuestas + proposals: + index: + title: Propuestas + back: Volver + form: + header_information: Encabezado de información + header_information_description: Proporciona información sobre el recorrido de las propuestas. Este texto se mostrará como una alerta en el encabezado de la sección de Propuestas dentro de este proceso. Usa Markdown para formatear el texto. + header_information_placeholder: Añade información para el encabezado de las las propuestas draft_versions: create: notice: 'Borrador creado correctamente. Haz click para verlo' diff --git a/db/migrate/20170913130803_add_proposals_description_to_legislation_processes.rb b/db/migrate/20170913130803_add_proposals_description_to_legislation_processes.rb new file mode 100644 index 000000000..d5e4f9c5d --- /dev/null +++ b/db/migrate/20170913130803_add_proposals_description_to_legislation_processes.rb @@ -0,0 +1,5 @@ +class AddProposalsDescriptionToLegislationProcesses < ActiveRecord::Migration + def change + add_column :legislation_processes, :proposals_description, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 578a0bc25..5b84833a7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170913101029) do +ActiveRecord::Schema.define(version: 20170913130803) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -473,6 +473,7 @@ ActiveRecord::Schema.define(version: 20170913101029) do t.date "proposals_phase_start_date" t.date "proposals_phase_end_date" t.boolean "proposals_phase_enabled" + t.text "proposals_description" end add_index "legislation_processes", ["allegations_end_date"], name: "index_legislation_processes_on_allegations_end_date", using: :btree