diff --git a/app/assets/javascripts/markdown_editor.js.coffee b/app/assets/javascripts/markdown_editor.js.coffee index 1874da5aa..9065717fc 100644 --- a/app/assets/javascripts/markdown_editor.js.coffee +++ b/app/assets/javascripts/markdown_editor.js.coffee @@ -18,6 +18,7 @@ App.MarkdownEditor = $(this).on 'change input paste keyup', -> App.MarkdownEditor.refresh_preview($(this), md) + $('.legislation-draft-versions-edit .warning').show() return $(this).find('.fullscreen-toggle').on 'click', -> diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index 2ab349623..995aedb9e 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -53,4 +53,8 @@ class Legislation::Process < ActiveRecord::Base today >= final_publication_date end end + + def total_comments + questions.map(&:comments_count).sum + end end diff --git a/app/views/admin/legislation/draft_versions/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb index a55bddc66..a217580d6 100644 --- a/app/views/admin/legislation/draft_versions/_form.html.erb +++ b/app/views/admin/legislation/draft_versions/_form.html.erb @@ -27,6 +27,7 @@
<%= f.label :changelog %> + <%= t('admin.legislation.draft_versions.form.use_markdown') %>
<%= f.text_area :changelog, label: false, rows: 5 %> @@ -41,6 +42,7 @@ <% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %> <%= f.radio_button :status, status, label: false %> <%= f.label t("admin.legislation.draft_versions.statuses.#{status}") %> + <%= t("admin.legislation.draft_versions.form.hints.status.#{status}") %>
<% end %>
@@ -52,17 +54,28 @@
<%= f.check_box :final_version, label: false %> + <%= t("admin.legislation.draft_versions.form.hints.final_version") %>
<%= f.label :body %> + <%= t('admin.legislation.draft_versions.form.use_markdown') %>

-
- <%= link_to t("admin.legislation.draft_versions.form.fullscreen_toggle"), "#", class: 'fullscreen-toggle' %> +
+
Consul | Editando Versión 3 del proceso Licencias urbanísticas, declaraciones
+ +
+ Previsualizar + <%= f.submit(class: "button", value: t("admin.legislation.draft_versions.#{admin_submit_action(@draft_version)}.submit_button")) %> +
+ + <%= link_to "#", class: 'fullscreen-toggle' do %> + <%= t("admin.legislation.draft_versions.form.fullscreen_toggle")%> + <% end %>
<%= f.text_area :body, label: false %> @@ -75,9 +88,12 @@
-
-
+
+
<%= f.submit(class: "button expanded", value: t("admin.legislation.draft_versions.#{admin_submit_action(@draft_version)}.submit_button")) %>
+
<% end %> diff --git a/app/views/admin/legislation/draft_versions/edit.html.erb b/app/views/admin/legislation/draft_versions/edit.html.erb index f347101cf..86cbe599f 100644 --- a/app/views/admin/legislation/draft_versions/edit.html.erb +++ b/app/views/admin/legislation/draft_versions/edit.html.erb @@ -1,6 +1,6 @@ -
+
- <%= link_to admin_legislation_process_path(@process), class: "back" do %> + <%= link_to admin_legislation_processes_path, class: "back" do %> <%= t("admin.legislation.draft_versions.edit.back") %> <% end %> @@ -9,13 +9,24 @@ <%= render 'admin/legislation/processes/subnav', process: @process, active: 'draft_versions' %> -

<%= @draft_version.title %>

+
+
+ +
+ +
+

<%= @draft_version.title %>

