decidim-assemblies 0.30.1 → 0.31.0.rc1

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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_settings_form/show.erb +3 -1
  3. data/app/commands/decidim/assemblies/admin/create_assembly.rb +1 -1
  4. data/app/commands/decidim/assemblies/admin/{copy_assembly.rb → duplicate_assembly.rb} +20 -21
  5. data/app/commands/decidim/assemblies/admin/update_assembly.rb +1 -1
  6. data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +3 -3
  7. data/app/controllers/decidim/assemblies/admin/assembly_duplicates_controller.rb +35 -0
  8. data/app/controllers/decidim/assemblies/admin/assembly_imports_controller.rb +1 -1
  9. data/app/controllers/decidim/assemblies/admin/assembly_landing_page_controller.rb +4 -0
  10. data/app/forms/decidim/assemblies/admin/{assembly_copy_form.rb → assembly_duplicate_form.rb} +4 -4
  11. data/app/forms/decidim/assemblies/admin/assembly_form.rb +0 -1
  12. data/app/models/decidim/assembly.rb +0 -4
  13. data/app/packs/entrypoints/decidim_assemblies_admin.js +0 -1
  14. data/app/packs/src/decidim/assemblies/admin/assemblies.js +3 -62
  15. data/app/packs/src/decidim/assemblies/controllers/.gitkeep +0 -0
  16. data/app/packs/src/decidim/assemblies/controllers/assembly_admin/assembly_admin.test.js +1077 -0
  17. data/app/packs/src/decidim/assemblies/controllers/assembly_admin/controller.js +66 -0
  18. data/app/permissions/decidim/assemblies/permissions.rb +9 -9
  19. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +0 -1
  20. data/app/presenters/decidim/assemblies/assembly_stats_presenter.rb +1 -3
  21. data/app/queries/decidim/assemblies/assemblies_stats_followers_count.rb +14 -0
  22. data/app/queries/decidim/assemblies/assemblies_stats_participants_count.rb +14 -0
  23. data/app/serializers/decidim/assemblies/assembly_importer.rb +5 -4
  24. data/app/views/decidim/assemblies/admin/assemblies/_assembly_row.html.erb +118 -49
  25. data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +8 -12
  26. data/app/views/decidim/assemblies/admin/assemblies/edit.html.erb +1 -9
  27. data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +2 -2
  28. data/app/views/decidim/assemblies/admin/assemblies/index.js.erb +4 -0
  29. data/app/views/decidim/assemblies/admin/assemblies/manage_trash.html.erb +2 -1
  30. data/app/views/decidim/assemblies/admin/assemblies/new.html.erb +1 -1
  31. data/app/views/decidim/assemblies/admin/{assembly_copies → assembly_duplicates}/_form.html.erb +4 -4
  32. data/app/views/decidim/assemblies/admin/assembly_duplicates/new.html.erb +19 -0
  33. data/app/views/decidim/assemblies/admin/assembly_user_roles/index.html.erb +42 -18
  34. data/app/views/decidim/assemblies/assemblies/index.html.erb +0 -1
  35. data/app/views/layouts/decidim/admin/_manage_assemblies.html.erb +1 -1
  36. data/config/assets.rb +2 -3
  37. data/config/locales/ar.yml +0 -19
  38. data/config/locales/bg.yml +0 -23
  39. data/config/locales/bs-BA.yml +0 -4
  40. data/config/locales/ca-IT.yml +11 -16
  41. data/config/locales/ca.yml +11 -16
  42. data/config/locales/cs.yml +12 -17
  43. data/config/locales/de.yml +14 -19
  44. data/config/locales/el.yml +0 -19
  45. data/config/locales/en.yml +11 -16
  46. data/config/locales/es-MX.yml +15 -20
  47. data/config/locales/es-PY.yml +15 -20
  48. data/config/locales/es.yml +13 -18
  49. data/config/locales/eu.yml +14 -19
  50. data/config/locales/fi-plain.yml +13 -18
  51. data/config/locales/fi.yml +13 -18
  52. data/config/locales/fr-CA.yml +10 -15
  53. data/config/locales/fr.yml +10 -15
  54. data/config/locales/ga-IE.yml +0 -6
  55. data/config/locales/gl.yml +0 -19
  56. data/config/locales/he-IL.yml +0 -17
  57. data/config/locales/hu.yml +0 -20
  58. data/config/locales/id-ID.yml +0 -18
  59. data/config/locales/is-IS.yml +0 -12
  60. data/config/locales/it.yml +39 -23
  61. data/config/locales/ja.yml +12 -17
  62. data/config/locales/kaa.yml +0 -3
  63. data/config/locales/ko.yml +0 -4
  64. data/config/locales/lb.yml +0 -18
  65. data/config/locales/lt.yml +0 -20
  66. data/config/locales/lv.yml +0 -19
  67. data/config/locales/nl.yml +0 -19
  68. data/config/locales/no.yml +0 -19
  69. data/config/locales/pl.yml +0 -23
  70. data/config/locales/pt-BR.yml +0 -23
  71. data/config/locales/pt.yml +0 -24
  72. data/config/locales/ro-RO.yml +2 -20
  73. data/config/locales/ru.yml +0 -16
  74. data/config/locales/sk.yml +0 -8
  75. data/config/locales/sl.yml +0 -18
  76. data/config/locales/sq-AL.yml +0 -21
  77. data/config/locales/sr-CS.yml +0 -4
  78. data/config/locales/sv.yml +17 -23
  79. data/config/locales/tr-TR.yml +0 -19
  80. data/config/locales/uk.yml +0 -16
  81. data/config/locales/zh-CN.yml +0 -19
  82. data/config/locales/zh-TW.yml +0 -19
  83. data/db/migrate/20250604081741_remove_hastags_column_assemblies.rb +7 -0
  84. data/lib/decidim/api/assembly_type.rb +10 -6
  85. data/lib/decidim/assemblies/admin_engine.rb +1 -1
  86. data/lib/decidim/assemblies/api.rb +0 -1
  87. data/lib/decidim/assemblies/engine.rb +5 -14
  88. data/lib/decidim/assemblies/menu.rb +1 -1
  89. data/lib/decidim/assemblies/participatory_space.rb +14 -0
  90. data/lib/decidim/assemblies/query_extensions.rb +0 -18
  91. data/lib/decidim/assemblies/seeds.rb +2 -3
  92. data/lib/decidim/assemblies/test/factories.rb +2 -2
  93. data/lib/decidim/assemblies/version.rb +1 -1
  94. metadata +23 -21
  95. data/app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb +0 -35
  96. data/app/packs/entrypoints/decidim_assemblies.js +0 -4
  97. data/app/packs/src/decidim/assemblies/assemblies.js +0 -14
  98. data/app/queries/decidim/assemblies/metrics/assemblies_metric_manage.rb +0 -27
  99. data/app/views/decidim/assemblies/admin/assembly_copies/new.html.erb +0 -19
  100. data/lib/decidim/api/assemblies_type_type.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71be77d034427c92b4c91b920d082170df08d5563aa2f73806e57404f466c888
