Merge pull request #3801 from consul/refactor_shared_partial

Use the shared partial to render errors
This commit is contained in:
Javier Martín
2019-10-25 15:46:41 +02:00
committed by GitHub
15 changed files with 23 additions and 170 deletions

View File

@@ -1,15 +0,0 @@
<% if @banner.errors.any? %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @banner.errors.count %>
<%= t("admin.banners.errors.form.error", count: @banner.errors.count) %>
</strong>
</div>
<% end %>

View File

@@ -2,7 +2,7 @@
<%= translatable_form_for [:admin, @banner] do |f| %>
<%= render "errors" %>
<%= render "shared/errors", resource: @banner %>
<div class="row">
<% date_started_at = @banner.post_started_at.present? ? I18n.localize(@banner.post_started_at) : "" %>

View File

@@ -1,14 +0,0 @@
<% if @geozone.errors.any? %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @geozone.errors.count %>
<%= t("admin.geozones.errors.form.error", count: @geozone.errors.count) %>
</strong>
</div>
<% end %>

View File

@@ -1,6 +1,6 @@
<%= form_for [:admin, @geozone] do |f| %>
<%= render "errors" %>
<%= render "shared/errors", resource: @geozone %>
<div class="small-12 large-8 column">
<%= f.text_field :name %>

View File

@@ -2,18 +2,7 @@
<%= translatable_form_for [:admin, @process, @draft_version], url: url, html: { data: { watch_changes: true }} do |f| %>
<% if @draft_version.errors.any? %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @draft_version.errors.count %>
<%= t("admin.legislation.draft_versions.errors.form.error", count: @draft_version.errors.count) %>
</strong>
</div>
<% end %>
<%= render "shared/errors", resource: @draft_version %>
<div class="row">
<%= f.translatable_fields do |translations_form| %>

View File

@@ -2,20 +2,8 @@
<%= translatable_form_for [:admin, @process], html: { data: { watch_changes: true } } do |f| %>
<% if @process.errors.any? %>
<%= render "shared/errors", resource: @process %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @process.errors.count %>
<%= t("admin.legislation.processes.errors.form.error", count: @process.errors.count) %>
</strong>
</div>
<% end %>
<div class="row">
<div class="small-12 medium-4 column">
<label><%= t("admin.legislation.processes.form.draft_phase") %></label>

View File

@@ -1,19 +1,6 @@
<%= form_for [:admin, @process], html: { data: { watch_changes: true } } do |f| %>
<% if @process.errors.any? %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @process.errors.count %>
<%= t("admin.legislation.processes.errors.form.error", count: @process.errors.count) %>
</strong>
</div>
<% end %>
<%= render "shared/errors", resource: @process %>
<div class="small-12 medium-8 column">
<%= f.text_field :custom_list, value: @process.tag_list_on(:customs).to_s,

View File

@@ -2,20 +2,7 @@
<%= translatable_form_for [:admin, @process, @question], url: url, html: { data: { watch_changes: true } } do |f| %>
<% if @question.errors.any? %>
<div class="small-12 medium-9 column">
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @question.errors.count %>
<%= t("admin.legislation.questions.errors.form.error", count: @question.errors.count) %>
</strong>
</div>
</div>
<% end %>
<%= render "shared/errors", resource: @question %>
<div class="row">
<%= f.translatable_fields do |translations_form| %>

View File

@@ -1,19 +1,6 @@
<%= form_for [:admin, @content_block], html: { class: "edit_page", data: { watch_changes: true } } do |f| %>
<% if @content_block.errors.any? %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @content_block.errors.count %>
<%= t("admin.site_customization.content_blocks.errors.form.error", count: @content_block.errors.count) %>
</strong>
</div>
<% end %>
<%= render "shared/errors", resource: @content_block %>
<div class="small-12 medium-6 column">
<%= f.select :name, options_for_select(valid_blocks, @selected_content_block) %>

View File

@@ -1,15 +1,5 @@
<%= form_tag(admin_site_customization_update_heading_content_block_path(@content_block.id), method: "put") do %>
<% if @content_block.errors.any? %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<strong>
<%= @content_block.errors.count %>
<%= t("admin.site_customization.content_blocks.errors.form.error", count: @content_block.errors.count) %>
</strong>
</div>
<% end %>
<%= render "shared/errors", resource: @content_block %>
<div class="small-12 medium-6 column">
<%= label_tag :name %>

View File

@@ -1,18 +1,8 @@
<%= render "shared/globalize_locales", resource: @page %>
<%= translatable_form_for [:admin, @page], html: { class: "edit_page", data: { watch_changes: true } } do |f| %>
<% if @page.errors.any? %>
<div id="error_explanation" data-alert class="callout alert" data-closable>
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<%= render "shared/errors", resource: @page %>
<strong>
<%= @page.errors.count %>
<%= t("admin.site_customization.pages.errors.form.error", count: @page.errors.count) %>
</strong>
</div>
<% end %>
<div class="row">
<div class="small-12 column">
<hr>

