Class: Decidim::ParticipatoryProcesses::ContentBlocks::RegistryManager

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/participatory_processes/content_blocks/registry_manager.rb

Class Method Summary collapse

Class Method Details

.register!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/decidim/participatory_processes/content_blocks/registry_manager.rb', line 7

def self.register!
  Decidim.content_blocks.register(:homepage, :highlighted_processes) do |content_block|
    content_block.cell = "decidim/participatory_processes/content_blocks/highlighted_processes"
    content_block.public_name_key = "decidim.participatory_processes.content_blocks.highlighted_processes.name"
    content_block.settings_form_cell = "decidim/participatory_processes/content_blocks/highlighted_processes_settings_form"

    content_block.settings do |settings|
      settings.attribute :max_results, type: :integer, default: 6
    end
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :title) do |content_block|
    content_block.cell = "decidim/participatory_process_groups/content_blocks/main_data"
    content_block.public_name_key = "decidim.participatory_process_groups.content_blocks.main_data.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :extra_data) do |content_block|
    content_block.cell = "decidim/participatory_process_groups/content_blocks/extra_data"
    content_block.public_name_key = "decidim.participatory_process_groups.content_blocks.extra_data.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :hero) do |content_block|
    content_block.cell = "decidim/content_blocks/participatory_space_hero"
    content_block.settings_form_cell = "decidim/content_blocks/participatory_space_hero_settings_form"
    content_block.public_name_key = "decidim.participatory_processes.content_blocks.hero.name"

    content_block.images = [
      {
        name: :background_image,
        uploader: "Decidim::BackgroundImageUploader"
      }
    ]

    content_block.settings do |settings|
      settings.attribute :button_text, type: :text, translated: true
      settings.attribute :button_url, type: :text, translated: true
    end

    content_block.default!
  end

  (1..3).each do |index|
    Decidim.content_blocks.register(:participatory_process_group_homepage, :"html_#{index}") do |content_block|
      content_block.cell = "decidim/content_blocks/html"
      content_block.public_name_key = "decidim.participatory_process_groups.content_blocks.html_#{index}.name"
      content_block.settings_form_cell = "decidim/content_blocks/html_settings_form"

      content_block.settings do |settings|
        settings.attribute :html_content, type: :text, translated: true
      end
    end
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :html) do |content_block|
    content_block.cell = "decidim/content_blocks/html"
    content_block.public_name_key = "decidim.content_blocks.html.name"
    content_block.settings_form_cell = "decidim/content_blocks/html_settings_form"

    content_block.settings do |settings|
      settings.attribute :html_content, type: :text, translated: true
    end
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :hero) do |content_block|
    content_block.cell = "decidim/content_blocks/participatory_space_hero"
    content_block.settings_form_cell = "decidim/content_blocks/participatory_space_hero_settings_form"
    content_block.public_name_key = "decidim.participatory_processes.content_blocks.hero.name"

    content_block.images = [
      {
        name: :background_image,
        uploader: "Decidim::BackgroundImageUploader"
      }
    ]

    content_block.settings do |settings|
      settings.attribute :button_text, type: :text, translated: true
      settings.attribute :button_url, type: :text, translated: true
    end

    content_block.default!
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :announcement) do |content_block|
    content_block.cell = "decidim/content_blocks/participatory_space_announcement"
    content_block.public_name_key = "decidim.content_blocks.announcement.name"
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :main_data) do |content_block|
    content_block.cell = "decidim/participatory_processes/content_blocks/main_data"
    content_block.public_name_key = "decidim.content_blocks.main_data.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :extra_data) do |content_block|
    content_block.cell = "decidim/participatory_processes/content_blocks/extra_data"
    content_block.public_name_key = "decidim.participatory_processes.content_blocks.extra_data.name"
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :metadata) do |content_block|
    content_block.cell = "decidim/participatory_processes/content_blocks/metadata"
    content_block.public_name_key = "decidim.content_blocks.metadata.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :last_activity) do |content_block|
    content_block.cell = "decidim/content_blocks/participatory_space_last_activity"
    content_block.public_name_key = "decidim.content_blocks.last_activity.name"
    content_block.settings_form_cell = "decidim/content_blocks/last_activity_settings_form"
    content_block.settings do |settings|
      settings.attribute :max_last_activity_users, type: :integer, default: Decidim.default_max_last_activity_users
    end
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :stats) do |content_block|
    content_block.cell = "decidim/participatory_processes/content_blocks/stats"
    content_block.public_name_key = "decidim.content_blocks.participatory_space_stats.name"
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :metrics) do |content_block|
    content_block.cell = "decidim/participatory_processes/content_blocks/metrics"
    content_block.public_name_key = "decidim.content_blocks.participatory_space_metrics.name"
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :related_processes) do |content_block|
    content_block.cell = "decidim/participatory_processes/content_blocks/related_processes"
    content_block.settings_form_cell = "decidim/participatory_processes/content_blocks/highlighted_processes_settings_form"
    content_block.public_name_key = "decidim.participatory_processes.content_blocks.related_processes.name"

    content_block.settings do |settings|
      settings.attribute :max_results, type: :integer, default: 6
    end
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :related_documents) do |content_block|
    content_block.cell = "decidim/content_blocks/participatory_space_documents"
    content_block.public_name_key = "decidim.application.documents.related_documents"
  end

  Decidim.content_blocks.register(:participatory_process_homepage, :related_images) do |content_block|
    content_block.cell = "decidim/content_blocks/participatory_space_images"
    content_block.public_name_key = "decidim.application.photos.related_photos"
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :stats) do |content_block|
    content_block.cell = "decidim/participatory_process_groups/content_blocks/statistics"
    content_block.public_name_key = "decidim.participatory_process_groups.content_blocks.stats.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :participatory_processes) do |content_block|
    content_block.cell = "decidim/participatory_process_groups/content_blocks/related_processes"
    content_block.settings_form_cell = "decidim/participatory_processes/content_blocks/processes_settings_form"
    content_block.public_name_key = "decidim.participatory_process_groups.content_blocks.participatory_processes.name"

    content_block.settings do |settings|
      settings.attribute :default_filter, type: :enum, default: "active", choices: %w(active all)
    end
  end

  register_highlighted_meetings
  register_highlighted_posts
  register_highlighted_proposals
  register_highlighted_results
  register_related_assemblies
