decidim-budgets 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e9ce6f985c07de9ead8fe7abd959d3942245bdacf65a7fdd657c209be76c1c1
4
- data.tar.gz: 9cdbba896b3130d27226c34a7939bea4b4ee6edb4576623b28e44e609b35cede
3
+ metadata.gz: 74e9586e7151e64001736d0bff69a2faf0a9c323defe134d4088c66800c41702
4
+ data.tar.gz: fe6dec03b3312ee9ab2052f115a7c39bbd0ad9a1552756b7fccf2b0469c844da
5
5
  SHA512:
6
- metadata.gz: dd11bcea8e6b62bbf93e632b573bfb4de4225fc6e0395b101d8794af6bdd0284e58e1a539b74bd1c61b3fba11e0f4dc120f0571185f5c1f7ced50507d949b229
7
- data.tar.gz: 96af9c618b53fd5d58110dd5af0a0738cb43d382fb51eaef54d961f7c9b8da5bdf3ab62b1c9ba1463211d9813af01a9a45f8b3e02b853e0a72c152059cb446e6
6
+ metadata.gz: 4e2cab9e2fb0ee2494ecce9488257ef242846886d86809b220e3ed6bf3c2858ad30b9db06e60371b8cf38cb1a51ca79d81132b91d8c2b0d89f551ef132c5f06c
7
+ data.tar.gz: b47182fb5d57b24c193fe9b70a83d5fdb57232cf10ef38ed78195499255a8a70d9bb7ed05be7a6f3c6275a057b6e2e922d03c7d68c29630672c120d1aee5e387
@@ -27,11 +27,27 @@ module Decidim
27
27
  def default_filter_params
28
28
  {
29
29
  search_text: "",
30
- scope_id: "",
31
- category_id: ""
30
+ scope_id: default_filter_scope_params,
31
+ category_id: default_filter_category_params
32
32
  }
33
33
  end
34
34
 
35
+ def default_filter_category_params
36
+ return "all" unless current_component.participatory_space.categories.any?
37
+
38
+ ["all"] + current_component.participatory_space.categories.map { |category| category.id.to_s }
39
+ end
40
+
41
+ def default_filter_scope_params
42
+ return "all" unless current_component.participatory_space.scopes.any?
43
+
44
+ if current_component.participatory_space.scope
45
+ ["all", current_component.participatory_space.scope.id] + current_component.participatory_space.scope.children.map { |scope| scope.id.to_s }
46
+ else
47
+ %w(all global) + current_component.participatory_space.scopes.map { |scope| scope.id.to_s }
48
+ end
49
+ end
50
+
35
51
  def context_params
36
52
  { component: current_component, organization: current_organization }
37
53
  end
@@ -8,6 +8,7 @@ module Decidim
8
8
  include PaginateHelper
9
9
  include Decidim::Comments::CommentsHelper
10
10
  include ProjectsHelper
11
+ include Decidim::CheckBoxesTreeHelper
11
12
  end
12
13
  end
13
14
  end
@@ -19,6 +19,14 @@ module Decidim
19
19
  .or(query.where(localized_search_text_in(:description), text: "%#{search_text}%"))
20
20
  end
21
21
 
22
+ def search_category_id
23
+ super
24
+ end
25
+
26
+ def search_scope_id
27
+ super
28
+ end
29
+
22
30
  # Returns the random projects for the current page.
23
31
  def results
24
32
  Project.where(id: super.pluck(:id))
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ BudgetsType = GraphQL::ObjectType.define do
6
+ interfaces [-> { Decidim::Core::ComponentInterface }]
7
+
8
+ name "Budgets"
9
+ description "A budget component of a participatory space."
10
+
11
+ connection :projects, ProjectType.connection_type do
12
+ resolve ->(component, _args, _ctx) {
13
+ ProjectTypeHelper.base_scope(component).includes(:component)
14
+ }
15
+ end
16
+
17
+ field(:project, ProjectType) do
18
+ argument :id, !types.ID
19
+
20
+ resolve ->(component, args, _ctx) {
21
+ ProjectTypeHelper.base_scope(component).find_by(id: args[:id])
22
+ }
23
+ end
24
+ end
25
+
26
+ module ProjectTypeHelper
27
+ def self.base_scope(component)
28
+ Project.where(component: component)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ ProjectType = GraphQL::ObjectType.define do
6
+ interfaces [
7
+ -> { Decidim::Core::ScopableInterface },
8
+ -> { Decidim::Core::AttachableInterface },
9
+ -> { Decidim::Comments::CommentableInterface },
10
+ -> { Decidim::Core::CategorizableInterface }
11
+ ]
12
+
13
+ name "Project"
14
+ description "A project"
15
+
16
+ field :id, !types.ID, "The internal ID for this project"
17
+ field :title, Decidim::Core::TranslatedFieldType, "The title for this project"
18
+ field :description, Decidim::Core::TranslatedFieldType, "The description for this project"
19
+ field :budget, types.Int, "The budget for this project"
20
+ field :createdAt, Decidim::Core::DateTimeType, "When this project was created", property: :created_at
21
+ field :updatedAt, Decidim::Core::DateTimeType, "When this project was updated", property: :updated_at
22
+ field :reference, types.String, "The reference for this project"
23
+ end
24
+ end
25
+ end
@@ -13,10 +13,10 @@
13
13
  </div>