+
+
+ <%= link_to t("admin.legislation.draft_versions.index.delete"), + admin_legislation_process_draft_version_path(@process, @draft_version), + method: :delete, + class: 'button hollow alert' %> +
+
<%= render 'form', url: admin_legislation_process_draft_version_path(@process, @draft_version) %> - - <%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_draft_version_path(@process, @draft_version), - method: :delete, - class: 'button hollow alert' %> -
diff --git a/app/views/admin/legislation/draft_versions/index.html.erb b/app/views/admin/legislation/draft_versions/index.html.erb index db6a459d2..efb572a7a 100644 --- a/app/views/admin/legislation/draft_versions/index.html.erb +++ b/app/views/admin/legislation/draft_versions/index.html.erb @@ -9,19 +9,27 @@ <%= render 'admin/legislation/processes/subnav', process: @process, active: 'draft_versions' %> - <%= link_to t("admin.legislation.draft_versions.index.create"), - new_admin_legislation_process_draft_version_path, class: "button float-right" %> +
+
+

<%= t("admin.legislation.draft_versions.index.title") %>

+
-

<%= t("admin.legislation.draft_versions.index.title") %>

+
+ <%= link_to t("admin.legislation.draft_versions.index.create"), new_admin_legislation_process_draft_version_path, class: "button" %> +
+
- - - - - - - - +
<%= t("admin.legislation.draft_versions.table.title") %><%= t("admin.legislation.draft_versions.table.created_at") %><%= t("admin.legislation.draft_versions.table.status") %><%= t("admin.legislation.draft_versions.table.comments") %><%= t("admin.legislation.draft_versions.table.final_version") %>
+ + + + + + + + + + <% @process.draft_versions.each do |draft_version| %> <% end %> +
<%= t("admin.legislation.draft_versions.table.title") %><%= t("admin.legislation.draft_versions.table.created_at") %><%= t("admin.legislation.draft_versions.table.status") %><%= t("admin.legislation.draft_versions.table.comments") %><%= t("admin.legislation.draft_versions.table.final_version") %>
@@ -33,6 +41,7 @@ <%= draft_version.final_version %>
diff --git a/app/views/admin/legislation/draft_versions/new.html.erb b/app/views/admin/legislation/draft_versions/new.html.erb index 7f7562339..e6c0e5230 100644 --- a/app/views/admin/legislation/draft_versions/new.html.erb +++ b/app/views/admin/legislation/draft_versions/new.html.erb @@ -9,7 +9,11 @@ <%= render 'admin/legislation/processes/subnav', process: @process, active: 'draft_versions' %> -

<%= t("admin.legislation.draft_versions.new.title") %>

+
+
+

<%= t("admin.legislation.draft_versions.new.title") %>