end

.register_highlighted_meetingsObject



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/decidim/participatory_processes/content_blocks/registry_manager.rb', line 176

def self.register_highlighted_meetings
  return unless Decidim.module_installed?(:meetings)

  Decidim.content_blocks.register(:participatory_process_homepage, :highlighted_meetings) do |content_block|
    content_block.cell = "decidim/meetings/content_blocks/highlighted_meetings"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_elements_for_component_settings_form"
    content_block.public_name_key = "decidim.meetings.content_blocks.upcoming_meetings.name"
    content_block.component_manifest_name = "meetings"

    content_block.settings do |settings|
      settings.attribute :component_id, type: :select, default: nil
    end
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :highlighted_meetings) do |content_block|
    content_block.cell = "decidim/meetings/content_blocks/highlighted_meetings"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_elements_settings_form"
    content_block.public_name_key = "decidim.meetings.content_blocks.upcoming_meetings.name"
    content_block.component_manifest_name = "meetings"
    content_block.default!

    content_block.settings do |settings|
      settings.attribute :order, type: :enum, default: "random", choices: %w(random recent)
      settings.attribute :show_space, type: :boolean, default: true
    end
  end
end

.register_highlighted_postsObject



204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/decidim/participatory_processes/content_blocks/registry_manager.rb', line 204

def self.register_highlighted_posts
  return unless Decidim.module_installed?(:blogs)

  Decidim.content_blocks.register(:participatory_process_homepage, :highlighted_posts) do |content_block|
    content_block.cell = "decidim/blogs/content_blocks/highlighted_posts"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_elements_for_component_settings_form"
    content_block.public_name_key = "decidim.blogs.content_blocks.highlighted_posts.name"
    content_block.component_manifest_name = "blogs"

    content_block.settings do |settings|
      settings.attribute :component_id, type: :select, default: nil
    end
  end
end

.register_highlighted_proposalsObject



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/decidim/participatory_processes/content_blocks/registry_manager.rb', line 219

def self.register_highlighted_proposals
  return unless Decidim.module_installed?(:proposals)

  Decidim.content_blocks.register(:participatory_process_homepage, :highlighted_proposals) do |content_block|
    content_block.cell = "decidim/proposals/content_blocks/highlighted_proposals"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_elements_for_component_settings_form"
    content_block.public_name_key = "decidim.proposals.content_blocks.highlighted_proposals.name"
    content_block.component_manifest_name = "proposals"

    content_block.settings do |settings|
      settings.attribute :order, type: :enum, default: "recent", choices: %w(random recent)
      settings.attribute :component_id, type: :select, default: nil
    end
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :highlighted_proposals) do |content_block|
    content_block.cell = "decidim/proposals/content_blocks/highlighted_proposals"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_elements_settings_form"
    content_block.public_name_key = "decidim.proposals.content_blocks.highlighted_proposals.name"
    content_block.component_manifest_name = "proposals"

    content_block.settings do |settings|
      settings.attribute :order, type: :enum, default: "random", choices: %w(random recent)
      settings.attribute :show_space, type: :boolean, default: true
    end
  end
end

.register_highlighted_resultsObject



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/decidim/participatory_processes/content_blocks/registry_manager.rb', line 247

def self.register_highlighted_results
  return unless Decidim.module_installed?(:accountability)

  Decidim.content_blocks.register(:participatory_process_homepage, :highlighted_results) do |content_block|
    content_block.cell = "decidim/accountability/content_blocks/highlighted_results"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_elements_for_component_settings_form"
    content_block.public_name_key = "decidim.accountability.content_blocks.highlighted_results.results"
    content_block.component_manifest_name = "accountability"

    content_block.settings do |settings|
      settings.attribute :order, type: :enum, default: "random", choices: %w(random recent)
      settings.attribute :component_id, type: :select, default: nil
    end
  end

  Decidim.content_blocks.register(:participatory_process_group_homepage, :highlighted_results) do |content_block|
    content_block.cell = "decidim/accountability/content_blocks/highlighted_results"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_elements_settings_form"
    content_block.public_name_key = "decidim.accountability.content_blocks.highlighted_results.results"
    content_block.component_manifest_name = "accountability"
    content_block.default!

    content_block.settings do |settings|
      settings.attribute :order, type: :enum, default: "random", choices: %w(random recent)
      settings.attribute :show_space, type: :boolean, default: true
    end
  end
end


276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/decidim/participatory_processes/content_blocks/registry_manager.rb', line 276

def self.register_related_assemblies
  return unless Decidim.module_installed?(:assemblies)

  Decidim.content_blocks.register(:participatory_process_homepage, :related_assemblies) do |content_block|
    content_block.cell = "decidim/assemblies/content_blocks/related_assemblies"
    content_block.settings_form_cell = "decidim/assemblies/content_blocks/highlighted_assemblies_settings_form"
    content_block.public_name_key = "decidim.assemblies.content_blocks.related_assemblies.name"

    content_block.settings do |settings|
      settings.attribute :max_results, type: :integer, default: 6
    end
  end
end