14
14
 
15
15
  <% if current_participatory_space.has_subscopes? %>
16
- <%= scopes_picker_filter form, :scope_id %>
16
+ <%= form.check_boxes_tree :scope_id, filter_scopes_values, legend_title: t(".scope") %>
17
17
  <% end %>
18
18
 
19
19
  <% if current_component.categories.any? %>
20
- <%= form.categories_select :category_id, current_component.categories, legend_title: t(".category"), disable_parents: false, label: false, prompt: t(".category_prompt") %>
20
+ <%= form.check_boxes_tree :category_id, filter_categories_values, legend_title: t(".category") %>
21
21
  <% end %>
22
22
  <% end %>
@@ -100,7 +100,7 @@ ar:
100
100
  other: "%{count} مشاريع"
101
101
  filters:
102
102
  category: الفئة
103
- category_prompt: اختر تصنيف
103
+ scope: نطاق
104
104
  search: بحث
105
105
  filters_small_view:
106
106
  close_modal: إغلاق مشروط
@@ -92,7 +92,7 @@ ca:
92
92
  other: "%{count} projectes"
93
93
  filters:
94
94
  category: Categoria
95
- category_prompt: Selecciona una categoria
95
+ scope: Àmbit
96
96
  search: Cerca
97
97
  filters_small_view:
98
98
  close_modal: Tancar finestra
@@ -96,7 +96,7 @@ cs:
96
96
  other: "%{count} projektů"
97
97
  filters:
98
98
  category: Kategorie
99
- category_prompt: Vyberte kategorii
99
+ scope: Rozsah
100
100
  search: Vyhledávání
101
101
  filters_small_view:
102
102
  close_modal: Zavřít modální
@@ -92,7 +92,7 @@ de:
92
92
  other: "%{count} Projekte"
93
93
  filters:
94
94
  category: Kategorie
95
- category_prompt: Wählen Sie eine Kategorie
95
+ scope: Umfang
96
96
  search: Suche
97
97
  filters_small_view:
98
98
  close_modal: Modal schließen
@@ -0,0 +1 @@
1
+ el:
@@ -93,7 +93,7 @@ en:
93
93
  other: "%{count} projects"
94
94
  filters:
95
95
  category: Category
96
- category_prompt: Select a category
96
+ scope: Scope
97
97
  search: Search
98
98
  filters_small_view:
99
99
  close_modal: Close modal
@@ -92,7 +92,7 @@ es-MX:
92
92
  other: "%{count} proyectos"
93
93
  filters:
94
94
  category: Categoría
95
- category_prompt: Selecciona una categoría
95
+ scope: Ámbito
96
96
  search: Buscar
97
97
  filters_small_view:
98
98
  close_modal: Cerrar ventana
@@ -92,7 +92,7 @@ es-PY:
92
92
  other: "%{count} proyectos"
93
93
  filters:
94
94
  category: Categoría
95
- category_prompt: Selecciona una categoría
95
+ scope: Ámbito
96
96
  search: Buscar
97
97
  filters_small_view:
98
98
  close_modal: Cerrar ventana
@@ -92,7 +92,7 @@ es:
92
92
  other: "%{count} proyectos"
93
93
  filters:
94
94
  category: Categoría
95
- category_prompt: Selecciona una categoría
95
+ scope: Ámbito
96
96
  search: Buscar
97
97
  filters_small_view:
98
98
  close_modal: Cerrar ventana
@@ -92,7 +92,7 @@ eu:
92
92
  other: "%{count} proiektu"
93
93
  filters:
94
94
  category: Kategoria
95
- category_prompt: Aukeratu kategoria bat
95
+ scope: Esparrua
96
96
  search: Bilatu
97
97
  filters_small_view:
98
98
  close_modal: Itxi leihoa
@@ -92,7 +92,7 @@ fi-pl:
92
92
  other: "%{count} suunnitelmaa"
