forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/meetings_form_embed_type_visibility' into pwa-staging
* fix/meetings_form_embed_type_visibility: Fix tests by adding missing doubled attributes Include value in validation conditional Allow participants to set iframe access level of meetings Fix embed type visibility in participants form Remove blank option in meetings embed type select Fix avatar thumbnail in participants' profile (decidim#8577) Fix HTML injection in comments and meeting's description (decidim#8511) Add search, filters and sorting to admin panel budget projects (decidim#8592) Add cache key separator to cache_hash (decidim#8559) Move social login buttons to the top of the login modal (decidim#8574) Fix the meeting copy functionality (decidim#8430) Temporarily ignore CSS validation issue in CI (decidim#8597) Fix security instructions (decidim#8587)
- Loading branch information
Showing
57 changed files
with
971 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
decidim-budgets/app/controllers/concerns/decidim/budgets/admin/filterable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require "active_support/concern" | ||
|
||
module Decidim | ||
module Budgets | ||
module Admin | ||
module Filterable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include Decidim::Admin::Filterable | ||
|
||
helper Decidim::Budgets::Admin::FilterableHelper | ||
|
||
private | ||
|
||
def base_query | ||
collection | ||
end | ||
|
||
def search_field_predicate | ||
:id_string_or_title_cont | ||
end | ||
|
||
def filters | ||
[ | ||
:scope_id_eq, | ||
:category_id_eq, | ||
:selected_at_null | ||
] | ||
end | ||
|
||
def filters_with_values | ||
{ | ||
scope_id_eq: scope_ids_hash(scopes.top_level), | ||
category_id_eq: category_ids_hash(categories.first_class), | ||
selected_at_null: [true, false] | ||
} | ||
end | ||
|
||
# Can't user `super` here, because it does not belong to a superclass | ||
# but to a concern. | ||
def dynamically_translated_filters | ||
[:scope_id_eq, :category_id_eq] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
decidim-budgets/app/helpers/decidim/budgets/admin/filterable_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Budgets | ||
module Admin | ||
module FilterableHelper | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
decidim-budgets/spec/system/admin_filters_searches_and_paginates_projects_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "Admin filters, searches, and paginates projects", type: :system do | ||
include_context "when managing a component as an admin" | ||
include_context "with filterable context" | ||
|
||
let(:manifest_name) { "budgets" } | ||
let(:resource_controller) { Decidim::Budgets::Admin::ProjectsController } | ||
let!(:budget) { create(:budget, component: current_component) } | ||
|
||
before do | ||
visit_component_admin | ||
find("a[title='Manage projects']").click | ||
end | ||
|
||
context "when filtering by scope" do | ||
let!(:scope1) { create(:scope, organization: component.organization, name: { "en" => "Scope1" }) } | ||
let!(:scope2) { create(:scope, organization: component.organization, name: { "en" => "Scope2" }) } | ||
let!(:project_with_scope1) { create(:project, budget: budget, scope: scope1) } | ||
let!(:project_with_scope2) { create(:project, budget: budget, scope: scope2) } | ||
let(:project_with_scope1_title) { translated(project_with_scope1.title) } | ||
let(:project_with_scope2_title) { translated(project_with_scope2.title) } | ||
|
||
before { visit current_path } | ||
|
||
it_behaves_like "a filtered collection", options: "Scope", filter: "Scope1" do | ||
let(:in_filter) { project_with_scope1_title } | ||
let(:not_in_filter) { project_with_scope2_title } | ||
end | ||
|
||
it_behaves_like "a filtered collection", options: "Scope", filter: "Scope2" do | ||
let(:in_filter) { project_with_scope2_title } | ||
let(:not_in_filter) { project_with_scope1_title } | ||
end | ||
end | ||
|
||
context "when filtering by category" do | ||
let!(:category1) { create(:category, participatory_space: participatory_space, name: { "en" => "Category1" }) } | ||
let!(:category2) { create(:category, participatory_space: participatory_space, name: { "en" => "Category2" }) } | ||
let!(:project_with_category1) { create(:project, budget: budget, category: category1) } | ||
let!(:project_with_category2) { create(:project, budget: budget, category: category2) } | ||
let(:project_with_category1_title) { translated(project_with_category1.title) } | ||
let(:project_with_category2_title) { translated(project_with_category2.title) } | ||
|
||
before { visit current_path } | ||
|
||
it_behaves_like "a filtered collection", options: "Category", filter: "Category1" do | ||
let(:in_filter) { project_with_category1_title } | ||
let(:not_in_filter) { project_with_category2_title } | ||
end | ||
|
||
it_behaves_like "a filtered collection", options: "Category", filter: "Category2" do | ||
let(:in_filter) { project_with_category2_title } | ||
let(:not_in_filter) { project_with_category1_title } | ||
end | ||
end | ||
|
||
context "when filtering by selected" do | ||
let!(:project_with_status1) { create(:project, budget: budget, selected_at: Time.current) } | ||
let!(:project_with_status2) { create(:project, budget: budget, selected_at: nil) } | ||
let(:project_with_status1_title) { translated(project_with_status1.title) } | ||
let(:project_with_status2_title) { translated(project_with_status2.title) } | ||
|
||
before { visit current_path } | ||
|
||
it_behaves_like "a filtered collection", options: "Selected", filter: "Selected for implementation" do | ||
let(:in_filter) { project_with_status1_title } | ||
let(:not_in_filter) { project_with_status2_title } | ||
end | ||
|
||
it_behaves_like "a filtered collection", options: "Selected", filter: "Not selected for implementation" do | ||
let(:in_filter) { project_with_status2_title } | ||
let(:not_in_filter) { project_with_status1_title } | ||
end | ||
end | ||
|
||
context "when searching by ID or title" do | ||
let!(:project1) { create(:project, budget: budget) } | ||
let!(:project2) { create(:project, budget: budget) } | ||
let!(:project1_title) { translated(project1.title) } | ||
let!(:project2_title) { translated(project2.title) } | ||
|
||
before { visit current_path } | ||
|
||
it "can be searched by ID" do | ||
search_by_text(project1.id) | ||
|
||
expect(page).to have_content(project1_title) | ||
end | ||
|
||
it "can be searched by title" do | ||
search_by_text(project2_title) | ||
|
||
expect(page).to have_content(project2_title) | ||
end | ||
end | ||
|
||
context "when listing projects" do | ||
before { visit current_path } | ||
|
||
it_behaves_like "paginating a collection" do | ||
let!(:collection) { create_list(:project, 50, budget: budget) } | ||
end | ||
end | ||
end |
Oops, something went wrong.