Skip to content

Commit

Permalink
Add proposal address in the admin backend (#52)
Browse files Browse the repository at this point in the history
* add proposal address to admin backend

* linting
  • Loading branch information
microstudi authored Jan 30, 2023
1 parent c145433 commit dea17e2
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 0 deletions.
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 @@ -544,6 +544,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

0 comments on commit dea17e2

Please sign in to comment.