Skip to content

Commit

Permalink
Add button to create solutions in challenge show (#75)
Browse files Browse the repository at this point in the history
* Add button to create solution in challenge show

* Update module version

* Rubocopify

* Fix tests

* Refactor
  • Loading branch information
laurajaime authored Nov 14, 2024
1 parent 1fa565d commit 955215f
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Following Semantic Versioning 2.

## next version:

## Version 0.4.2 (MINOR)
- Show create solution button in challenge, show only if there is a solution component.

## Version 0.4.1.1 (PATCH)
- Add missing translation.
- Fix update solution in backoffice.
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ GIT
PATH
remote: .
specs:
decidim-challenges (0.4.1.1)
decidim-challenges (0.4.2)
decidim-core (~> 0.27)

GEM
Expand Down Expand Up @@ -270,7 +270,7 @@ GEM
parser (>= 2.4)
smart_properties
bindex (0.8.1)
bootsnap (1.17.0)
bootsnap (1.18.4)
msgpack (~> 1.2)
browser (2.7.1)
builder (3.2.4)
Expand Down Expand Up @@ -501,7 +501,7 @@ GEM
tomlrb
mixlib-shellout (3.2.7)
chef-utils
msgpack (1.7.2)
msgpack (1.7.5)
multi_xml (0.6.0)
mustache (1.1.1)
net-imap (0.4.9)
Expand Down
11 changes: 10 additions & 1 deletion app/controllers/decidim/challenges/challenges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ChallengesController < Decidim::Challenges::ApplicationController
helper Decidim::Sdgs::SdgsHelper
helper Decidim::ShowFiltersHelper

helper_method :challenges
helper_method :challenges, :new_solution_path, :solutions_component

def index
@challenges = search.result
Expand Down Expand Up @@ -56,6 +56,15 @@ def challenges
def search_collection
::Decidim::Challenges::Challenge.where(component: current_component).published
end

def new_solution_path
component = solutions_component
Decidim::EngineRouter.main_proxy(component).new_solution_path
end

def solutions_component
current_participatory_space.components.find_by(manifest_name: "solutions")
end
end
end
end
6 changes: 6 additions & 0 deletions app/packs/stylesheets/decidim/challenges/challenges.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,9 @@
.card-proposed-solution {
padding: 5px 10px;
}

.challenge-action-buttons {
display: flex;
flex-direction: column;
gap: 12px;
}
15 changes: 12 additions & 3 deletions app/views/decidim/challenges/challenges/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@

<div class="card extra">
<div class="card__content">
<% if @challenge.survey_enabled %>
<%= link_to t('surveys.answer', scope: "decidim.challenges"), answer_challenge_survey_path(@challenge), class: "card__button button button--sc small" %>
<% end %>
<div class="challenge-action-buttons">
<% if @challenge.survey_enabled? %>
<%= link_to t('surveys.answer', scope: "decidim.challenges"), answer_challenge_survey_path(@challenge), class: "card__button button button--sc small" %>
<% end %>

<% if solutions_component&.settings&.creation_enabled? %>
<%= action_authorized_link_to :create, new_solution_path, class: "card__button button button--sc small", data: { "redirect_url": new_solution_path } do %>
<%= t(".new_solution") %>
<%= icon "plus", role: "img", "aria-hidden": true %>
<% end %>
<% end %>
</div>
<%= render partial: "decidim/shared/follow_button",
locals: { followable: current_participatory_space, large: false } %>
</div>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ ca:
label: Ordenacions
random: Aleatori
recent: Més recents
show:
new_solution: Nova solució
challenges_helper:
filter_state_values:
all: Tots
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ en:
label: test
random: Random
recent: Most recent
show:
new_solution: New solution
challenges_helper:
filter_state_values:
all: All
Expand Down
2 changes: 2 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ es:
label: Ordenaciones
random: Aleatorio
recent: Más recientes
show:
new_solution: Nueva solución
challenges_helper:
filter_state_values:
all: Todos
Expand Down
2 changes: 2 additions & 0 deletions config/locales/oc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ oc:
label: Ordenacions
random: Aleatori
recent: Més recents
show:
new_solution: Nova solució
challenges_helper:
filter_state_values:
all: Tots
Expand Down
2 changes: 1 addition & 1 deletion lib/decidim/challenges/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Decidim
# This holds the decidim-meetings version.
module Challenges
def self.version
"0.4.1.1"
"0.4.2"
end

def self.decidim_version
Expand Down

0 comments on commit 955215f

Please sign in to comment.