Extract partial for edit and destroy links

This commit is contained in:
Javi Martín
2020-06-06 18:28:45 +02:00
parent 289eb96561
commit 4e60424678
25 changed files with 45 additions and 196 deletions

View File

@@ -30,27 +30,14 @@
</td> </td>
<td> <td>
<% if admin_notification.draft? %> <% if admin_notification.draft? %>
<div class="small-4 column"> <%= render "shared/table_actions", record: admin_notification, actions: [:edit, :destroy] %>
<%= link_to t("admin.admin_notifications.index.edit"),
edit_admin_admin_notification_path(admin_notification),
class: "button expanded hollow" %>
</div>
<div class="small-4 column">
<%= link_to t("admin.admin_notifications.index.delete"),
admin_admin_notification_path(admin_notification),
method: :delete, class: "button expanded hollow alert" %>
</div>
<div class="small-4 column">
<%= link_to t("admin.admin_notifications.index.preview"), <%= link_to t("admin.admin_notifications.index.preview"),
admin_admin_notification_path(admin_notification), admin_admin_notification_path(admin_notification),
class: "button expanded" %> class: "button" %>
</div>
<% else %> <% else %>
<div class="small-4 column">
<%= link_to t("admin.admin_notifications.index.view"), <%= link_to t("admin.admin_notifications.index.view"),
admin_admin_notification_path(admin_notification), admin_admin_notification_path(admin_notification),
class: "button expanded" %> class: "button" %>
</div>
<% end %> <% end %>
</td> </td>
</tr> </tr>

View File