+
+
<%= render 'form', url: admin_legislation_process_draft_versions_path(@process) %>
diff --git a/app/views/admin/legislation/processes/_form.html.erb b/app/views/admin/legislation/processes/_form.html.erb index fa1ddf54e..d1643747c 100644 --- a/app/views/admin/legislation/processes/_form.html.erb +++ b/app/views/admin/legislation/processes/_form.html.erb @@ -13,7 +13,97 @@
-<% end %> + <% end %> + +
+
+ +
+
+ <%= t('admin.legislation.processes.form.start') %> +
+
+ <%= f.text_field :start_date, + label: false, + class: "js-calendar-full", + id: "start_date" %> +
+
+ <%= t('admin.legislation.processes.form.end') %> +
+
+ <%= f.text_field :end_date, + label: false, + class: "js-calendar-full", + id: "end_date" %> +
+ +
+ +
+
+ <%= t('admin.legislation.processes.form.start') %> +
+
+ <%= f.text_field :debate_start_date, + label: false, + class: "js-calendar-full", + id: "debate_start_date" %> +
+
+ <%= t('admin.legislation.processes.form.end') %> +
+
+ <%= f.text_field :debate_end_date, + label: false, + class: "js-calendar-full", + id: "debate_end_date" %> +
+ +
+ +
+
+ <%= t('admin.legislation.processes.form.start') %> +
+
+ <%= f.text_field :allegations_start_date, + label: false, + class: "js-calendar-full", + id: "allegations_start_date" %> +
+
+ <%= t('admin.legislation.processes.form.end') %> +
+
+ <%= f.text_field :allegations_end_date, + label: false, + class: "js-calendar-full", + id: "allegations_end_date" %> +
+ +
+ <%= f.label :draft_publication_date %> +
+
+ <%= f.text_field :draft_publication_date, + label: false, + class: "js-calendar-full", + id: "draft_publication_date" %> +
+
+ +
+
+ <%= f.label :final_publication_date %> +
+
+ <%= f.text_field :final_publication_date, + label: false, + class: "js-calendar-full", + id: "final_publication_date" %> +
+
@@ -28,6 +118,7 @@
<%= f.label :description %> + <%= t('admin.legislation.processes.form.use_markdown') %>
<%= f.text_area :description, @@ -39,6 +130,7 @@
<%= f.label :target %> + <%= t('admin.legislation.processes.form.use_markdown') %>
<%= f.text_area :target, @@ -50,6 +142,7 @@
<%= f.label :how_to_participate %> + <%= t('admin.legislation.processes.form.use_markdown') %>
<%= f.text_area :how_to_participate, @@ -61,6 +154,7 @@
<%= f.label :additional_info %> + <%= t('admin.legislation.processes.form.use_markdown') %>
<%= f.text_area :additional_info, @@ -70,85 +164,7 @@
-
- <%= f.label :start_date %> -
-
- <%= f.text_field :start_date, - label: false, - class: "js-calendar-full", - id: "start_date" %> -
-
- <%= f.label :end_date %> -
-
- <%= f.text_field :end_date, - label: false, - class: "js-calendar-full", - id: "end_date" %> -
-
- -
-
- <%= f.label :debate_start_date %> -
-
- <%= f.text_field :debate_start_date, - label: false, - class: "js-calendar-full", - id: "debate_start_date" %> -
-
- <%= f.label :debate_end_date %> -
-
- <%= f.text_field :debate_end_date, - label: false, - class: "js-calendar-full", - id: "debate_end_date" %> -
-
- <%= f.label :draft_publication_date %> -
-
- <%= f.text_field :draft_publication_date, - label: false, - class: "js-calendar-full", - id: "draft_publication_date" %> -
-
- <%= f.label :allegations_start_date %> -
-
- <%= f.text_field :allegations_start_date, - label: false, - class: "js-calendar-full", - id: "allegations_start_date" %> -
-
- <%= f.label :allegations_end_date %> -
-
- <%= f.text_field :allegations_end_date, - label: false, - class: "js-calendar-full", - id: "allegations_end_date" %> -
-
- <%= f.label :final_publication_date %> -
-
- <%= f.text_field :final_publication_date, - label: false, - class: "js-calendar-full", - id: "final_publication_date" %> -
-
- -
-
+
<%= f.submit(class: "button expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
diff --git a/app/views/admin/legislation/processes/index.html.erb b/app/views/admin/legislation/processes/index.html.erb index c3ca87c51..ee702028b 100644 --- a/app/views/admin/legislation/processes/index.html.erb +++ b/app/views/admin/legislation/processes/index.html.erb @@ -1,30 +1,42 @@ -<%= link_to t("admin.legislation.processes.index.create"), - new_admin_legislation_process_path, class: "button success float-right" %> +
+
+
+

<%= t("admin.legislation.processes.index.title") %>

+
+
+ <%= link_to t("admin.legislation.processes.index.create"), new_admin_legislation_process_path, class: "button" %> +
+
-

<%= t("admin.legislation.processes.index.title") %>

+ <%= render 'shared/filter_subnav', i18n_namespace: "admin.legislation.processes.index" %> -<%= render 'shared/filter_subnav', i18n_namespace: "admin.legislation.processes.index" %> +

<%= page_entries_info @processes %>

-

<%= page_entries_info @processes %>

+ + + + + + + + + + <% @processes.each do |process| %> + + + + + + <% end %> + +
<%= t("admin.legislation.processes.process.title") %><%= t("admin.legislation.processes.process.comments") %>
+ <%= link_to process.title, edit_admin_legislation_process_path(process) %> + <%= process.total_comments %> + <%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process), + method: :delete, + class: 'button hollow alert' %> +
- - - - - - <% @processes.each do |process| %> - - + <%= paginate @processes %> - - - <% end %> -
<%= t("admin.legislation.processes.process.title") %>
- <%= link_to process.title, edit_admin_legislation_process_path(process) %> - - <%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process), - method: :delete, - class: 'button hollow alert' %> -
- -<%= paginate @processes %> +
diff --git a/app/views/admin/legislation/questions/_form.html.erb b/app/views/admin/legislation/questions/_form.html.erb index f5288b487..cca5ca430 100644 --- a/app/views/admin/legislation/questions/_form.html.erb +++ b/app/views/admin/legislation/questions/_form.html.erb @@ -15,31 +15,29 @@ <% end %> -
-
- <%= f.label :title %> -
-
- <%= f.text_area :title, rows: 5, label: false %> -
+ +
+ <%= f.label :title %> +
+
+ <%= f.text_area :title, rows: 5, label: false %>
-
-
- <%= f.label :question_options %> -
-
- <%= f.fields_for :question_options do |ff| %> - <%= render 'question_option_fields', f: ff %> - <% end %> -
-
- <%= link_to_add_association t('.add_option'), f, :question_options %> -
+
+ <%= f.label :question_options %> +
+
+ <%= f.fields_for :question_options do |ff| %> + <%= render 'question_option_fields', f: ff %> + <% end %> +
+
+ <%= link_to_add_association t('.add_option'), f, :question_options %>
+
-
+
<%= f.submit(class: "button expanded", value: t("admin.legislation.questions.#{admin_submit_action(@question)}.submit_button")) %>
diff --git a/app/views/admin/legislation/questions/_question_option_fields.html.erb b/app/views/admin/legislation/questions/_question_option_fields.html.erb index bfe51288e..0578e65ae 100644 --- a/app/views/admin/legislation/questions/_question_option_fields.html.erb +++ b/app/views/admin/legislation/questions/_question_option_fields.html.erb @@ -1,6 +1,11 @@
- <%= f.text_field :value, label: false %> - <%= link_to_remove_association t('.remove_option'), f %> +
+
+ <%= f.text_field :value, label: false %> +
+
+ <%= link_to_remove_association " #{t('.remove_option')}".html_safe, f %> +
diff --git a/app/views/admin/legislation/questions/edit.html.erb b/app/views/admin/legislation/questions/edit.html.erb index e62479fbb..79a044ec4 100644 --- a/app/views/admin/legislation/questions/edit.html.erb +++ b/app/views/admin/legislation/questions/edit.html.erb @@ -1,6 +1,6 @@
- <%= link_to admin_legislation_process_path(@process), class: "back" do %> + <%= link_to admin_legislation_processes_path, class: "back" do %> <%= t("admin.legislation.questions.edit.back") %> <% end %> @@ -9,12 +9,17 @@ <%= render 'admin/legislation/processes/subnav', process: @process, active: 'questions' %> -

<%= @question.title %>

+
+
+

<%= t("admin.legislation.questions.edit.title", question_title: @question.title) %>

+
+
+ <%= link_to t("admin.legislation.questions.index.delete"), admin_legislation_process_question_path(@process, @question), + method: :delete, + class: 'button hollow alert' %> +
+
<%= render 'form', url: admin_legislation_process_question_path(@process, @question) %> - - <%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_question_path(@process, @question), - method: :delete, - class: 'button hollow alert' %>
diff --git a/app/views/admin/legislation/questions/index.html.erb b/app/views/admin/legislation/questions/index.html.erb index f0a4638ee..a77ffcec7 100644 --- a/app/views/admin/legislation/questions/index.html.erb +++ b/app/views/admin/legislation/questions/index.html.erb @@ -9,18 +9,26 @@ <%= render 'admin/legislation/processes/subnav', process: @process, active: 'questions' %> - <%= link_to t("admin.legislation.questions.index.create"), - new_admin_legislation_process_question_path, class: "button float-right" %> +
+
+

<%= t("admin.legislation.questions.index.title") %>

+
-

<%= t("admin.legislation.questions.index.title") %>

+
+ <%= link_to t("admin.legislation.questions.index.create"), new_admin_legislation_process_question_path, class: "button" %> +
+
- - - - - - - +
<%= t("admin.legislation.questions.table.title") %><%= t("admin.legislation.questions.table.question_options") %><%= t("admin.legislation.questions.table.answers_count") %><%= t("admin.legislation.questions.table.comments_count") %>
+ + + + + + + + + <% @process.questions.each do |question| %> - + <% end %> +
<%= t("admin.legislation.questions.table.title") %><%= t("admin.legislation.questions.table.question_options") %><%= t("admin.legislation.questions.table.answers_count") %><%= t("admin.legislation.questions.table.comments_count") %>
@@ -36,9 +44,10 @@ <% end %> <%= question.answers_count %><%= question.comments.count %><%= link_to question.comments.count, legislation_process_question_path(@process, question, anchor: 'comments') %>
diff --git a/app/views/admin/legislation/questions/new.html.erb b/app/views/admin/legislation/questions/new.html.erb index 7239134e1..ed6e6a3c8 100644 --- a/app/views/admin/legislation/questions/new.html.erb +++ b/app/views/admin/legislation/questions/new.html.erb @@ -9,7 +9,11 @@ <%= render 'admin/legislation/processes/subnav', process: @process, active: 'questions' %> -