View File

@@ -39,11 +39,6 @@ en:
editing: Edit banner
form:
submit_button: Save changes
errors:
form:
error:
one: "error prevented this banner from being saved"
other: "errors prevented this banner from being saved"
new:
creating: Create banner
activity:
@@ -472,9 +467,6 @@ en:
edit:
back: Back
submit_button: Save changes
errors:
form:
error: Error
form:
enabled: Enabled
process: Process
@@ -551,9 +543,6 @@ en:
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:
title: 'Editing <span class="strong">%{draft_version_title}</span> from the process <span class="strong">%{process_title}</span>'
launch_text_editor: Launch text editor
@@ -595,9 +584,6 @@ en:
back: Back
title: "Edit “%{question_title}”"
submit_button: Save changes
errors:
form:
error: Error
form:
add_option: Add option
title_placeholder: Add question
@@ -1329,11 +1315,6 @@ en:
code_help: Response code for this geozone on the census API
coordinates: Coordinates
coordinates_help: Coordinates that will generate a clickable area on an HTML image map
errors:
form:
error:
one: "error prevented this geozone from being saved"
other: "errors prevented this geozone from being saved"
edit:
form:
submit_button: Save changes
@@ -1490,9 +1471,6 @@ en:
notice: Content block deleted successfully
edit:
title: Editing content block
errors:
form:
error: Error
index:
create: Create new content block
delete: Delete block
@@ -1530,9 +1508,6 @@ en:
notice: Page deleted successfully
edit:
title: Editing %{page_title}
errors:
form:
error: Error
form:
options: Options
index:

View File

@@ -171,11 +171,16 @@ en:
errors: errors
not_saved: "prevented this %{resource} from being saved. <br>Please check the marked fields to know how to correct them:"
policy: Privacy Policy
banner: banner
proposal: Proposal
proposal_notification: "Notification"
budget/investment: Investment
budget/group: Budget Group
budget/heading: Budget Heading
geozone: geozone
legislation/draft_version: draft
legislation/process: process
legislation/question: question
poll/shift: Shift
poll/question/answer: Answer
user: Account
@@ -186,6 +191,8 @@ en:
image: Image
local_census_record: Local Census Record
local_census_records/import: Local Census Records Import
site_customization/content_block: content block
site_customization/page: page
geozones:
none: All city
layouts:

View File

@@ -39,11 +39,6 @@ es:
editing: Editar el banner
form:
submit_button: Guardar cambios
errors:
form:
error:
one: "error impidió guardar el banner"
other: "errores impidieron guardar el banner."
new:
creating: Crear banner
activity:
@@ -472,9 +467,6 @@ es:
edit:
back: Volver
submit_button: Guardar cambios
errors:
form:
error: Error
form:
enabled: Habilitado
process: Proceso
@@ -550,9 +542,6 @@ es:
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:
title: 'Editando <span class="strong">%{draft_version_title}</span> del proceso <span class="strong">%{process_title}</span>'
launch_text_editor: Lanzar editor de texto
@@ -594,9 +583,6 @@ es:
back: Volver
title: "Editar “%{question_title}”"
submit_button: Guardar cambios
errors:
form:
error: Error
form:
add_option: Añadir respuesta cerrada
title_placeholder: Escribe un título a la pregunta
@@ -1328,11 +1314,6 @@ es:
code_help: Código de respuesta para esta zona en la API del censo
coordinates: Coordenadas
coordinates_help: Coordenadas que generarán una zona clicable en un mapa de imagen HTML
errors:
form:
error:
one: "error impidió guardar la zona."
other: "errores impidieron guardar la zona."
edit:
form:
submit_button: Guardar cambios
@@ -1489,9 +1470,6 @@ es:
notice: Bloque borrado correctamente
edit:
title: Editar bloque
errors:
form:
error: Error
index:
create: Crear nuevo bloque
delete: Borrar bloque
@@ -1529,9 +1507,6 @@ es:
notice: Página eliminada correctamente
edit:
title: Editar %{page_title}
errors:
form:
error: Error
form:
options: Opciones
index:

View File

@@ -171,11 +171,16 @@ es:
errors: errores
not_saved: "impidieron guardar %{resource}. <br>Por favor revisa los campos marcados para saber cómo corregirlos:"
policy: Política de privacidad
banner: el banner
proposal: la propuesta
proposal_notification: "la notificación"
budget/investment: el proyecto de gasto
budget/group: el grupo de partidas presupuestarias
budget/heading: la partida presupuestaria
geozone: la zona
legislation/draft_version: el borrador
legislation/process: el proceso
legislation/question: la pregunta
poll/shift: el turno
poll/question/answer: la respuesta
user: la cuenta
@@ -186,6 +191,8 @@ es:
image: Imagen
local_census_record: el registro del censo local
local_census_records/import: la importación de registros del censo local
site_customization/content_block: el bloque
site_customization/page: la página
geozones:
none: Toda la ciudad
layouts: