Merge pull request #5459 from consuldemocracy/admin_actions_buttons
Use buttons for non-GET actions in the admin section
This commit is contained in:
@@ -110,11 +110,9 @@
|
||||
//= require sortable
|
||||
//= require table_sortable
|
||||
//= require investment_report_alert
|
||||
//= require send_newsletter_alert
|
||||
//= require managers
|
||||
//= require i18n
|
||||
//= require globalize
|
||||
//= require send_admin_notification_alert
|
||||
//= require settings
|
||||
//= require cookies
|
||||
//= require columns_selector
|
||||
@@ -166,10 +164,8 @@ var initialize_modules = function() {
|
||||
App.Sortable.initialize();
|
||||
App.TableSortable.initialize();
|
||||
App.InvestmentReportAlert.initialize();
|
||||
App.SendNewsletterAlert.initialize();
|
||||
App.Managers.initialize();
|
||||
App.Globalize.initialize();
|
||||
App.SendAdminNotificationAlert.initialize();
|
||||
App.Settings.initialize();
|
||||
if ($("#js-columns-selector").length) {
|
||||
App.ColumnsSelector.initialize();
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
App.SendAdminNotificationAlert = {
|
||||
initialize: function() {
|
||||
$("#js-send-admin_notification-alert").on("click", function() {
|
||||
return confirm(this.dataset.alert);
|
||||
});
|
||||
}
|
||||
};
|
||||
}).call(this);
|
||||
@@ -1,10 +0,0 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
App.SendNewsletterAlert = {
|
||||
initialize: function() {
|
||||
$("#js-send-newsletter-alert").on("click", function() {
|
||||
return confirm(this.dataset.alert);
|
||||
});
|
||||
}
|
||||
};
|
||||
}).call(this);
|
||||
@@ -31,6 +31,15 @@ $table-header: #ecf1f6;
|
||||
.admin {
|
||||
@include admin-layout;
|
||||
|
||||
main {
|
||||
&.admin-site-customization-pages-new,
|
||||
&.admin-site-customization-pages-edit {
|
||||
> header {
|
||||
@include grid-row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: 100;
|
||||
margin-bottom: $line-height;
|
||||
@@ -501,10 +510,18 @@ code {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
a,
|
||||
button,
|
||||
form {
|
||||
margin-#{$global-left}: auto;
|
||||
}
|
||||
|
||||
a,
|
||||
button {
|
||||
@include regular-button;
|
||||
margin-left: auto;
|
||||
&:not(.delete) {
|
||||
@include regular-button;
|
||||
margin-#{$global-left}: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,4 +3,8 @@
|
||||
&[disabled] {
|
||||
@include button-disabled;
|
||||
}
|
||||
|
||||
&.delete {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.admin-site-customization-images-index {
|
||||
tbody tr td {
|
||||
&:first-child {
|
||||
width: calc(100% / 3);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
width: calc(100% * 2 / 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
.site-customization-images-table-actions {
|
||||
align-items: flex-start;
|
||||
container-type: inline-size;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: calc(#{$line-height} / 2);
|
||||
|
||||
> :first-child {
|
||||
align-items: flex-start;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@container (min-width: 30rem) {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
> div {
|
||||
@include grid-column-gutter;
|
||||
min-width: 5rem;
|
||||
padding-#{$global-left}: 0 !important;
|
||||
width: 50cqi;
|
||||
}
|
||||
}
|
||||
|
||||
.destroy-link {
|
||||
@include hollow-button;
|
||||
color: $alert-color;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,11 @@ class Admin::ActionComponent < ApplicationComponent
|
||||
private
|
||||
|
||||
def button?
|
||||
options[:method] && options[:method] != :get
|
||||
method && method != :get
|
||||
end
|
||||
|
||||
def method
|
||||
options[:method] || (:delete if action == :destroy)
|
||||
end
|
||||
|
||||
def text
|
||||
@@ -30,6 +34,7 @@ class Admin::ActionComponent < ApplicationComponent
|
||||
|
||||
def html_options
|
||||
{
|
||||
method: method,
|
||||
class: html_class,
|
||||
id: (dom_id(record, action) if record.respond_to?(:to_key)),
|
||||
"aria-describedby": describedby,
|
||||
@@ -38,7 +43,7 @@ class Admin::ActionComponent < ApplicationComponent
|
||||
confirm: confirmation_text,
|
||||
disable_with: (text if button?)
|
||||
}
|
||||
}.merge(options.except(:"aria-describedby", :"aria-label", :class, :confirm, :path, :text))
|
||||
}.merge(options.except(:"aria-describedby", :"aria-label", :class, :confirm, :method, :path, :text))
|
||||
end
|
||||
|
||||
def html_class
|
||||
|
||||
@@ -39,7 +39,6 @@ class Admin::Budgets::ActionsComponent < ApplicationComponent
|
||||
def destroy_action
|
||||
action(:destroy,
|
||||
text: t("admin.budgets.edit.delete"),
|
||||
method: :delete,
|
||||
confirm: t("admin.budgets.actions.confirm.destroy"),
|
||||
disabled: budget.investments.any? || budget.poll)
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<div class="groups-actions">
|
||||
<%= action(:edit, group, "aria-label": true) %>
|
||||
<%= action(:destroy, group, method: :delete, confirm: true, "aria-label": true) %>
|
||||
<%= action(:destroy, group, confirm: true, "aria-label": true) %>
|
||||
<%= action(:new,
|
||||
group,
|
||||
text: t("admin.budgets.show.add_heading"),
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<% provide :main_class, "admin-site-customization-images-index" %>
|
||||
<%= header %>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.site_customization.images.index.image") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% images.each do |image| %>
|
||||
<tr id="image_<%= image.name %>">
|
||||
<td>
|
||||
<strong><%= image.name %></strong> (<%= image.required_width %>x<%= image.required_height %>)
|
||||
</td>
|
||||
<td>
|
||||
<%= render Admin::SiteCustomization::Images::TableActionsComponent.new(image) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,14 @@
|
||||
class Admin::SiteCustomization::Images::IndexComponent < ApplicationComponent
|
||||
include Header
|
||||
attr_reader :images
|
||||
|
||||
def initialize(images)
|
||||
@images = images
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def title
|
||||
t("admin.site_customization.images.index.title")
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
<div class="site-customization-images-table-actions">
|
||||
<%= form_for([:admin, image], html: { id: "edit_#{dom_id(image)}" }) do |f| %>
|
||||
<div>
|
||||
<%= image_tag image.image if image.persisted_attachment? %>
|
||||
<%= f.file_field :image, label: false %>
|
||||
</div>
|
||||
|
||||
<%= f.submit(t("admin.site_customization.images.index.update"), class: "button hollow") %>
|
||||
<% end %>
|
||||
|
||||
<% if image.persisted_attachment? %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
image,
|
||||
path: admin_site_customization_image_path(image)
|
||||
) %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
class Admin::SiteCustomization::Images::TableActionsComponent < ApplicationComponent
|
||||
attr_reader :image
|
||||
|
||||
def initialize(image)
|
||||
@image = image
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<% provide :main_class, "admin-site-customization-pages-edit" %>
|
||||
<%= back_link_to admin_site_customization_pages_path %>
|
||||
|
||||
<%= header do %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@page,
|
||||
text: t("admin.site_customization.pages.index.delete"),
|
||||
confirm: true,
|
||||
class: "delete"
|
||||
) %>
|
||||
<% end %>
|
||||
|
||||
<%= render "form" %>
|
||||
@@ -0,0 +1,12 @@
|
||||
class Admin::SiteCustomization::Pages::EditComponent < ApplicationComponent
|
||||
include Header
|
||||
attr_reader :page
|
||||
|
||||
def initialize(page)
|
||||
@page = page
|
||||
end
|
||||
|
||||
def title
|
||||
t("admin.site_customization.pages.edit.title", page_title: page.title)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
<% provide :main_class, "admin-site-customization-pages-new" %>
|
||||
<%= back_link_to admin_site_customization_pages_path %>
|
||||
|
||||
<%= header %>
|
||||
|
||||
<%= render "form" %>
|
||||
@@ -0,0 +1,12 @@
|
||||
class Admin::SiteCustomization::Pages::NewComponent < ApplicationComponent
|
||||
include Header
|
||||
attr_reader :page
|
||||
|
||||
def initialize(page)
|
||||
@page = page
|
||||
end
|
||||
|
||||
def title
|
||||
t("admin.site_customization.pages.new.title")
|
||||
end
|
||||
end
|
||||
@@ -38,7 +38,6 @@ class Admin::TableActionsComponent < ApplicationComponent
|
||||
|
||||
def destroy_options
|
||||
{
|
||||
method: :delete,
|
||||
confirm: options[:destroy_confirmation] || true
|
||||
}.merge(options[:destroy_options] || {})
|
||||
end
|
||||
|
||||
@@ -25,9 +25,8 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr
|
||||
def destroy
|
||||
@image.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render layout: false }
|
||||
end
|
||||
redirect_to admin_answer_images_path(@image.imageable),
|
||||
notice: t("flash.actions.destroy.poll_question_answer_image")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -64,12 +64,16 @@
|
||||
|
||||
<% if @admin_notification.draft? && @admin_notification.valid_segment_recipient? %>
|
||||
<div class="small-12 medium-6 large-3 column end">
|
||||
<%= link_to t("admin.admin_notifications.show.send"),
|
||||
deliver_admin_admin_notification_path(@admin_notification),
|
||||
"data-alert": t("admin.admin_notifications.show.send_alert",
|
||||
n: @admin_notification.list_of_recipients_count),
|
||||
method: :post,
|
||||
id: "js-send-admin_notification-alert",
|
||||
class: "button success expanded" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:deliver,
|
||||
@admin_notification,
|
||||
text: t("admin.admin_notifications.show.send"),
|
||||
method: :post,
|
||||
confirm: t(
|
||||
"admin.admin_notifications.show.send_alert",
|
||||
n: @admin_notification.list_of_recipients_count
|
||||
),
|
||||
class: "button success expanded",
|
||||
) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
<h3 class="inline-block"><%= @draft_version.title %></h3>
|
||||
|
||||
<div class="float-right">
|
||||
<%= 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 Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@draft_version,
|
||||
confirm: true,
|
||||
class: "button hollow alert"
|
||||
) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
<h3 class="inline-block"><%= t("admin.legislation.questions.edit.title", question_title: @question.title) %></h3>
|
||||
|
||||
<div class="float-right">
|
||||
<%= link_to t("admin.legislation.questions.index.delete"), admin_legislation_process_question_path(@process, @question),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@question,
|
||||
confirm: true,
|
||||
class: "button hollow alert"
|
||||
) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -56,10 +56,12 @@
|
||||
</div>
|
||||
|
||||
<% if @newsletter.draft? && @newsletter.valid_segment_recipient? %>
|
||||
<%= link_to t("admin.newsletters.show.send"),
|
||||
deliver_admin_newsletter_path(@newsletter),
|
||||
"data-alert": t("admin.newsletters.show.send_alert", n: recipients_count),
|
||||
method: :post,
|
||||
id: "js-send-newsletter-alert",
|
||||
class: "button success" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:deliver,
|
||||
@newsletter,
|
||||
text: t("admin.newsletters.show.send"),
|
||||
method: :post,
|
||||
confirm: t("admin.newsletters.show.send_alert", n: recipients_count),
|
||||
class: "button success"
|
||||
) %>
|
||||
<% end %>
|
||||
|
||||
@@ -14,9 +14,16 @@
|
||||
<%= f.text_field :official_position %>
|
||||
<%= f.select :official_level, official_level_options %>
|
||||
<%= f.submit class: "button" %>
|
||||
<% if @user.official? %>
|
||||
<br>
|
||||
<%= link_to t("admin.officials.edit.destroy"), admin_official_path(@user), method: :delete, class: "delete" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @user.official? %>
|
||||
<br>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@user,
|
||||
text: t("admin.officials.edit.destroy"),
|
||||
path: admin_official_path(@user),
|
||||
class: "delete"
|
||||
) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
$(".delete").on("ajax:success", function () {
|
||||
$(this).closest("div").fadeOut();
|
||||
});
|
||||
@@ -26,12 +26,13 @@
|
||||
<%= render_image(image, :large, true) if image.present? %>
|
||||
|
||||
<% if can?(:destroy, image) %>
|
||||
<%= link_to t("images.remove_image"),
|
||||
admin_image_path(image),
|
||||
class: "delete float-right",
|
||||
method: :delete,
|
||||
remote: true,
|
||||
data: { confirm: t("admin.actions.confirm_action", action: t("images.remove_image"), name: image.title) } %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
image,
|
||||
text: t("images.remove_image"),
|
||||
confirm: t("admin.actions.confirm_action", action: t("images.remove_image"), name: image.title),
|
||||
class: "delete float-right"
|
||||
) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -4,10 +4,14 @@
|
||||
|
||||
<%= back_link_to admin_site_customization_content_blocks_path %>
|
||||
|
||||
<%= link_to t("admin.site_customization.content_blocks.index.delete"),
|
||||
(@is_heading_content_block ? admin_site_customization_delete_heading_content_block_path(@content_block.id) : admin_site_customization_content_block_path(@content_block)),
|
||||
method: :delete,
|
||||
class: "delete float-right" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@content_block,
|
||||
text: t("admin.site_customization.content_blocks.index.delete"),
|
||||
path: (@is_heading_content_block ? admin_site_customization_delete_heading_content_block_path(@content_block.id) : admin_site_customization_content_block_path(@content_block)),
|
||||
confirm: true,
|
||||
class: "delete float-right"
|
||||
) %>
|
||||
|
||||
<div class="small-12 column">
|
||||
<h2><%= t("admin.site_customization.content_blocks.edit.title") %></h2>
|
||||
|
||||
@@ -34,21 +34,21 @@
|
||||
<tbody>
|
||||
<% @content_blocks.each do |content_block| %>
|
||||
<tr id="<%= dom_id(content_block) %>">
|
||||
<td><%= link_to "#{content_block.name} (#{content_block.locale})", edit_admin_site_customization_content_block_path(content_block) %></td>
|
||||
<td><%= "#{content_block.name} (#{content_block.locale})" %></td>
|
||||
<td><%= raw content_block.body %></td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(content_block, actions: [:destroy]) %>
|
||||
<%= render Admin::TableActionsComponent.new(content_block) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% @headings_content_blocks.each do |content_block| %>
|
||||
<tr id="<%= dom_id(content_block) %>">
|
||||
<td><%= link_to "#{content_block.name} (#{content_block.locale})", admin_site_customization_edit_heading_content_block_path(content_block) %></td>
|
||||
<td><%= "#{content_block.name} (#{content_block.locale})" %></td>
|
||||
<td><%= raw content_block.body %></td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(
|
||||
content_block,
|
||||
actions: [:destroy],
|
||||
edit_path: admin_site_customization_edit_heading_content_block_path(content_block),
|
||||
destroy_path: admin_site_customization_delete_heading_content_block_path(content_block)
|
||||
) %>
|
||||
</td>
|
||||
|
||||
@@ -1,31 +1 @@
|
||||
<h2><%= t("admin.site_customization.images.index.title") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.site_customization.images.index.image") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @images.each do |image| %>
|
||||
<tr id="image_<%= image.name %>">
|
||||
<td class="small-12 medium-4">
|
||||
<strong><%= image.name %></strong> (<%= image.required_width %>x<%= image.required_height %>)
|
||||
</td>
|
||||
<td class="small-12 medium-8">
|
||||
<%= form_for([:admin, image], html: { id: "edit_#{dom_id(image)}" }) do |f| %>
|
||||
<div class="small-12 medium-6 large-6 column">
|
||||
<%= image_tag image.image if image.persisted_attachment? %>
|
||||
<%= f.file_field :image, label: false %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-6 column">
|
||||
<%= f.submit(t("admin.site_customization.images.index.update"), class: "button hollow") %>
|
||||
<%= link_to t("admin.site_customization.images.index.delete"), admin_site_customization_image_path(image), method: :delete, class: "button hollow alert" if image.persisted_attachment? %>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= render Admin::SiteCustomization::Images::IndexComponent.new(@images) %>
|
||||
|
||||
@@ -1,14 +1 @@
|
||||
<% provide :title do %>
|
||||
<%= t("admin.header.title") %> - <%= t("admin.menu.site_customization.pages") %> - <%= @page.title %>
|
||||
<% end %>
|
||||
|
||||
<%= back_link_to admin_site_customization_pages_path %>
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<h2 class="inline-block"><%= t("admin.site_customization.pages.edit.title", page_title: @page.title) %></h2>
|
||||
|
||||
<%= link_to t("admin.site_customization.pages.index.delete"), admin_site_customization_page_path(@page), method: :delete, class: "delete float-right" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "form" %>
|
||||
<%= render Admin::SiteCustomization::Pages::EditComponent.new(@page) %>
|
||||
|
||||
@@ -1,12 +1 @@
|
||||
<% provide :title do %>
|
||||
<%= t("admin.header.title") %> - <%= t("admin.menu.site_customization.pages") %> - <%= t("admin.site_customization.pages.new.title") %>
|
||||
<% end %>
|
||||
|
||||
<%= back_link_to admin_site_customization_pages_path %>
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<h2><%= t("admin.site_customization.pages.new.title") %></h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "form" %>
|
||||
<%= render Admin::SiteCustomization::Pages::NewComponent.new(@page) %>
|
||||
|
||||
@@ -30,11 +30,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= link_to t("admin.system_emails.preview_pending.moderate_pending"),
|
||||
admin_system_email_moderate_pending_path(system_email_id: "proposal_notification_digest",
|
||||
id: preview.id),
|
||||
method: :put,
|
||||
class: "button hollow float-right" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:moderate_pending,
|
||||
"proposal_notification_digest",
|
||||
text: t("admin.system_emails.preview_pending.moderate_pending"),
|
||||
path: admin_system_email_moderate_pending_path(system_email_id: "proposal_notification_digest", id: preview.id),
|
||||
method: :put,
|
||||
class: "button hollow float-right"
|
||||
) %>
|
||||
</div>
|
||||
<hr>
|
||||
<% end %>
|
||||
|
||||
@@ -24,9 +24,9 @@ module ActionDispatch::Routing::UrlFor
|
||||
end
|
||||
|
||||
def namespaced_polymorphic_path(namespace, resource, options = {})
|
||||
if %w[Budget::Group Budget::Heading Poll::Booth Poll::BoothAssignment Poll::Officer
|
||||
Poll::Question Poll::Question::Answer Poll::Question::Answer::Video Poll::Shift
|
||||
SDG::LocalTarget].include?(resource.class.name)
|
||||
if %w[Budget::Group Budget::Heading Legislation::DraftVersion Legislation::Question
|
||||
Poll::Booth Poll::BoothAssignment Poll::Officer Poll::Question Poll::Question::Answer
|
||||
Poll::Question::Answer::Video Poll::Shift SDG::LocalTarget].include?(resource.class.name)
|
||||
resolve = resolve_for(resource)
|
||||
resolve_options = resolve.pop
|
||||
|
||||
|
||||
@@ -664,7 +664,6 @@ en:
|
||||
index:
|
||||
title: Draft versions
|
||||
create: Create version
|
||||
delete: Delete
|
||||
preview: Preview
|
||||
new:
|
||||
back: Back
|
||||
@@ -697,7 +696,6 @@ en:
|
||||
back: Back
|
||||
title: Questions associated to this process
|
||||
create: Create question
|
||||
delete: Delete
|
||||
new:
|
||||
back: Back
|
||||
title: Create new question
|
||||
@@ -1609,7 +1607,6 @@ en:
|
||||
index:
|
||||
title: Custom images
|
||||
update: Update
|
||||
delete: Delete
|
||||
image: Image
|
||||
update:
|
||||
notice: Image updated successfully
|
||||
|
||||
@@ -34,6 +34,7 @@ en:
|
||||
destroy:
|
||||
budget_investment: "Investment project deleted successfully."
|
||||
topic: "Topic deleted successfully."
|
||||
poll_question_answer_image: "Image deleted successfully."
|
||||
poll_question_answer_video: "Answer video deleted successfully."
|
||||
valuator_group: "Valuator group deleted successfully"
|
||||
vote: "Vote deleted successfully"
|
||||
|
||||
@@ -664,7 +664,6 @@ es:
|
||||
index:
|
||||
title: Versiones del borrador
|
||||
create: Crear versión
|
||||
delete: Borrar
|
||||
preview: Previsualizar
|
||||
new:
|
||||
back: Volver
|
||||
@@ -697,7 +696,6 @@ es:
|
||||
back: Volver
|
||||
title: Preguntas asociadas a este proceso
|
||||
create: Crear pregunta
|
||||
delete: Borrar
|
||||
new:
|
||||
back: Volver
|
||||
title: Crear nueva pregunta
|
||||
@@ -1609,7 +1607,6 @@ es:
|
||||
index:
|
||||
title: Personalizar imágenes
|
||||
update: Actualizar
|
||||
delete: Borrar
|
||||
image: Imagen
|
||||
update:
|
||||
notice: Imagen actualizada correctamente
|
||||
|
||||
@@ -34,6 +34,7 @@ es:
|
||||
destroy:
|
||||
budget_investment: "Proyecto de gasto eliminado."
|
||||
topic: "Tema eliminado."
|
||||
poll_question_answer_image: "Imagen eliminada correctamente."
|
||||
poll_question_answer_video: "Vídeo de respuesta eliminado."
|
||||
valuator_group: "Grupo de evaluadores eliminado correctamente"
|
||||
vote: "Voto eliminado correctamente"
|
||||
|
||||
@@ -346,3 +346,7 @@ end
|
||||
resolve "Poll::Question::Answer::Video" do |video, options|
|
||||
[:answer, :video, options.merge(answer_id: video.answer, id: video)]
|
||||
end
|
||||
|
||||
resolve "Legislation::DraftVersion" do |version, options|
|
||||
[version.process, :draft_version, options.merge(id: version)]
|
||||
end
|
||||
|
||||
@@ -1,6 +1,38 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::ActionComponent do
|
||||
describe "method" do
|
||||
it "is not included by default for most actions" do
|
||||
render_inline Admin::ActionComponent.new(:create, double, path: "/")
|
||||
|
||||
expect(page).to have_link count: 1
|
||||
expect(page).not_to have_button
|
||||
expect(page).not_to have_css "[data-method]"
|
||||
end
|
||||
|
||||
it "is included in the link when the method is get" do
|
||||
render_inline Admin::ActionComponent.new(:create, double, path: "/", method: :get)
|
||||
|
||||
expect(page).to have_link count: 1
|
||||
expect(page).to have_css "a[data-method='get']"
|
||||
expect(page).not_to have_button
|
||||
end
|
||||
|
||||
it "defaults to :delete for the destroy action" do
|
||||
render_inline Admin::ActionComponent.new(:destroy, double, path: "/")
|
||||
|
||||
expect(page).to have_css "input[name='_method']", visible: :all, count: 1
|
||||
expect(page).to have_css "input[name='_method'][value='delete']", visible: :hidden
|
||||
end
|
||||
|
||||
it "can be overriden for the destroy action" do
|
||||
render_inline Admin::ActionComponent.new(:destroy, double, path: "/", method: :put)
|
||||
|
||||
expect(page).to have_css "input[name='_method']", visible: :all, count: 1
|
||||
expect(page).to have_css "input[name='_method'][value='put']", visible: :hidden
|
||||
end
|
||||
end
|
||||
|
||||
describe "HTML class" do
|
||||
it "includes an HTML class for the action by default" do
|
||||
render_inline Admin::ActionComponent.new(:edit, double, path: "/")
|
||||
@@ -159,7 +191,7 @@ describe Admin::ActionComponent do
|
||||
|
||||
render_inline Admin::ActionComponent.new(:destroy, record, path: "/", confirm: true)
|
||||
|
||||
expect(page).to have_link count: 1
|
||||
expect(page).to have_button count: 1
|
||||
expect(page).to have_css "[data-confirm='#{text}']"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -190,7 +190,7 @@ describe "Admin Notifications", :admin do
|
||||
|
||||
visit admin_admin_notification_path(notification)
|
||||
|
||||
accept_confirm { click_link "Send notification" }
|
||||
accept_confirm { click_button "Send notification" }
|
||||
|
||||
expect(page).to have_content "Notification sent successfully"
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ describe "Admin newsletter emails", :admin do
|
||||
newsletter = create(:newsletter)
|
||||
visit admin_newsletter_path(newsletter)
|
||||
|
||||
accept_confirm { click_link "Send" }
|
||||
accept_confirm { click_button "Send" }
|
||||
|
||||
expect(page).to have_content "Newsletter sent successfully"
|
||||
end
|
||||
@@ -153,7 +153,7 @@ describe "Admin newsletter emails", :admin do
|
||||
newsletter = create(:newsletter, segment_recipient: "administrators")
|
||||
visit admin_newsletter_path(newsletter)
|
||||
|
||||
accept_confirm { click_link "Send" }
|
||||
accept_confirm { click_button "Send" }
|
||||
|
||||
expect(page).to have_content "Newsletter sent successfully"
|
||||
|
||||
|
||||
@@ -74,6 +74,18 @@ describe "Admin legislation draft versions", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Delete" do
|
||||
version = create(:legislation_draft_version, body: "Version 1")
|
||||
|
||||
visit edit_admin_legislation_process_draft_version_path(version.process, version)
|
||||
|
||||
accept_confirm("Are you sure? This action will delete \"Version 1\" and can't be undone.") do
|
||||
click_button "Delete"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Draft deleted successfully"
|
||||
end
|
||||
|
||||
context "Changing content with the markdown editor" do
|
||||
let(:prompt) { "You've edited the text without saving it. Do you confirm to leave the page?" }
|
||||
let(:version) { create(:legislation_draft_version, body: "Version 1") }
|
||||
|
||||
@@ -75,7 +75,9 @@ describe "Admin legislation questions", :admin do
|
||||
|
||||
visit edit_admin_legislation_process_question_path(process, question)
|
||||
|
||||
click_link "Delete"
|
||||
accept_confirm("Are you sure? This action will delete \"Question 2\" and can't be undone.") do
|
||||
click_button "Delete"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Questions"
|
||||
expect(page).to have_content "Question 1"
|
||||
|
||||
@@ -63,7 +63,7 @@ describe "Admin officials", :admin do
|
||||
scenario "Destroy" do
|
||||
visit edit_admin_official_path(official)
|
||||
|
||||
click_link 'Remove "Official" status'
|
||||
click_button 'Remove "Official" status'
|
||||
|
||||
expect(page).to have_content "Details saved: the user is no longer an official"
|
||||
expect(page).to have_current_path(admin_officials_path, ignore_query: true)
|
||||
|
||||
@@ -73,7 +73,7 @@ describe "Images", :admin do
|
||||
expect(page).to have_content image.title
|
||||
|
||||
accept_confirm "Are you sure? Remove image \"#{image.title}\"" do
|
||||
click_link "Remove image"
|
||||
click_button "Remove image"
|
||||
end
|
||||
|
||||
expect(page).not_to have_css "img[title='#{image.title}']"
|
||||
@@ -88,7 +88,7 @@ describe "Images", :admin do
|
||||
expect(page).to have_css "img[title='#{image.title}']"
|
||||
expect(page).to have_content image.title
|
||||
|
||||
expect(page).not_to have_link "Remove image"
|
||||
expect(page).not_to have_content "Remove image"
|
||||
expect(page).to have_content "Once the poll has started it will not be possible to create, edit or"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,13 +2,19 @@ require "rails_helper"
|
||||
|
||||
describe "Admin custom content blocks", :admin do
|
||||
scenario "Index" do
|
||||
block = create(:site_customization_content_block)
|
||||
heading_block = create(:heading_content_block)
|
||||
block = create(:site_customization_content_block, name: "top_links")
|
||||
heading_block = create(:heading_content_block, heading: create(:budget_heading, name: "Reforestation"))
|
||||
visit admin_site_customization_content_blocks_path
|
||||
|
||||
expect(page).to have_content(block.name)
|
||||
within "tr", text: "top_links" do
|
||||
expect(page).to have_link "Edit"
|
||||
end
|
||||
|
||||
within "tr", text: "Reforestation" do
|
||||
expect(page).to have_link "Edit"
|
||||
end
|
||||
|
||||
expect(page).to have_content(block.body)
|
||||
expect(page).to have_content(heading_block.heading.name)
|
||||
expect(page).to have_content(heading_block.body)
|
||||
end
|
||||
|
||||
@@ -73,7 +79,7 @@ describe "Admin custom content blocks", :admin do
|
||||
click_link "Custom content blocks"
|
||||
end
|
||||
|
||||
click_link "top_links (en)"
|
||||
within("tr", text: "top_links (en)") { click_link "Edit" }
|
||||
|
||||
fill_in "site_customization_content_block_body", with: "Some other custom content"
|
||||
click_button "Update Custom content block"
|
||||
@@ -103,7 +109,9 @@ describe "Admin custom content blocks", :admin do
|
||||
block = create(:site_customization_content_block)
|
||||
visit edit_admin_site_customization_content_block_path(block)
|
||||
|
||||
click_link "Delete block"
|
||||
accept_confirm("Are you sure? This action will delete \"#{block.name}\" and can't be undone.") do
|
||||
click_button "Delete block"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content("#{block.name} (#{block.locale})")
|
||||
expect(page).not_to have_content(block.body)
|
||||
|
||||
@@ -112,7 +112,7 @@ describe "Admin custom images", :admin do
|
||||
expect(page).to have_css("img[src*='social_media_icon.png']")
|
||||
|
||||
within("tr#image_social_media_icon") do
|
||||
click_link "Delete"
|
||||
click_button "Delete"
|
||||
end
|
||||
|
||||
expect(page).not_to have_css("img[src*='social_media_icon.png']")
|
||||
|
||||
@@ -93,7 +93,9 @@ describe "Admin custom pages", :admin do
|
||||
custom_page = create(:site_customization_page, title: "An example custom page")
|
||||
visit edit_admin_site_customization_page_path(custom_page)
|
||||
|
||||
click_link "Delete page"
|
||||
accept_confirm "Are you sure? This action will delete \"An example custom page\" and can't be undone." do
|
||||
click_button "Delete page"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "An example custom page"
|
||||
expect(page).not_to have_content "example-page"
|
||||
|
||||
@@ -328,7 +328,7 @@ describe "System Emails" do
|
||||
visit admin_system_email_preview_pending_path("proposal_notification_digest")
|
||||
|
||||
within("#proposal_notification_#{proposal_notification1.id}") do
|
||||
click_link "Moderate notification send"
|
||||
click_button "Moderate notification send"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content("Proposal A Title")
|
||||
|
||||
@@ -482,7 +482,7 @@ describe "Emails" do
|
||||
|
||||
expect(page).to have_content "Newsletter created successfully"
|
||||
|
||||
accept_confirm { click_link "Send" }
|
||||
accept_confirm { click_button "Send" }
|
||||
|
||||
expect(page).to have_content "Newsletter sent successfully"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user