@@ -29,13 +29,7 @@
<%= administrator.description %> <%= administrator.description %>
</td> </td>
<td> <td>
<%= link_to t("admin.actions.edit"), <%= render "shared/table_actions", record: administrator, actions: [:edit, :destroy] %>
edit_admin_administrator_path(administrator),
class: "button hollow" %>
<%= link_to t("admin.administrators.administrator.delete"),
admin_administrator_path(administrator),
method: :delete,
class: "button hollow alert" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -19,10 +19,7 @@
<td><%= user.email %></td> <td><%= user.email %></td>
<td class="text-right"> <td class="text-right">
<% if user.administrator? && user.administrator.persisted? %> <% if user.administrator? && user.administrator.persisted? %>
<%= link_to t("admin.administrators.administrator.delete"), <%= render "shared/table_actions", record: user.administrator, actions: [:destroy] %>
admin_administrator_path(user.administrator),
method: :delete,
class: "button hollow alert expanded" %>
<% else %> <% else %>
<%= link_to t("admin.administrators.administrator.add"), <%= link_to t("admin.administrators.administrator.add"),
{ controller: "admin/administrators", { controller: "admin/administrators",

View File

@@ -29,13 +29,7 @@
<td><%= link_to t("admin.budget_groups.headings_manage"), <td><%= link_to t("admin.budget_groups.headings_manage"),
admin_budget_group_headings_path(@budget, group) %></td> admin_budget_group_headings_path(@budget, group) %></td>
<td> <td>
<%= link_to t("admin.actions.edit"), <%= render "shared/table_actions", record: group, actions: [:edit, :destroy] %>
edit_admin_budget_group_path(@budget, group),
class: "button hollow" %>
<%= link_to t("admin.actions.delete"),
admin_budget_group_path(@budget, group),
method: :delete,
class: "button hollow alert" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -34,13 +34,7 @@
<%= heading.allow_custom_content ? t("admin.shared.true_value") : t("admin.shared.false_value") %> <%= heading.allow_custom_content ? t("admin.shared.true_value") : t("admin.shared.false_value") %>
</td> </td>
<td> <td>
<%= link_to t("admin.actions.edit"), <%= render "shared/table_actions", record: heading, actions: [:edit, :destroy] %>
edit_admin_budget_group_heading_path(@budget, @group, heading),
class: "button hollow" %>
<%= link_to t("admin.actions.delete"),
admin_budget_group_heading_path(@budget, @group, heading),
method: :delete,
class: "button hollow alert" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -32,14 +32,7 @@
<td class="text-center"><%= number_with_delimiter(action.required_supports, delimiter: ".") %></td> <td class="text-center"><%= number_with_delimiter(action.required_supports, delimiter: ".") %></td>
<td class="text-center"><%= action.order %></td> <td class="text-center"><%= action.order %></td>
<td class="text-right"> <td class="text-right">
<%= link_to t("admin.dashboard.actions.index.edit"), <%= render "shared/table_actions", record: action, actions: [:edit, :destroy] %>
edit_admin_dashboard_action_path(action),
class: "button hollow" %>
<%= link_to t("admin.dashboard.actions.index.delete"),
admin_dashboard_action_path(action),
method: :delete,
class: "button hollow alert",
data: { confirm: t("admin.actions.confirm") } %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -22,17 +22,7 @@
<td><%= geozone.census_code %></td> <td><%= geozone.census_code %></td>
<td class="break"><%= geozone.html_map_coordinates %></td> <td class="break"><%= geozone.html_map_coordinates %></td>
<td> <td>
<div class="small-6 column"> <%= render "shared/table_actions", record: geozone, actions: [:edit, :destroy] %>
<%= link_to t("admin.geozones.index.edit"),
edit_admin_geozone_path(geozone),
class: "button hollow expanded" %>
</div>
<div class="small-6 column">
<%= link_to t("admin.geozones.index.delete"),
admin_geozone_path(geozone),
method: :delete,
class: "button hollow alert expanded" %>
</div>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -17,14 +17,6 @@
<% end %> <% end %>
</td> </td>
<td> <td>
<%= link_to t("admin.actions.edit"), <%= render "shared/table_actions", record: card, actions: [:edit, :destroy] %>
edit_admin_widget_card_path(card),
class: "button hollow" %>
<%= link_to t("admin.actions.delete"),
admin_widget_card_path(card),
method: :delete,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow alert" %>
</td> </td>
</tr> </tr>

View File

@@ -35,9 +35,7 @@
<td class="text-center"><%= I18n.l process.end_date %></td> <td class="text-center"><%= I18n.l process.end_date %></td>
<td class="text-center"><%= process.total_comments %></td> <td class="text-center"><%= process.total_comments %></td>
<td> <td>
<%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process), <%= render "shared/table_actions", record: process, actions: [:destroy] %>
method: :delete,
class: "button hollow alert expanded" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -12,14 +12,6 @@
<%= local_census_record.postal_code %> <%= local_census_record.postal_code %>
</td> </td>
<td> <td>
<%= link_to t("admin.actions.edit"), <%= render "shared/table_actions", record: local_census_record, actions: [:edit, :destroy] %>
edit_admin_local_census_record_path(local_census_record),
class: "button hollow" %>
<%= link_to t("admin.actions.delete"),
admin_local_census_record_path(local_census_record),
method: :delete,
class: "button hollow alert",
data: { confirm: t("admin.actions.confirm") } %>
</td> </td>
</tr> </tr>

View File

@@ -22,10 +22,7 @@
<%= manager.email %> <%= manager.email %>
</td> </td>
<td> <td>
<%= link_to t("admin.managers.manager.delete"), <%= render "shared/table_actions", record: manager, actions: [:destroy] %>
admin_manager_path(manager),
method: :delete,
class: "button hollow alert expanded" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -19,10 +19,7 @@
<td><%= user.email %></td> <td><%= user.email %></td>
<td> <td>
<% if user.manager? && user.manager.persisted? %> <% if user.manager? && user.manager.persisted? %>
<%= link_to t("admin.managers.manager.delete"), <%= render "shared/table_actions", record: user.manager, actions: [:destroy] %>
admin_manager_path(user.manager),
method: :delete,
class: "button hollow alert expanded" %>
<% else %> <% else %>
<%= link_to t("admin.managers.manager.add"), <%= link_to t("admin.managers.manager.add"),
{ controller: "admin/managers", { controller: "admin/managers",

View File

@@ -23,12 +23,7 @@
<%= status.description %> <%= status.description %>
</td> </td>
<td> <td>
<%= link_to t("admin.statuses.index.edit"), <%= render "shared/table_actions", record: status, actions: [:edit, :destroy] %>
edit_admin_milestone_status_path(status),
class: "button hollow" %>
<%= link_to t("admin.statuses.index.delete"),
admin_milestone_status_path(status),
method: :delete, class: "button hollow alert" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -24,10 +24,7 @@
<%= moderator.email %> <%= moderator.email %>
</td> </td>
<td> <td>
<%= link_to t("admin.moderators.moderator.delete"), <%= render "shared/table_actions", record: moderator, actions: [:destroy] %>
admin_moderator_path(moderator),
method: :delete,
class: "button hollow alert expanded" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -19,10 +19,7 @@
<td><%= user.email %></td> <td><%= user.email %></td>
<td> <td>
<% if user.moderator? && user.moderator.persisted? %> <% if user.moderator? && user.moderator.persisted? %>
<%= link_to t("admin.moderators.moderator.delete"), <%= render "shared/table_actions", record: user.moderator, actions: [:destroy] %>
admin_moderator_path(user.moderator),
method: :delete,
class: "button hollow alert expanded" %>
<% else %> <% else %>
<%= link_to t("admin.moderators.moderator.add"), <%= link_to t("admin.moderators.moderator.add"),
{ controller: "admin/moderators", { controller: "admin/moderators",

View File

@@ -29,18 +29,10 @@
<% end %> <% end %>
</td> </td>
<td> <td>
<div class="small-4 column"> <%= render "shared/table_actions", record: newsletter, actions: [:edit, :destroy] %>
<%= link_to t("admin.newsletters.index.edit"), edit_admin_newsletter_path(newsletter),
class: "button hollow expanded" %>
</div>
<div class="small-4 column">
<%= link_to t("admin.newsletters.index.delete"), admin_newsletter_path(newsletter),
method: :delete, class: "button hollow alert expanded" %>
</div>
<div class="small-4 column">
<%= link_to t("admin.newsletters.index.preview"), admin_newsletter_path(newsletter), <%= link_to t("admin.newsletters.index.preview"), admin_newsletter_path(newsletter),
class: "button expanded" %> class: "button" %>
</div>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -30,19 +30,9 @@
<% end %> <% end %>
</td> </td>
<td> <td>
<div class="small-4 column">
<%= link_to t("admin.polls.show.edit_answers"), admin_question_path(question), <%= link_to t("admin.polls.show.edit_answers"), admin_question_path(question),
class: "button hollow expanded" %> class: "button hollow" %>
</div> <%= render "shared/table_actions", record: question, actions: [:edit, :destroy] %>
<div class="small-4 column">
<%= link_to t("shared.edit"), edit_admin_question_path(question),
class: "button hollow expanded" %>
</div>
<div class="small-4 column">
<%= link_to t("shared.delete"), admin_question_path(question),
class: "button hollow alert expanded",
method: :delete %>
</div>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -27,12 +27,7 @@
<% end %> <% end %>
</td> </td>
<td> <td>
<div class="small-6 column"> <%= render "shared/table_actions", record: question, actions: [:edit, :destroy] %>
<%= link_to t("shared.edit"), edit_admin_question_path(question), class: "button hollow expanded" %>
</div>
<div class="small-6 column">
<%= link_to t("shared.delete"), admin_question_path(question), class: "button hollow alert expanded", method: :delete %>
<div class="small-6 column">
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -29,15 +29,7 @@
<td><%= video.title %></td> <td><%= video.title %></td>
<td><%= link_to "#{video.url}", video.url %></td> <td><%= link_to "#{video.url}", video.url %></td>
<td class="text-right"> <td class="text-right">
<%= render "shared/table_actions", record: video, actions: [:edit, :destroy] %>
<%= link_to t("shared.edit"),
edit_admin_video_path(video),
class: "button hollow" %>
<%= link_to t("shared.delete"),
admin_video_path(video),
class: "button hollow alert",
method: :delete %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -36,14 +36,7 @@
<%= number_to_percentage(progress_bar.percentage, strip_insignificant_zeros: true) %> <%= number_to_percentage(progress_bar.percentage, strip_insignificant_zeros: true) %>
</td> </td>
<td> <td>
<%= link_to t("admin.actions.edit"), <%= render "shared/table_actions", record: progress_bar, actions: [:edit, :destroy] %>
admin_polymorphic_path(progress_bar, action: :edit),
class: "button hollow" %>
<%= link_to t("admin.actions.delete"),
admin_polymorphic_path(progress_bar),
method: :delete,
class: "button hollow alert" %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -6,12 +6,6 @@
<%= group.valuators.count %> <%= group.valuators.count %>
</td> </td>
<td> <td>
<%= link_to t("admin.actions.delete"), <%= render "shared/table_actions", record: group, actions: [:edit, :destroy] %>
admin_valuator_group_path(group),
method: :delete, class: "button hollow alert" %>
<%= link_to t("admin.actions.edit"),
edit_admin_valuator_group_path(group),
class: "button hollow" %>
</td> </td>
</tr> </tr>

View File

@@ -19,12 +19,6 @@
<%= valuator_abilities(valuator) %> <%= valuator_abilities(valuator) %>
</td> </td>
<td> <td>
<%= link_to t("admin.actions.edit"), <%= render "shared/table_actions", record: valuator, actions: [:edit, :destroy] %>
edit_admin_valuator_path(valuator),
class: "button hollow" %>
<%= link_to t("admin.valuators.valuator.delete"),
admin_valuator_path(valuator),
method: :delete,
class: "button hollow alert" %>
</td> </td>
</tr> </tr>

View File

@@ -0,0 +1,13 @@
<% if actions.include?(:edit) %>
<%= link_to t("admin.actions.edit"),
admin_polymorphic_path(record, action: :edit),
class: "button hollow" %>
<% end %>
<% if actions.include?(:destroy) %>
<%= link_to t("admin.actions.delete"),
admin_polymorphic_path(record),
method: :delete,
class: "button hollow alert",
data: { confirm: t("admin.actions.confirm") } %>
<% end %>

View File

@@ -297,8 +297,6 @@ en:
table_name: Name table_name: Name
table_description: Description table_description: Description
table_actions: Actions table_actions: Actions
delete: Delete
edit: Edit
edit: edit:
title: Edit milestone status title: Edit milestone status
update: update:
@@ -362,7 +360,6 @@ en:
description: "When users create proposals they can access a dashboard of their proposal, where you can propose resources and recommendations to get support for their idea." description: "When users create proposals they can access a dashboard of their proposal, where you can propose resources and recommendations to get support for their idea."
create: Create resource or action create: Create resource or action
edit: Edit edit: Edit
delete: Delete
active: 'Yes' active: 'Yes'
inactive: 'No' inactive: 'No'
title: Resources and actions title: Resources and actions
@@ -497,7 +494,6 @@ en:
banner_title: Header colors banner_title: Header colors
index: index:
create: New process create: New process
delete: Delete
title: Collaborative legislation title: Collaborative legislation
filters: filters:
active: Active active: Active
@@ -629,7 +625,6 @@ en:
no_managers: There are no managers. no_managers: There are no managers.
manager: manager:
add: Add add: Add
delete: Delete
search: search:
title: "Managers: User search" title: "Managers: User search"
menu: menu:
@@ -709,7 +704,6 @@ en:
no_administrators: There are no administrators. no_administrators: There are no administrators.
administrator: administrator:
add: Add add: Add
delete: Delete
restricted_removal: "Sorry, you can't remove yourself from the administrators" restricted_removal: "Sorry, you can't remove yourself from the administrators"
search: search:
title: "Administrators: User search" title: "Administrators: User search"
@@ -724,7 +718,6 @@ en:
no_moderators: There are no moderators. no_moderators: There are no moderators.
moderator: moderator:
add: Add add: Add
delete: Delete
search: search:
title: "Moderators: User search" title: "Moderators: User search"
segment_recipient: segment_recipient:
@@ -751,8 +744,6 @@ en:
sent: Sent sent: Sent
actions: Actions actions: Actions
draft: Draft draft: Draft
edit: Edit
delete: Delete
preview: Preview preview: Preview
empty_newsletters: There are no newsletters to show empty_newsletters: There are no newsletters to show
new: new:
@@ -788,8 +779,6 @@ en:
sent: Sent sent: Sent
actions: Actions actions: Actions
draft: Draft draft: Draft
edit: Edit
delete: Delete
preview: Preview preview: Preview
view: View view: View
empty_notifications: There are no notifications to show empty_notifications: There are no notifications to show
@@ -887,7 +876,6 @@ en:
can_edit_dossier: "Can edit dossier" can_edit_dossier: "Can edit dossier"
valuator: valuator:
add: Add to valuators add: Add to valuators
delete: Delete
search: search:
title: "Valuators: User search" title: "Valuators: User search"
form: form:
@@ -1309,8 +1297,6 @@ en:
index: index:
title: Geozone title: Geozone
create: Create geozone create: Create geozone
edit: Edit
delete: Delete
geozone: geozone:
name: Name name: Name
external_code: External code external_code: External code

View File

@@ -297,8 +297,6 @@ es:
table_name: Nombre table_name: Nombre
table_description: Descripción table_description: Descripción
table_actions: Acciones table_actions: Acciones
delete: Borrar
edit: Editar
edit: edit:
title: Editar estado de seguimiento title: Editar estado de seguimiento
update: update:
@@ -362,7 +360,6 @@ es:
description: "Cuando los usuarios crean propuestas pueden acceder a un panel de progreso de su propuesta, donde se le puede proponer recursos y recomendaciones para conseguir apoyos a su idea." description: "Cuando los usuarios crean propuestas pueden acceder a un panel de progreso de su propuesta, donde se le puede proponer recursos y recomendaciones para conseguir apoyos a su idea."
create: Crear recurso o acción create: Crear recurso o acción
edit: Editar edit: Editar
delete: Borrar
active: 'Si' active: 'Si'
inactive: 'No' inactive: 'No'
title: Recursos y acciones title: Recursos y acciones
@@ -497,7 +494,6 @@ es:
banner_title: Colores del encabezado banner_title: Colores del encabezado
index: index:
create: Nuevo proceso create: Nuevo proceso
delete: Borrar
title: Procesos de legislación colaborativa title: Procesos de legislación colaborativa
filters: filters:
active: Activos active: Activos
@@ -628,7 +624,6 @@ es:
no_managers: No hay gestores. no_managers: No hay gestores.
manager: manager:
add: Añadir como gestor add: Añadir como gestor
delete: Borrar
search: search:
title: "Gestores: Búsqueda de usuarios" title: "Gestores: Búsqueda de usuarios"
menu: menu:
@@ -708,7 +703,6 @@ es:
no_administrators: No hay administradores. no_administrators: No hay administradores.
administrator: administrator:
add: Añadir como Administrador add: Añadir como Administrador
delete: Borrar
restricted_removal: "Lo sentimos, no puedes eliminarte a ti mismo de la lista" restricted_removal: "Lo sentimos, no puedes eliminarte a ti mismo de la lista"
search: search:
title: "Administradores: Búsqueda de usuarios" title: "Administradores: Búsqueda de usuarios"
@@ -723,7 +717,6 @@ es:
no_moderators: No hay moderadores. no_moderators: No hay moderadores.
moderator: moderator:
add: Añadir como Moderador add: Añadir como Moderador
delete: Borrar
search: search:
title: "Moderadores: Búsqueda de usuarios" title: "Moderadores: Búsqueda de usuarios"
segment_recipient: segment_recipient:
@@ -750,8 +743,6 @@ es:
sent: Enviado sent: Enviado
actions: Acciones actions: Acciones
draft: Borrador draft: Borrador
edit: Editar
delete: Borrar
preview: Previsualizar preview: Previsualizar
empty_newsletters: No hay newsletters para mostrar empty_newsletters: No hay newsletters para mostrar
new: new:
@@ -787,8 +778,6 @@ es:
sent: Enviado sent: Enviado
actions: Acciones actions: Acciones
draft: Borrador draft: Borrador
edit: Editar
delete: Borrar
preview: Previsualizar preview: Previsualizar
view: Visualizar view: Visualizar
empty_notifications: No hay notificaciones para mostrar empty_notifications: No hay notificaciones para mostrar
@@ -886,7 +875,6 @@ es:
can_edit_dossier: "Puede editar informes" can_edit_dossier: "Puede editar informes"
valuator: valuator:
add: Añadir como evaluador add: Añadir como evaluador
delete: Borrar
search: search:
title: "Evaluadores: Búsqueda de usuarios" title: "Evaluadores: Búsqueda de usuarios"
form: form:
@@ -1308,8 +1296,6 @@ es:
index: index:
title: Zonas title: Zonas
create: Crear una zona create: Crear una zona
edit: Editar
delete: Borrar
geozone: geozone:
name: Nombre name: Nombre
external_code: Código externo external_code: Código externo