Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proposal address in the admin backend #52

Merged
merged 2 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "stylesheets/decidim/modules/address";

.address{
padding: 1rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
//Admin dashboard
@import "stylesheets/decidim/admin/modules/users_statistics";
@import "stylesheets/decidim/admin/modules/moderations";

// Address styling
@import "stylesheets/decidim/admin/modules/address";
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
<strong><%= t ".body" %>:</strong> <%= simple_format(present(proposal).body(strip_tags: true)) %>
</div>

<% if component_settings.geocoding_enabled? %>
<div class="row column">
<strong><%= t ".geolocated_at" %>:</strong>
<%= render partial: "decidim/shared/static_map", locals: { icon_name: "proposals", geolocalizable: proposal } %>
</div>
<% end %>

<div class="row column">
<strong><%= t ".created_at" %>:</strong> <%= l proposal.created_at, format: :decidim_short %>
</div>
Expand Down
1 change: 1 addition & 0 deletions decidim-proposals/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ en:
endorsements_count: Endorsements count
endorsements_ranking: Ranking by endorsements
endorsers: Endorsers
geolocated_at: Geolocated at
link: Link
n_more_endorsers:
one: and 1 more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,38 @@
end
end

context "when it is a proposal with geocoding data" do
let!(:proposal) { create(:proposal, component: component, address: address, latitude: latitude, longitude: longitude) }

it "does not show the address" do
go_to_admin_proposal_page(proposal)
expect(page).not_to have_css(".address")
expect(page).not_to have_css(".address__info")
expect(page).not_to have_css(".address__map")
expect(page).not_to have_content(address)
end

context "when component has geocoding enabled" do
let!(:component) do
create(:proposal_component,
manifest: manifest,
participatory_space: participatory_process,
settings: {
geocoding_enabled: true
})
end

it "shows the address" do
go_to_admin_proposal_page(proposal)
within ".address" do
expect(page).to have_css(".address__info")
expect(page).to have_css(".address__map")
expect(page).to have_content(address)
end
end
end
end

describe "with supports" do
before do
create_list :proposal_vote, 2, proposal: proposal
Expand Down
34 changes: 34 additions & 0 deletions decidim-proposals/spec/system/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,40 @@
end
end

context "when it is a proposal with geocoding data" do
let!(:proposal) { create(:proposal, component: component, address: address, latitude: latitude, longitude: longitude) }

it "does not show the address" do
visit_component
click_link proposal_title
expect(page).not_to have_css(".card__content.address")
expect(page).not_to have_css(".address__info")
expect(page).not_to have_css(".address__map")
expect(page).not_to have_content(address)
end

context "when component has geocoding enabled" do
let!(:component) do
create(:proposal_component,
manifest: manifest,
participatory_space: participatory_process,
settings: {
geocoding_enabled: true
})
end

it "shows the address" do
visit_component
click_link proposal_title
within ".card__content.address" do
expect(page).to have_css(".address__info")
expect(page).to have_css(".address__map")
expect(page).to have_content(address)
end
end
end
end

context "when it is an official meeting proposal" do
include_context "with rich text editor content"
let!(:proposal) { create(:proposal, :official_meeting, body: content, component: component) }
Expand Down