4
- data.tar.gz: '085029e0c7680f62f908940a0a33f32dc19aeaedf406fb6e3cf9499bde8ea0e4'
3
+ metadata.gz: d018d946999f92c36cb1382901e224dc928869b75f0598598a9009915273b443
4
+ data.tar.gz: c3f32fc6f46777b1a5c0837bb3d5ca4a8dbaf45d87725e52d9c8369168421121
5
5
  SHA512:
6
- metadata.gz: 7033326acb2853ea34bc06ea93f7eea65991790d2adc0f4d1e70922ca8ffbd84ab56d1c61f066c6797410421a87dfef1ca99dae17f8714e9bc3f9782cf6eae8d
7
- data.tar.gz: b267638567476032f186de1e7fd917efb8728f76391c8d074551aeccc43f17da484557fa0056e5c714073dbe18d7e3b8c0119a4e616398baa5c2f10afd735db4
6
+ metadata.gz: 61e63411dd6100f1d766d6f6feaf714efd607e0d1d0e76b70613a091afbe9a3ccb34ee3e20f45d478c3a1ea365020a0d524ece702676c4edd9916328d849e1a8
7
+ data.tar.gz: 64d22117555d2275ee23236c7ba8cc4991ee40f3cdd11540b2bebe76aa315c53210c728051cd760766b003869ad51d97135407fa96763ab3b3ae4cac028cbcf3
@@ -1,3 +1,5 @@
1
1
  <% form.fields_for :settings, form.object.settings do |settings_fields| %>
2
- <%= settings_fields.number_field :max_results, label: %>
2
+ <div class="row column">
3
+ <%= settings_fields.number_field :max_results, label: %>
4
+ </div>
3
5
  <% end %>
@@ -8,7 +8,7 @@ module Decidim
8
8
  class CreateAssembly < Decidim::Commands::CreateResource
9
9
  fetch_file_attributes :hero_image, :banner_image
10
10
 
11
- fetch_form_attributes :title, :subtitle, :weight, :slug, :hashtag, :description, :short_description,
11
+ fetch_form_attributes :title, :subtitle, :weight, :slug, :description, :short_description,
12
12
  :promoted, :taxonomizations, :parent, :announcement, :organization,
13
13
  :private_space, :developer_group, :local_area, :target, :participatory_scope,
14
14
  :participatory_structure, :meta_scope, :purpose_of_action,
@@ -3,9 +3,9 @@
3
3
  module Decidim
4
4
  module Assemblies
5
5
  module Admin
6
- # A command with all the business logic when copying a new participatory
6
+ # A command with all the business logic when duplicating a new participatory
7
7
  # assembly in the system.
8
- class CopyAssembly < Decidim::Command
8
+ class DuplicateAssembly < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -27,27 +27,26 @@ module Decidim
27
27
 
28
28
  Decidim.traceability.perform_action!("duplicate", @assembly, @user) do
29
29
  Assembly.transaction do
30
- copy_assembly
31
- copy_assembly_attachments
32
- copy_assembly_components if @form.copy_components?
33
- copy_landing_page_blocks if @form.copy_landing_page_blocks?
30
+ duplicate_assembly
31
+ duplicate_assembly_attachments
32
+ duplicate_assembly_components if @form.duplicate_components?
33
+ duplicate_landing_page_blocks if @form.duplicate_landing_page_blocks?
34
34
  end
35
35
  end
36
36
 
37
- broadcast(:ok, @copied_assembly)
37
+ broadcast(:ok, @duplicated_assembly)
38
38
  end
39
39
 
40
40
  private
41
41
 
42
42
  attr_reader :form
43
43
 
