Skip to content

Commit

Permalink
Rework sdgs filters
Browse files Browse the repository at this point in the history
  • Loading branch information
laurajaime committed Nov 20, 2024
1 parent 40f01de commit 5663b59
Show file tree
Hide file tree
Showing 17 changed files with 398 additions and 335 deletions.
7 changes: 2 additions & 5 deletions app/controllers/decidim/challenges/challenges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ def challenge_scope
@challenge_scope ||= current_organization.scopes.find_by(id: @challenge.decidim_scope_id)
end

def default_filter_params
has_sdgs? ? default_filters.merge({ with_any_sdgs_codes: [] }) : default_filters
end

def challenges
@challenges ||= reorder(paginate(search.result))
end
Expand All @@ -50,11 +46,12 @@ def search_collection
::Decidim::Challenges::Challenge.where(component: current_component).published
end

def default_filters
def default_filter_params
{
search_text_cont: "",
with_any_state: %w(proposal execution finished),
with_any_scope: default_filter_scope_params,
with_any_sdgs_codes: [],
related_to: "",
}
end
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/decidim/problems/problems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ def challenge_scope
end

def default_filter_params
has_sdgs? ? default_filters.merge({ with_any_sdgs_codes: [] }) : default_filters
end

def default_filters
{
search_text_cont: "",
with_any_state: %w(proposal execution finished),
with_any_sectorial_scope: default_filter_scope_params,
with_any_technological_scope: default_filter_scope_params,
with_any_territorial_scope: default_filter_scope_params,
with_any_sdgs_codes: [],
related_to: "",
}
end
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/decidim/solutions/solutions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ def create
private

def default_filter_params
has_sdgs? ? default_filters.merge({ with_any_sdgs_codes: [] }) : default_filters
end

def default_filters
{
search_text_cont: "",
with_any_territorial_scope: default_filter_scope_params,
Expand Down
1 change: 0 additions & 1 deletion app/helpers/decidim/challenges/challenges_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def filter_sections
items.append(method: :with_any_scope, collection: filter_global_scopes_values, label_scope: "decidim.shared.filters",
id: "scope")
end
items.append(method: :with_any_sdgs_codes, collection: filter_sdgs_values, label_scope: "decidim.shared.filters", id: "sdgs") if has_sdgs?

items.reject { |item| item[:collection].blank? }
end
Expand Down
1 change: 0 additions & 1 deletion app/helpers/decidim/problems/problems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def filter_sections
items.append(method: :with_any_technological_scope, collection: filter_global_scopes_values, label_scope: "decidim.problems.problems.filters", id: "technological_scope")
items.append(method: :with_any_territorial_scope, collection: filter_global_scopes_values, label_scope: "decidim.problems.problems.filters", id: "territorial_scope")
end
items.append(method: :with_any_sdgs_codes, collection: filter_sdgs_values, label_scope: "decidim.shared.filters", id: "sdgs") if has_sdgs?

items.reject { |item| item[:collection].blank? }
end
Expand Down
1 change: 0 additions & 1 deletion app/helpers/decidim/solutions/solutions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def filter_sections
end
items.append(method: :related_to, collection: linked_classes_filter_values_for(Decidim::Challenges::Challenge), label_scope: "decidim.solutions.solutions.filters",
id: "related_to", type: :radio_buttons)
items.append(method: :with_any_sdgs_codes, collection: filter_sdgs_values, label_scope: "decidim.shared.filters", id: "sdgs") if has_sdgs?

items.reject { |item| item[:collection].blank? }
end
Expand Down
2 changes: 2 additions & 0 deletions app/packs/entrypoints/decidim_sdgs.scss
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
@import "stylesheets/decidim/sdgs/sdgs_filter/button.scss";
@import "stylesheets/decidim/sdgs/sdgs_filter/modal.scss";
@import "stylesheets/decidim/sdgs/ods.scss";
12 changes: 11 additions & 1 deletion app/packs/src/decidim/sdgs/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ function toggleSdgFilterCellSelect(cell, selected) {
}
}

$( document ).ready(function() {
$(document).ready(function() {
window.onclick = function(event) {
let modal = document.querySelector("#sdgs-modal");

if (event.target == modal) {
modal.style.display = "none";
}
}

/**
* Setup Sdgs selector
*/
Expand Down Expand Up @@ -62,4 +70,6 @@ $( document ).ready(function() {
sdgs_opener.parent("form").submit()
sdgs_opener= null
});


})
Loading

0 comments on commit 5663b59

Please sign in to comment.