decidim-homepage_proposals 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +32 -0
  4. data/Rakefile +30 -0
  5. data/app/cells/decidim/homepage_proposals/content_blocks/proposals_slider/show.erb +37 -0
  6. data/app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb +56 -0
  7. data/app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_settings_form/show.erb +13 -0
  8. data/app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_settings_form_cell.rb +36 -0
  9. data/app/controllers/decidim/proposals_slider_controller.rb +74 -0
  10. data/app/packs/entrypoints/decidim_homepage_proposals.js +5 -0
  11. data/app/packs/entrypoints/decidim_homepage_proposals_admin.js +1 -0
  12. data/app/packs/images/decidim/homepage_proposals/icon.svg +1 -0
  13. data/app/packs/images/decidim/homepage_proposals/slider_proposal_image.jpeg +0 -0
  14. data/app/packs/src/decidim/homepage_proposals/admin.js +16 -0
  15. data/app/packs/src/decidim/homepage_proposals/glideBuilder.js +49 -0
  16. data/app/packs/src/decidim/homepage_proposals/glidejs/Manager.js +130 -0
  17. data/app/packs/src/decidim/homepage_proposals/glidejs/glideItems/GlideItem.js +17 -0
  18. data/app/packs/src/decidim/homepage_proposals/glidejs/glideItems/NotFound.js +23 -0
  19. data/app/packs/src/decidim/homepage_proposals/glidejs/glideItems/Proposal.js +51 -0
  20. data/app/packs/src/decidim/homepage_proposals/main.js +19 -0
  21. data/app/packs/stylesheets/decidim/homepage_proposals/homepage_proposals.scss +45 -0
  22. data/app/views/decidim/shared/homepage_proposals/_filters.erb +47 -0
  23. data/app/views/decidim/shared/homepage_proposals/_filters_small_view.erb +18 -0
  24. data/config/assets.rb +10 -0
  25. data/config/i18n-tasks.yml +10 -0
  26. data/config/locales/en.yml +33 -0
  27. data/config/routes.rb +5 -0
  28. data/lib/decidim/homepage_proposals/admin.rb +10 -0
  29. data/lib/decidim/homepage_proposals/admin_engine.rb +24 -0
  30. data/lib/decidim/homepage_proposals/engine.rb +41 -0
  31. data/lib/decidim/homepage_proposals/test/factories.rb +17 -0
  32. data/lib/decidim/homepage_proposals/version.rb +13 -0
  33. data/lib/decidim/homepage_proposals.rb +12 -0
  34. data/lib/tasks/homepage_proposals.rake +25 -0
  35. data/lib/tasks/homepage_proposals_webpacker_tasks.rake +14 -0
  36. metadata +92 -0