<%= t("admin.legislation.questions.new.title") %>

+
+
+

<%= t("admin.legislation.questions.new.title") %>

+
+
<%= render 'form', url: admin_legislation_process_questions_path(@process) %>
diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index e3a3a8aec..e3747d151 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -108,9 +108,10 @@ en: changelog: Changes status: Status final_version: Final version - legislation/questions: + legislation/question: title: "Title" - legislation/question_options: + question_options: Options + legislation/question_option: value: "Value" errors: models: diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index 59fba819b..479c3c004 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -108,9 +108,10 @@ es: changelog: Cambios status: Estado final_version: Versión final - legislation/questions: + legislation/question: title: "Título" - legislation/question_options: + question_options: Respuestas + legislation/question_option: value: "Valor" errors: models: diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index fbecd7bb7..eef45e8ac 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -90,6 +90,13 @@ en: errors: form: error: Error + form: + process: Process + debate_phase: Debate phase + allegations_phase: Allegations phase + start: Start + end: End + use_markdown: Use Markdown to format the text index: create: New process delete: Delete @@ -104,7 +111,8 @@ en: title: Create new collaborative legislation process submit_button: Create process process: - title: Collaborative legislation process title + title: Process + comments: Comments subnav: info: Information draft_texts: Text @@ -113,14 +121,22 @@ en: edit: back: Back submit_button: Save changes + warning: You've edited the text, don't forget to click on Save to permanently save the changes. errors: form: error: Error form: fullscreen_toggle: Toggle full screen + use_markdown: Use Markdown to format the text + hints: + final_version: This version will be published as Final Result for this process. Comments won't be allowed in this version. + status: + draft: You can preview as admin, no one else can see it + published: Visible for everybody index: title: Draft versions create: Create version + delete: Delete new: back: Back title: Create new version @@ -137,6 +153,7 @@ en: questions: edit: back: Back + title: "Edit “%{question_title}”" submit_button: Save changes errors: form: @@ -145,8 +162,9 @@ en: add_option: Add option index: back: Back - title: Questions + title: Questions associated to this process create: Create question + delete: Delete new: back: Back title: Create new question diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index d476b30a2..d2d8e5685 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -88,6 +88,13 @@ es: errors: form: error: Error + form: + process: Proceso + debate_phase: Fase previa + allegations_phase: Fase de alegaciones + start: Inicio + end: Fin + use_markdown: Usa Markdown para formatear el texto index: create: Nuevo proceso delete: Borrar @@ -102,7 +109,8 @@ es: title: Crear nuevo proceso de legislación colaborativa submit_button: Crear proceso process: - title: Título del proceso de legislación colaborativa + title: Proceso + comments: Comentarios subnav: info: Información draft_texts: Texto @@ -111,14 +119,22 @@ es: edit: back: Volver submit_button: Guardar cambios + warning: Ojo, has editado el texto. Para conservar de forma permanente los cambios, no te olvides de hacer click en Guardar. errors: form: error: Error form: fullscreen_toggle: Pantalla completa + use_markdown: Usa Markdown para formatear el texto + hints: + final_version: Será la versión que se publique en Publicación de Resultados. Esta versión no se podrá comentar + status: + draft: Podrás previsualizarlo como logueado, nadie más lo podrá ver + published: Será visible para todo el mundo index: title: Versiones del borrador create: Crear versión + delete: Borrar new: back: Volver title: Crear nueva versión @@ -135,6 +151,7 @@ es: questions: edit: back: Volver + title: "Editar “%{question_title}”" submit_button: Guardar cambios errors: form: @@ -143,8 +160,9 @@ es: add_option: +Añadir respuesta cerrada index: back: Volver - title: Preguntas + title: Preguntas asociadas a este proceso create: Crear pregunta + delete: Borrar new: back: Volver title: Crear nueva pregunta diff --git a/spec/features/admin/legislation/draft_versions_spec.rb b/spec/features/admin/legislation/draft_versions_spec.rb index 287b119ac..0a61f5d97 100644 --- a/spec/features/admin/legislation/draft_versions_spec.rb +++ b/spec/features/admin/legislation/draft_versions_spec.rb @@ -57,7 +57,9 @@ feature 'Admin legislation draft versions' do fill_in 'legislation_draft_version_changelog', with: 'Version 3 changes' fill_in 'legislation_draft_version_body', with: 'Version 3 body' - click_button 'Create version' + within('.primary-buttons') do + click_button 'Create version' + end expect(page).to have_content 'An example legislation process' expect(page).to have_content 'Version 3' diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index 03aae2768..0f1114f51 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -44,15 +44,15 @@ feature 'Admin legislation processes' do fill_in 'legislation_process_how_to_participate', with: 'You can partipate in this thing by doing...' base_date = Date.current - fill_in 'start_date', with: base_date.strftime("%d/%m/%Y") - fill_in 'end_date', with: (base_date + 5.days).strftime("%d/%m/%Y") + fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y") + fill_in 'legislation_process[end_date]', with: (base_date + 5.days).strftime("%d/%m/%Y") - fill_in 'debate_start_date', with: base_date.strftime("%d/%m/%Y") - fill_in 'debate_end_date', with: (base_date + 2.days).strftime("%d/%m/%Y") - fill_in 'draft_publication_date', with: (base_date + 3.days).strftime("%d/%m/%Y") - fill_in 'allegations_start_date', with: (base_date + 3.days).strftime("%d/%m/%Y") - fill_in 'allegations_end_date', with: (base_date + 5.days).strftime("%d/%m/%Y") - fill_in 'final_publication_date', with: (base_date + 7.days).strftime("%d/%m/%Y") + fill_in 'legislation_process[debate_start_date]', with: base_date.strftime("%d/%m/%Y") + fill_in 'legislation_process[debate_end_date]', with: (base_date + 2.days).strftime("%d/%m/%Y") + fill_in 'legislation_process[draft_publication_date]', with: (base_date + 3.days).strftime("%d/%m/%Y") + fill_in 'legislation_process[allegations_start_date]', with: (base_date + 3.days).strftime("%d/%m/%Y") + fill_in 'legislation_process[allegations_end_date]', with: (base_date + 5.days).strftime("%d/%m/%Y") + fill_in 'legislation_process[final_publication_date]', with: (base_date + 7.days).strftime("%d/%m/%Y") click_button 'Create process'