44
- def copy_assembly
45
- @copied_assembly = Assembly.create!(
44
+ def duplicate_assembly
45
+ @duplicated_assembly = Assembly.create!(
46
46
  organization: @assembly.organization,
47
47
  title: form.title,
48
48
  subtitle: @assembly.subtitle,
49
49
  slug: form.slug,
50
- hashtag: @assembly.hashtag,
51
50
  description: @assembly.description,
52
51
  short_description: @assembly.short_description,
53
52
  promoted: @assembly.promoted,
@@ -64,47 +63,47 @@ module Decidim
64
63
  )
65
64
  end
66
65
 
67
- def copy_assembly_attachments
66
+ def duplicate_assembly_attachments
68
67
  [:hero_image, :banner_image].each do |attribute|
69
68
  next unless @assembly.attached_uploader(attribute).attached?
70
69
 
71
- @copied_assembly.send(attribute).attach(@assembly.send(attribute).blob)
70
+ @duplicated_assembly.send(attribute).attach(@assembly.send(attribute).blob)
72
71
  end
73
72
  end
74
73
 
75
- def copy_assembly_components
74
+ def duplicate_assembly_components
76
75
  @assembly.components.each do |component|
77
76
  new_component = Component.create!(
78
77
  manifest_name: component.manifest_name,
79
78
  name: component.name,
80
- participatory_space: @copied_assembly,
79
+ participatory_space: @duplicated_assembly,
81
80
  settings: component.settings,
82
81
  step_settings: component.step_settings,
83
82
  weight: component.weight
84
83
  )
85
- component.manifest.run_hooks(:copy, new_component:, old_component: component)
84
+ component.manifest.run_hooks(:duplicate, new_component:, old_component: component)
86
85
  end
87
86
  end
88
87
 
89
- def copy_landing_page_blocks
88
+ def duplicate_landing_page_blocks
90
89
  blocks = Decidim::ContentBlock.where(scoped_resource_id: @assembly.id, scope_name: "assembly_homepage", organization: @assembly.organization)
91
90
  return if blocks.blank?
92
91
 
93
92
  blocks.each do |block|
94
93
  new_block = Decidim::ContentBlock.create!(
95
- organization: @copied_assembly.organization,
94
+ organization: @duplicated_assembly.organization,
96
95
  scope_name: "assembly_homepage",
97
- scoped_resource_id: @copied_assembly.id,
96
+ scoped_resource_id: @duplicated_assembly.id,
98
97
  manifest_name: block.manifest_name,
99
98
  settings: block.settings,
100
99
  weight: block.weight,
101
- published_at: block.published_at.present? ? @copied_assembly.created_at : nil # determine if block is active/inactive
100
+ published_at: block.published_at.present? ? @duplicated_assembly.created_at : nil # determine if block is active/inactive
102
101
  )
103
- copy_block_attachments(block, new_block) if block.attachments.present?
102
+ duplicate_block_attachments(block, new_block) if block.attachments.present?
104
103
  end
105
104
  end
106
105
 
107
- def copy_block_attachments(block, new_block)
106
+ def duplicate_block_attachments(block, new_block)
108
107
  block.attachments.map(&:name).each do |name|
109
108
  original_image = block.images_container.send(name).blob
110
109
  next if original_image.blank?
@@ -8,7 +8,7 @@ module Decidim
8
8
  class UpdateAssembly < Decidim::Commands::UpdateResource
9
9
  fetch_file_attributes :hero_image, :banner_image
10
10
 
11
- fetch_form_attributes :title, :subtitle, :slug, :hashtag, :promoted, :description, :short_description,
11
+ fetch_form_attributes :title, :subtitle, :slug, :promoted, :description, :short_description,
12
12
  :taxonomizations, :parent, :private_space, :developer_group, :local_area,
13
13
  :target, :participatory_scope, :participatory_structure, :meta_scope,
14
14
  :purpose_of_action, :composition, :creation_date, :created_by,
@@ -37,7 +37,7 @@ module Decidim
37
37
 
38
38
  on(:invalid) do
39
39
  flash.now[:alert] = I18n.t("assemblies.create.error", scope: "decidim.admin")
40
- render :new
40
+ render :new, status: :unprocessable_entity
41
41
  end
42
42
  end
43
43
  end
@@ -63,12 +63,12 @@ module Decidim
63
63
 
64
64
  on(:invalid) do
65
65
  flash.now[:alert] = I18n.t("assemblies.update.error", scope: "decidim.admin")
66
- render :edit, layout: "decidim/admin/assembly"
66
+ render :edit, layout: "decidim/admin/assembly", status: :unprocessable_entity
67
67
  end
68
68
  end
69
69
  end
70
70
 
71
- def copy
71
+ def duplicate
72
72
  enforce_permission_to :create, :assembly, assembly: collection.find_by(id: params[:parent_id])
73
73
  end
74
74
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # Controller that allows managing assemblies.
7
+ #
8
+ class AssemblyDuplicatesController < Decidim::Assemblies::Admin::ApplicationController
9
+ include Concerns::AssemblyAdmin
10
+
11
+ def new
12
+ enforce_permission_to :create, :assembly
13
+ @form = form(AssemblyDuplicateForm).from_model(current_assembly)
14
+ end
15
+
16
+ def create
17
+ enforce_permission_to :create, :assembly
18
+ @form = form(AssemblyDuplicateForm).from_params(params)
19
+
20
+ DuplicateAssembly.call(@form, current_assembly, current_user) do
21
+ on(:ok) do
22
+ flash[:notice] = I18n.t("assemblies_duplicates.create.success", scope: "decidim.admin")
23
+ redirect_to assemblies_path
24
+ end
25
+
26
+ on(:invalid) do
27
+ flash.now[:alert] = I18n.t("assemblies_duplicates.create.error", scope: "decidim.admin")
28
+ render :new, status: :unprocessable_entity
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -23,7 +23,7 @@ module Decidim
23
23
 
24
24
  on(:invalid) do
25
25
  flash.now[:alert] = I18n.t("assembly_imports.create.error", scope: "decidim.admin")
26
- render :new
26
+ render :new, status: :unprocessable_entity
27
27
  end
28
28
  end
29
29
  end
@@ -31,6 +31,10 @@ module Decidim
31
31
  def resource_content_block_cell
32
32
  "decidim/assemblies/content_block"
33
33
  end
34
+
35
+ def content_blocks_title
36
+ t("decidim.admin.menu.assemblies_submenu.landing_page")
37
+ end
34
38
  end
35
39
  end
36
40
  end
@@ -3,10 +3,10 @@
3
3
  module Decidim
4
4
  module Assemblies
5
5
  module Admin
6
- # A form object used to copy a assemblies from the admin
6
+ # A form object used to duplicate a assemblies from the admin
7
7
  # dashboard.
8
8
  #
9
- class AssemblyCopyForm < Form
9
+ class AssemblyDuplicateForm < Form
10
10
  include TranslatableAttributes
11
11
 
12
12
  translatable_attribute :title, String
@@ -14,8 +14,8 @@ module Decidim
14
14
  mimic :assembly
15
15
 
16
16
  attribute :slug, String
17
- attribute :copy_components, Boolean
18
- attribute :copy_landing_page_blocks, Boolean
17
+ attribute :duplicate_components, Boolean
18
+ attribute :duplicate_landing_page_blocks, Boolean
19
19
 
20
20
  validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
21
21
  validates :title, translatable_presence: true
@@ -36,7 +36,6 @@ module Decidim
36
36
  attribute :created_by, String
37
37
  attribute :facebook_handler, String
38
38
  attribute :github_handler, String
39
- attribute :hashtag, String
40
39
  attribute :instagram_handler, String
41
40
  attribute :slug, String
42
41
  attribute :twitter_handler, String
@@ -123,10 +123,6 @@ module Decidim
123
123
  published? && (!private_space? || (private_space? && is_transparent?))
124
124
  end
125
125
 
126
- def hashtag
127
- attributes["hashtag"].to_s.delete("#")
128
- end
129
-
130
126
  def to_param
131
127
  slug
132
128
  end
@@ -1,2 +1 @@
1
1
  import "src/decidim/assemblies/admin/assemblies"
2
- import "src/decidim/slug_form"
@@ -1,63 +1,4 @@
1
- $(() => {
2
- const $assemblyScopeEnabled = $("#assembly_scopes_enabled");
3
- const $assemblyScopeId = $("#assembly_scope_id");
1
+ import { definitionsFromContext } from "src/decidim/refactor/support/stimulus"
4
2
 
5
- if ($(".edit_assembly, .new_assembly").length > 0) {
6
- $assemblyScopeEnabled.on("change", (event) => {
7
- const checked = event.target.checked;
8
- $assemblyScopeId.attr("disabled", !checked);
9
- })
10
- $assemblyScopeId.attr("disabled", !$assemblyScopeEnabled.prop("checked"));
11
- }
12
-
13
- const $form = $(".assembly_form_admin");
14
-
15
- if ($form.length > 0) {
16
-
17
- const $privateSpace = $form.find("#private_space");
18
- const $isTransparent = $form.find("#is_transparent");
19
- const $specialFeatures = $form.find("#special_features");
20
-
21
-
22
- const toggleDisabledHiddenFields = () => {
23
- const enabledPrivateSpace = $privateSpace.find("input[type='checkbox']").prop("checked");
24
- $isTransparent.find("input[type='checkbox']").attr("disabled", "disabled");
25
- $specialFeatures.hide();
26
-
27
- if (enabledPrivateSpace) {
28
- $isTransparent.find("input[type='checkbox']").attr("disabled", !enabledPrivateSpace);
29
- $specialFeatures.show();
30
- }
31
- };
32
-
33
- $privateSpace.on("change", toggleDisabledHiddenFields);
34
- toggleDisabledHiddenFields();
35
-
36
- const $assemblyType = $form.find("#assembly_assembly_type");
37
- const $assemblyTypeOther = $form.find("#assembly_type_other");
38
-
39
- const $assemblyCreatedBy = $form.find("#assembly_created_by");
40
- const $assemblyCreatedByOther = $form.find("#created_by_other");
41
-
42
- const toggleDependsOnSelect = ($target, $showDiv) => {
43
- const value = $target.val();
44
- $showDiv.hide();
45
- if (value === "others") {
46
- $showDiv.show();
47
- }
48
- };
49
-
50
- $assemblyType.on("change", (ev) => {
51
- const $target = $(ev.target);
52
- toggleDependsOnSelect($target, $assemblyTypeOther);
53
- });
54
-
55
- $assemblyCreatedBy.on("change", (ev) => {
56
- const $target = $(ev.target);
57
- toggleDependsOnSelect($target, $assemblyCreatedByOther);
58
- });
59
-
60
- toggleDependsOnSelect($assemblyType, $assemblyTypeOther);
61
- toggleDependsOnSelect($assemblyCreatedBy, $assemblyCreatedByOther);
62
- }
63
- });
3
+ const context = require.context("../controllers", true, /controller\.js$/)
4
+ window.Stimulus.load(definitionsFromContext(context))