@@ -0,0 +1,47 @@
1
+ <%= filter_form_for filter, decidim_participatory_processes_path , id: 'filters-form' do |form| %>
2
+ <div class="columns mediumlarge-4 large-3">
3
+ <%= cell(
4
+ "decidim/scopes_picker",
5
+ form,
6
+ attribute: :scope_id,
7
+ multiple: true,
8
+ legend_title: t("decidim.homepage_proposals.proposal_at_a_glance.filters.scope"),
9
+ label: false,
10
+ checkboxes_on_top: false
11
+ ) %>
12
+ </div>
13
+ <div class="columns mediumlarge-4 large-3">
14
+ <%= form.categories_select :category_id,
15
+ categories_filter,
16
+ legend_title: t("decidim.homepage_proposals.proposal_at_a_glance.filters.categories"),
17
+ disable_parents: false,
18
+ label: "",
19
+ selected: filter.category_id,
20
+ include_blank: t("decidim.homepage_proposals.proposal_at_a_glance.filters.default_categories") %>
21
+ </div>
22
+ <div class="columns mediumlarge-4 large-3">
23
+ <div class="filters__section">
24
+ <fieldset class="">
25
+ <legend class="mini-title"><%= t("decidim.homepage_proposals.proposal_at_a_glance.filters.components") %></legend>
26
+ <label for="">
27
+
28
+ <%= form.select :component_id,
29
+ options_for_default_component,
30
+ label: false,
31
+ selected: filter.component_id,
32
+ data: { placeholder: t("decidim.homepage_proposals.proposal_at_a_glance.filters.components") }
33
+ %>
34
+ </label>
35
+
36
+ </fieldset>
37
+
38
+ </div>
39
+
40
+ </div>
41
+ <%# Small button to clear filters %>
42
+ <div class="columns mediumlarge-12 large-3">
43
+ <div class="clear-filters">
44
+ <%= link_to t("decidim.homepage_proposals.proposal_at_a_glance.filters.clear_filters"), decidim_participatory_processes_path, class: "button--clear-filters" %>
45
+ </div>
46
+ </div>
47
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <div class="filters-controls hide-for-mediumlarge">
2
+ <button data-open="filter-box" class="filters-controls__trigger" aria-controls="filter-box" aria-haspopup="dialog">
3
+ <%= t ".filters_small_view.filter" %>
4
+ <%= icon "caret-bottom", class: "icon--small float-right", aria_label: t(".filters_small_view.unfold"), role: "img" %>
5
+ </button>
6
+ </div>
7
+
8
+ <div class="reveal" id="filter-box" data-reveal role="dialog" aria-modal="true" aria-labelledby="filter-box-label">
9
+ <div class="reveal__header">
10
+ <h3 id="filter-box-label" class="reveal__title"><%= t ".filters_small_view.filter_by" %>:</h3>
11
+ <button class="close-button" data-close aria-label="<%= t(".filters_small_view.close_modal") %>" type="button">
12
+ <span aria-hidden="true">&times;</span>
13
+ </button>
14
+ </div>
15
+ <div class="filters">
16
+ <%= render partial: "decidim/shared/homepage_proposals/filters", locals: { type: :small } %>
17
+ </div>
18
+ </div>
data/config/assets.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ base_path = File.expand_path("..", __dir__)
4
+
5
+ Decidim::Webpacker.register_path("#{base_path}/app/packs")
6
+ Decidim::Webpacker.register_entrypoints(
7
+ decidim_homepage_proposals: "#{base_path}/app/packs/entrypoints/decidim_homepage_proposals.js",
8
+ decidim_homepage_proposals_admin: "#{base_path}/app/packs/entrypoints/decidim_homepage_proposals_admin.js"
9
+ )
10
+ Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/homepage_proposals/homepage_proposals")
@@ -0,0 +1,10 @@
1
+ ---
2
+
3
+ base_locale: en
4
+ locales: [en]
5
+
6
+ ignore_unused:
7
+ - "decidim.components.homepage_proposals.name"
8
+
9
+ ignore_missing:
10
+ - decidim.participatory_processes.scopes.global
@@ -0,0 +1,33 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ homepage_proposals:
5
+ content_blocks:
6
+ proposals_slider:
7
+ filters_small_view:
8
+ close_modal: Close modal
9
+ filter: Filter
10
+ filter_by: Filter by
11
+ unfold: Unfold
12
+ learn_more: Learn more
13
+ name: Proposals slider
14
+ loading: Loading...
15
+ search: Search
16
+ proposals_slider_settings_form:
17
+ activate_filters: Activate filters
18
+ default_linked_component: Component displayed by default
19
+ linked_components_id: Components available in filters
20
+ proposal_at_a_glance:
21
+ title: Explore proposals
22
+ filters:
23
+ categories: Categories
24
+ clear_filters: Clear filters
25
+ components: Components
26
+ default_categories: All categories
27
+ default_components: All components
28
+ default_scope: All scopes
29
+ scope: Scope
30
+ learn_more: Learn more
31
+ no_proposals:
32
+ title: No proposals
33
+ description: There are no proposals that match the selected filters.
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ get "proposals_slider/refresh_proposals", to: "decidim/proposals_slider#refresh_proposals"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module HomepageProposals
5
+ # This module contains all the domain logic associated to Decidim's HomepageProposals
6
+ # component admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module HomepageProposals
5
+ # This is the engine that runs on the public interface of `HomepageProposals`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::HomepageProposals::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ routes do
13
+ # Create a route to refresh proposals
14
+ # proposals_slider/refresh_proposals searching for the method "refresh_proposals" in the cell
15
+ # resources :homepage_proposals
16
+ # root to: "homepage_proposals#index"
17
+ end
18
+
19
+ def load_seed
20
+ nil
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "decidim/core"
5
+
6
+ module Decidim
7
+ module HomepageProposals
8
+ # This is the engine that runs on the public interface of homepage_proposals.
9
+ class Engine < ::Rails::Engine
10
+ isolate_namespace Decidim::HomepageProposals
11
+
12
+ routes do
13
+ # Add engine routes here
14
+ # resources :homepage_proposals
15
+ # root to: "homepage_proposals#index"
16
+ end
17
+
18
+ initializer "HomepageProposals.webpacker.assets_path" do
19
+ Decidim.register_assets_path File.expand_path("app/packs", root)
20
+ end
21
+
22
+ initializer "decidim_homepage_proposals.add_cells_view_paths" do
23
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::HomepageProposals::Engine.root}/app/cells")
24
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::HomepageProposals::Engine.root}/app/views") # for proposal partials
25
+ end
26
+
27
+ initializer "decidim_homepage_proposals.content_blocks" do
28
+ Decidim.content_blocks.register(:homepage, :proposals_slider) do |content_block|
29
+ content_block.cell = "decidim/homepage_proposals/content_blocks/proposals_slider"
30
+ content_block.public_name_key = "decidim.homepage_proposals.content_blocks.proposals_slider.name"
31
+ content_block.settings_form_cell = "decidim/homepage_proposals/content_blocks/proposals_slider_settings_form"
32
+ content_block.settings do |settings|
33
+ settings.attribute :activate_filters, type: :boolean, default: false
34
+ settings.attribute :linked_components_id, type: :array
35
+ settings.attribute :default_linked_component, type: :integer
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/core/test/factories"
4
+
5
+ FactoryBot.define do
6
+ factory :proposals_slider, parent: :content_block do
7
+ manifest_name { :proposals_slider }
8
+ scope_name { :homepage }
9
+ settings do
10
+ {
11
+ activate_filters: false,
12
+ linked_components_id: [],
13
+ default_linked_component: nil
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module HomepageProposals
5
+ def self.version
6
+ "1.0.0"
7
+ end
8
+
9
+ def self.decidim_version
10
+ "0.26"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/homepage_proposals/admin"
4
+ require "decidim/homepage_proposals/engine"
5
+ require "decidim/homepage_proposals/admin_engine"
6
+
7
+ module Decidim
8
+ # This namespace holds the logic of the `HomepageProposals` component. This component
9
+ # allows users to create homepage_proposals in a participatory space.
10
+ module HomepageProposals
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :homepage_proposals do
5
+ desc "Seed module"
6
+ task seed: :environment do
7
+ organization = Decidim::Organization.first
8
+
9
+ components = Decidim::Component.where(manifest_name: "proposals").where.not(participatory_space: nil)
10
+
11
+ Decidim::ContentBlock.create(
12
+ decidim_organization_id: organization.id,
13
+ weight: 1,
14
+ scope_name: :homepage,
15
+ manifest_name: :proposals_slider,
16
+ published_at: Time.current,
17
+ settings: {
18
+ activate_filters: true,
19
+ linked_components_id: [components.first.id, components.second.id],
20
+ default_linked_component: components.first.id
21
+ }
22
+ )
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/gem_manager"
4
+
5
+ namespace :decidim_module_homepage_proposals do
6
+ namespace :webpacker do
7
+ desc "Installs Decidim Awesome webpacker files in Rails instance application"
8
+ task install: :environment do
9
+ puts "install NPM packages. You can also do this manually with this command:"
10
+ puts "npm i --save @glidejs/glide"
11
+ system! "npm i --save @glidejs/glide"
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decidim-homepage_proposals
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Elie Gaboriau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: decidim-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.26'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.26'
27
+ description: Homepage slider for proposals.
28
+ email:
29
+ - elie@opensourcepolitics.eu
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE-AGPLv3.txt
35
+ - README.md
36
+ - Rakefile
37
+ - app/cells/decidim/homepage_proposals/content_blocks/proposals_slider/show.erb
38
+ - app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb
39
+ - app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_settings_form/show.erb
40
+ - app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_settings_form_cell.rb
41
+ - app/controllers/decidim/proposals_slider_controller.rb
42
+ - app/packs/entrypoints/decidim_homepage_proposals.js
43
+ - app/packs/entrypoints/decidim_homepage_proposals_admin.js
44
+ - app/packs/images/decidim/homepage_proposals/icon.svg
45
+ - app/packs/images/decidim/homepage_proposals/slider_proposal_image.jpeg
46
+ - app/packs/src/decidim/homepage_proposals/admin.js
47
+ - app/packs/src/decidim/homepage_proposals/glideBuilder.js
48
+ - app/packs/src/decidim/homepage_proposals/glidejs/Manager.js
49
+ - app/packs/src/decidim/homepage_proposals/glidejs/glideItems/GlideItem.js
50
+ - app/packs/src/decidim/homepage_proposals/glidejs/glideItems/NotFound.js
51
+ - app/packs/src/decidim/homepage_proposals/glidejs/glideItems/Proposal.js
52
+ - app/packs/src/decidim/homepage_proposals/main.js
53
+ - app/packs/stylesheets/decidim/homepage_proposals/homepage_proposals.scss
54
+ - app/views/decidim/shared/homepage_proposals/_filters.erb
55
+ - app/views/decidim/shared/homepage_proposals/_filters_small_view.erb
56
+ - config/assets.rb
57
+ - config/i18n-tasks.yml
58
+ - config/locales/en.yml
59
+ - config/routes.rb
60
+ - lib/decidim/homepage_proposals.rb
61
+ - lib/decidim/homepage_proposals/admin.rb
62
+ - lib/decidim/homepage_proposals/admin_engine.rb
63
+ - lib/decidim/homepage_proposals/engine.rb
64
+ - lib/decidim/homepage_proposals/test/factories.rb
65
+ - lib/decidim/homepage_proposals/version.rb
66
+ - lib/tasks/homepage_proposals.rake
67
+ - lib/tasks/homepage_proposals_webpacker_tasks.rake
68
+ homepage: https://github.com/decidim/decidim-module-homepage_proposals
69
+ licenses:
70
+ - AGPL-3.0
71
+ metadata:
72
+ rubygems_mfa_required: 'true'
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '2.7'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.3.5
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: A decidim homepage_proposals module
92
+ test_files: []