93
93
  filters:
94
94
  category: Aihepiiri
95
- category_prompt: Valitse aihepiiri
95
+ scope: Teema
96
96
  search: Haku
97
97
  filters_small_view:
98
98
  close_modal: Sulje ikkuna
@@ -92,7 +92,7 @@ fi:
92
92
  other: "%{count} suunnitelmaa"
93
93
  filters:
94
94
  category: Aihepiiri
95
- category_prompt: Valitse aihepiiri
95
+ scope: Teema
96
96
  search: Haku
97
97
  filters_small_view:
98
98
  close_modal: Sulje ikkuna
@@ -92,7 +92,7 @@ fr:
92
92
  other: "%{count} projets"
93
93
  filters:
94
94
  category: Catégorie
95
- category_prompt: Sélectionner une catégorie
95
+ scope: Périmètre d'application
96
96
  search: Rechercher
97
97
  filters_small_view:
98
98
  close_modal: Fermez la fenêtre
@@ -92,7 +92,7 @@ gl:
92
92
  other: "%{count} proxectos"
93
93
  filters:
94
94
  category: Categoría
95
- category_prompt: Selecciona unha categoría
95
+ scope: Alcance
96
96
  search: Busca
97
97
  filters_small_view:
98
98
  close_modal: Pechar modal
@@ -92,7 +92,7 @@ hu:
92
92
  other: "%{count} projektek"
93
93
  filters:
94
94
  category: Kategória
95
- category_prompt: Válassz kategóriát
95
+ scope: Hatáskör
96
96
  search: Keresés
97
97
  filters_small_view:
98
98
  close_modal: Modal bezárása
@@ -90,7 +90,7 @@ id:
90
90
  other: "%{count} proyek"
91
91
  filters:
92
92
  category: Kategori
93
- category_prompt: Pilih Kategori
93
+ scope: Cakupan
94
94
  search: Pencarian
95
95
  filters_small_view:
96
96
  close_modal: Tutup modal
@@ -71,7 +71,7 @@ is-IS:
71
71
  other: "%{count} verkefni"
72
72
  filters:
73
73
  category: Flokkur
74
- category_prompt: Veldu flokk
74
+ scope: Umfang
75
75
  search: Leita
76
76
  filters_small_view:
77
77
  close_modal: Loka mát
@@ -92,7 +92,7 @@ it:
92
92
  other: "%{count} progetti"
93
93
  filters:
94
94
  category: Categoria
95
- category_prompt: Scegli una categoria
95
+ scope: Ambito tematico
96
96
  search: Cerca
97
97
  filters_small_view:
98
98
  close_modal: Chiudi modalità
@@ -92,7 +92,7 @@ nl:
92
92
  other: "%{count} projecten"
93
93
  filters:
94
94
  category: Categorie
95
- category_prompt: Kies een categorie
95
+ scope: Reikwijdte
96
96
  search: Zoeken
97
97
  filters_small_view:
98
98
  close_modal: Dialoogvenster sluiten
@@ -92,7 +92,7 @@
92
92
  other: "%{count} prosjekter"
93
93
  filters:
94
94
  category: Kategori
95
- category_prompt: Velg en kategori
95
+ scope: Omfang
96
96
  search: Søk
97
97
  filters_small_view:
98
98
  close_modal: Lukk modal
@@ -96,7 +96,7 @@ pl:
96
96
  other: "%{count} projektów"
97
97
  filters:
98
98
  category: Kategoria
99
- category_prompt: Wybierz kategorię
99
+ scope: Zakres
100
100
  search: Szukanie
101
101
  filters_small_view:
102
102
  close_modal: Zamknij modal
@@ -92,7 +92,7 @@ pt-BR:
92
92
  other: "%{count} projetos"
93
93
  filters:
94
94
  category: Categoria
95
- category_prompt: Selecione uma categoria
95
+ scope: Âmbito
96
96
  search: Pesquisa
97
97
  filters_small_view:
98
98
  close_modal: Fechar modal
@@ -92,7 +92,7 @@ pt:
92
92
  other: "%{count} projetos"
93
93
  filters:
94
94
  category: Categoria
95
- category_prompt: Selecione uma categoria
95
+ scope: Âmbito
96
96
  search: Pesquisa
97
97
  filters_small_view:
98
98
  close_modal: Fechar modal
@@ -96,7 +96,7 @@ ru:
96
96
  other: "%{count} проектов"
97
97
  filters:
98
98
  category: Категория
99
- category_prompt: Выберите категорию
99
+ scope: Охват
100
100
  search: Поиск
101
101
  filters_small_view:
102
102
  close_modal: Закрыть окошко
@@ -92,7 +92,7 @@ sv:
92
92
  other: "%{count} projekt"
93
93
  filters:
94
94
  category: Kategori
95
- category_prompt: Välj en kategori
95
+ scope: Omfång
96
96
  search: Sök
97
97
  filters_small_view:
98
98
  close_modal: Stäng fönstret
@@ -92,7 +92,7 @@ tr:
92
92
  other: "%{count} proje"
93
93
  filters:
94
94
  category: Kategori
95
- category_prompt: bir kategori seç
95
+ scope: kapsam
96
96
  search: Arama
97
97
  filters_small_view:
98
98
  close_modal: Kalıcı modal
@@ -96,7 +96,7 @@ uk:
96
96
  other: "%{count} проектів"
97
97
  filters:
98
98
  category: Категорія
99
- category_prompt: Оберіть категорію
99
+ scope: Обсяг
100
100
  search: Шукати
101
101
  filters_small_view:
102
102
  close_modal: Закрити віконце
@@ -13,6 +13,8 @@ Decidim.register_component(:budgets) do |component|
13
13
 
14
14
  component.newsletter_participant_entities = ["Decidim::Budgets::Order"]
15
15
 
16
+ component.query_type = "Decidim::Budgets::BudgetsType"
17
+
16
18
  component.actions = %(vote)
17
19
 
18
20
  component.on(:before_destroy) do |instance|
@@ -43,6 +45,11 @@ Decidim.register_component(:budgets) do |component|
43
45
  Decidim::Comments::Comment.where(root_commentable: projects).count
44
46
  end
45
47
 
48
+ component.register_stat :followers_count, tag: :followers, priority: Decidim::StatsRegistry::LOW_PRIORITY do |components, start_at, end_at|
49
+ projects_ids = Decidim::Budgets::FilteredProjects.for(components, start_at, end_at).pluck(:id)
50
+ Decidim::Follow.where(decidim_followable_type: "Decidim::Budgets::Project", decidim_followable_id: projects_ids).count
51
+ end
52
+
46
53
  component.settings(:global) do |settings|
47
54
  settings.attribute :projects_per_page, type: :integer, default: 12
48
55
  settings.attribute :total_budget, type: :integer, default: 100_000_000
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-budgets version.
5
5
  module Budgets
6
6
  def self.version
7
- "0.20.1"
7
+ "0.21.0"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-budgets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-03-27 00:00:00.000000000 Z
13
+ date: 2020-04-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-comments
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.20.1
21
+ version: 0.21.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.20.1
28
+ version: 0.21.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: decidim-core
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.20.1
35
+ version: 0.21.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.20.1
42
+ version: 0.21.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: kaminari
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -74,42 +74,42 @@ dependencies:
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.20.1
77
+ version: 0.21.0
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - '='
83
83
  - !ruby/object:Gem::Version
84
- version: 0.20.1
84
+ version: 0.21.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: decidim-dev
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - '='
90
90
  - !ruby/object:Gem::Version
91
- version: 0.20.1
91
+ version: 0.21.0
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - '='
97
97
  - !ruby/object:Gem::Version
98
- version: 0.20.1
98
+ version: 0.21.0
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: decidim-proposals
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - '='
104
104
  - !ruby/object:Gem::Version
105
- version: 0.20.1
105
+ version: 0.21.0
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - '='
111
111
  - !ruby/object:Gem::Version
112
- version: 0.20.1
112
+ version: 0.21.0
113
113
  description: A budgets component for decidim's participatory spaces.
114
114
  email:
115
115
  - josepjaume@gmail.com
@@ -167,6 +167,8 @@ files:
167
167
  - app/queries/decidim/budgets/metrics/budget_participants_metric_measure.rb
168
168
  - app/serializers/decidim/budgets/data_portability_budgets_order_serializer.rb
169
169
  - app/services/decidim/budgets/project_search.rb
170
+ - app/types/decidim/budgets/budgets_type.rb
171
+ - app/types/decidim/budgets/project_type.rb
170
172
  - app/views/decidim/budgets/admin/projects/_form.html.erb
171
173
  - app/views/decidim/budgets/admin/projects/edit.html.erb
172
174
  - app/views/decidim/budgets/admin/projects/index.html.erb
@@ -196,6 +198,7 @@ files:
196
198
  - config/locales/cs.yml
197
199
  - config/locales/de.yml
198
200
  - config/locales/el-GR.yml
201
+ - config/locales/el.yml
199
202
  - config/locales/en.yml
200
203
  - config/locales/eo-UY.yml
201
204
  - config/locales/es-MX.yml