decidim-decidim_awesome 0.11.2 → 0.11.4

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +54 -2
  4. data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +5 -3
  5. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +0 -4
  6. data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +18 -3
  7. data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +2 -2
  8. data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +1 -1
  9. data/app/commands/concerns/decidim/decidim_awesome/system/register_organization_override.rb +29 -0
  10. data/app/commands/concerns/decidim/decidim_awesome/system/update_organization_override.rb +35 -0
  11. data/app/commands/concerns/decidim/decidim_awesome/update_account_override.rb +30 -0
  12. data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +3 -2
  13. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +6 -4
  14. data/app/controllers/concerns/decidim/decidim_awesome/check_login_authorizations.rb +60 -0
  15. data/app/controllers/concerns/decidim/decidim_awesome/needs_awesome_config.rb +0 -2
  16. data/app/controllers/concerns/decidim/decidim_awesome/proposals/memoize_extra_fields.rb +23 -0
  17. data/app/controllers/concerns/decidim/decidim_awesome/use_user_time_zone.rb +32 -0
  18. data/app/controllers/decidim/decidim_awesome/admin/admin_authorizations_controller.rb +122 -0
  19. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +1 -1
  20. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +7 -1
  21. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +5 -1
  22. data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +12 -4
  23. data/app/controllers/decidim/decidim_awesome/required_authorizations_controller.rb +58 -0
  24. data/app/forms/concerns/decidim/decidim_awesome/account_form_override.rb +25 -0
  25. data/app/forms/concerns/decidim/decidim_awesome/system/organization_form_override.rb +34 -0
  26. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +41 -8
  27. data/app/helpers/decidim/decidim_awesome/map_helper.rb +28 -26
  28. data/app/overrides/decidim/account/show/add_timezone_select.html.erb.deface +3 -0
  29. data/app/overrides/decidim/admin/officializations/index/add_modal.html.erb.deface +3 -0
  30. data/app/overrides/decidim/admin/officializations/index/add_td.html.erb.deface +5 -0
  31. data/app/overrides/decidim/admin/officializations/index/add_th.html.erb.deface +5 -0
  32. data/app/overrides/decidim/system/organizations/_advanced_settings/add_awesome_config.html.erb.deface +9 -0
  33. data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +1 -1
  34. data/app/overrides/layouts/decidim/admin/_header/add_awesome_custom_styles.html.erb.deface +3 -0
  35. data/app/overrides/layouts/decidim/admin/_header/add_awesome_tags.html.erb.deface +1 -0
  36. data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +0 -5
  37. data/app/packs/src/decidim/decidim_awesome/admin/verification_selects.js +21 -0
  38. data/app/packs/src/decidim/decidim_awesome/admin/verifications.js +43 -0
  39. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +1 -0
  40. data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +1 -0
  41. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +1 -1
  42. data/app/packs/stylesheets/decidim/decidim_awesome/admin/verifications.scss +99 -0
  43. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +1 -0
  44. data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +42 -11
  45. data/app/permissions/decidim/decidim_awesome/permissions.rb +7 -0
  46. data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +3 -5
  47. data/app/presenters/decidim/decidim_awesome/admin_log/user_presenter_override.rb +46 -0
  48. data/app/views/decidim/decidim_awesome/account/_timezone_select.html.erb +3 -0
  49. data/app/views/decidim/decidim_awesome/admin/admin_authorizations/authorization.html.erb +20 -0
  50. data/app/views/decidim/decidim_awesome/admin/admin_authorizations/callout.html.erb +3 -0
  51. data/app/views/decidim/decidim_awesome/admin/admin_authorizations/conflict.html.erb +5 -0
  52. data/app/views/decidim/decidim_awesome/admin/admin_authorizations/edit.html.erb +41 -0
  53. data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_admin_styles.html.erb +1 -0
  54. data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_styles.html.erb +48 -0
  55. data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +8 -0
  56. data/app/views/decidim/decidim_awesome/admin/config/_form_verifications.html.erb +15 -0
  57. data/app/views/decidim/decidim_awesome/admin/constraints/no_permissions.html.erb +6 -0
  58. data/app/views/decidim/decidim_awesome/admin/officializations/_participants_td.html.erb +25 -0
  59. data/app/views/decidim/decidim_awesome/admin/officializations/_participants_th.html.erb +1 -0
  60. data/app/views/decidim/decidim_awesome/admin/officializations/_verification_modal.html.erb +9 -0
  61. data/app/views/decidim/decidim_awesome/required_authorizations/index.html.erb +66 -0
  62. data/app/views/decidim/decidim_awesome/system/organizations/_admin_allowed_authorizations.html.erb +5 -0
  63. data/app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb +1 -1
  64. data/app/views/layouts/decidim/decidim_awesome/admin/_custom_styles.html.erb +3 -0
  65. data/app/views/layouts/decidim/decidim_awesome/admin/admin_authorizations.html.erb +7 -0
  66. data/config/i18n-tasks.yml +6 -0
  67. data/config/locales/ca.yml +91 -5
  68. data/config/locales/cs.yml +86 -0
  69. data/config/locales/de.yml +131 -0
  70. data/config/locales/en.yml +115 -1
  71. data/config/locales/es.yml +89 -3
  72. data/config/locales/eu.yml +607 -26
  73. data/config/locales/fr.yml +37 -1
  74. data/config/locales/it.yml +0 -1
  75. data/config/locales/ja.yml +86 -0
  76. data/config/locales/nl.yml +0 -1
  77. data/config/locales/pt-BR.yml +0 -1
  78. data/lib/decidim/decidim_awesome/admin_engine.rb +2 -0
  79. data/lib/decidim/decidim_awesome/authorizator.rb +34 -0
  80. data/lib/decidim/decidim_awesome/awesome.rb +55 -1
  81. data/lib/decidim/decidim_awesome/awesome_helpers.rb +48 -19
  82. data/lib/decidim/decidim_awesome/checksums.yml +9 -0
  83. data/lib/decidim/decidim_awesome/engine.rb +20 -4
  84. data/lib/decidim/decidim_awesome/menu.rb +45 -9
  85. data/lib/decidim/decidim_awesome/request_memoizer.rb +16 -0
  86. data/lib/decidim/decidim_awesome/test/factories.rb +0 -4
  87. data/lib/decidim/decidim_awesome/test/initializer.rb +4 -0
  88. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +1 -1
  89. data/lib/decidim/decidim_awesome/test/shared_examples/custom_styles_examples.rb +156 -0
  90. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +26 -10
  91. data/lib/decidim/decidim_awesome/version.rb +1 -1
  92. data/package.json +6 -5
  93. metadata +42 -4
  94. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +0 -30
@@ -15,6 +15,7 @@ module Decidim
15
15
  isolate_namespace Decidim::DecidimAwesome
16
16
 
17
17
  routes do
18
+ get :required_authorizations, to: "required_authorizations#index"
18
19
  post :editor_images, to: "editor_images#create"
19
20
  end
20
21
 
@@ -22,10 +23,6 @@ module Decidim
22
23
  # https://edgeguides.rubyonrails.org/engines.html#overriding-models-and-controllers
23
24
  # overrides
24
25
  config.to_prepare do
25
- # activate Decidim LayoutHelper for the overriden views
26
- ActiveSupport.on_load :action_controller do
27
- helper Decidim::LayoutHelper if respond_to?(:helper)
28
- end
29
26
  # Include additional helpers globally
30
27
  ActiveSupport.on_load(:action_view) { include Decidim::DecidimAwesome::AwesomeHelpers }
31
28
  # Also for cells
@@ -66,12 +63,24 @@ module Decidim
66
63
  Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::AddProposalTypeCustomFields)
67
64
  end
68
65
 
66
+ if DecidimAwesome.enabled?(:admins_available_authorizations)
67
+ Decidim::System::RegisterOrganizationForm.include(Decidim::DecidimAwesome::System::OrganizationFormOverride)
68
+ Decidim::System::UpdateOrganizationForm.include(Decidim::DecidimAwesome::System::OrganizationFormOverride)
69
+ Decidim::System::UpdateOrganization.include(Decidim::DecidimAwesome::System::UpdateOrganizationOverride)
70
+ Decidim::System::RegisterOrganization.include(Decidim::DecidimAwesome::System::RegisterOrganizationOverride)
71
+ end
72
+
69
73
  if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields, :weighted_proposal_voting)
70
74
  # add vote weight/private_body to proposals
71
75
  Decidim::Proposals::Proposal.include(Decidim::DecidimAwesome::HasProposalExtraFields)
72
76
  Decidim::Proposals::CollaborativeDraft.include(Decidim::DecidimAwesome::HasProposalExtraFields)
73
77
  end
74
78
 
79
+ if Decidim::DecidimAwesome.enabled?(:user_timezone)
80
+ Decidim::AccountForm.include(Decidim::DecidimAwesome::AccountFormOverride)
81
+ Decidim::UpdateAccount.include(Decidim::DecidimAwesome::UpdateAccountOverride)
82
+ end
83
+
75
84
  if DecidimAwesome.enabled?(:weighted_proposal_voting)
76
85
  # add vote weight to proposal vote
77
86
  Decidim::Proposals::ProposalVote.include(Decidim::DecidimAwesome::HasVoteWeight)
@@ -101,6 +110,9 @@ module Decidim
101
110
 
102
111
  initializer "decidim_decidim_awesome.overrides", after: "decidim.action_controller" do
103
112
  config.to_prepare do
113
+ Decidim::ApplicationController.include(Decidim::DecidimAwesome::CheckLoginAuthorizations) if DecidimAwesome.enabled?(:force_authorization_after_login)
114
+ Decidim::ApplicationController.include(Decidim::DecidimAwesome::UseUserTimeZone) if Decidim::DecidimAwesome.enabled?(:user_timezone)
115
+
104
116
  # Auto-insert some csp directives
105
117
  Decidim::ApplicationController.include(Decidim::DecidimAwesome::ContentSecurityPolicy)
106
118
  Decidim::Admin::ApplicationController.include(Decidim::DecidimAwesome::ContentSecurityPolicy)
@@ -119,9 +131,12 @@ module Decidim
119
131
  end
120
132
 
121
133
  if DecidimAwesome.enabled?(:weighted_proposal_voting)
134
+ Decidim::Proposals::ProposalsController.include(Decidim::DecidimAwesome::Proposals::MemoizeExtraFields)
122
135
  Decidim::Proposals::ProposalVotesController.include(Decidim::DecidimAwesome::Proposals::ProposalVotesControllerOverride)
123
136
  end
124
137
 
138
+ Decidim::AdminLog::UserPresenter.include(Decidim::DecidimAwesome::AdminLog::UserPresenterOverride) if DecidimAwesome.enabled?(:admins_available_authorizations)
139
+
125
140
  Decidim::AmendmentsController.include(Decidim::DecidimAwesome::LimitPendingAmendments) if DecidimAwesome.enabled?(:allow_limiting_amendments)
126
141
 
127
142
  Decidim::Proposals::ProposalsController.include(Decidim::DecidimAwesome::Proposals::OrderableOverride) if DecidimAwesome.enabled?(:additional_proposal_sortings)
@@ -274,6 +289,7 @@ module Decidim
274
289
  Decidim.icons.register(name: "line-chart-line", icon: "line-chart-line", category: "system", description: "", engine: :decidim_awesome)
275
290
  Decidim.icons.register(name: "spy", icon: "spy-fill", category: "system", description: "", engine: :decidim_awesome)
276
291
  Decidim.icons.register(name: "forbid-line", icon: "forbid-line", category: "system", description: "", engine: :decidim_awesome)
292
+ Decidim.icons.register(name: "file-settings-line", icon: "file-settings-line", category: "system", description: "", engine: :decidim_awesome)
277
293
  end
278
294
  end
279
295
  end
@@ -29,17 +29,20 @@ module Decidim
29
29
 
30
30
  menu.add_item :styles,
31
31
  I18n.t("menu.styles", scope: "decidim.decidim_awesome.admin"),
32
- decidim_admin_decidim_awesome.config_path(:styles),
32
+ decidim_admin_decidim_awesome.config_path(:scoped_styles),
33
33
  position: 4,
34
34
  icon_name: "brush",
35
- if: menus[:styles]
35
+ if: menus[:styles],
36
+ submenu: { target_menu: :custom_styles_submenu }
36
37
 
37
- menu.add_item :proposal_custom_fields,
38
+ menu.add_item :custom_fields,
38
39
  I18n.t("menu.proposal_custom_fields", scope: "decidim.decidim_awesome.admin"),
39
- decidim_admin_decidim_awesome.config_path(:proposal_custom_fields),
40
+ decidim_admin_decidim_awesome.config_path(menus[:proposal_custom_fields] ? :proposal_custom_fields : :proposal_private_custom_fields),
40
41
  position: 5,
41
42
  icon_name: "layers",
42
- if: menus[:proposal_custom_fields],
43
+ active: is_active_link?(decidim_admin_decidim_awesome.config_path(:proposal_custom_fields)) ||
44
+ is_active_link?(decidim_admin_decidim_awesome.config_path(:proposal_private_custom_fields)),
45
+ if: menus[:custom_fields],
43
46
  submenu: { target_menu: :custom_fields_submenu }
44
47
 
45
48
  menu.add_item :admins,
@@ -55,6 +58,8 @@ module Decidim
55
58
  position: 7,
56
59
  icon_name: "menu-line",
57
60
  if: menus[:menu_hacks],
61
+ active: is_active_link?(decidim_admin_decidim_awesome.menu_hacks_path(:menu)) ||
62
+ is_active_link?(decidim_admin_decidim_awesome.menu_hacks_path(:home_content_block_menu)),
58
63
  submenu: { target_menu: :menu_hacks_submenu }
59
64
 
60
65
  menu.add_item :custom_redirects,
@@ -71,11 +76,20 @@ module Decidim
71
76
  icon_name: "chat-1-line",
72
77
  if: menus[:livechat]
73
78
 
79
+ menu.add_item :verifications,
80
+ I18n.t("menu.verifications", scope: "decidim.decidim_awesome.admin"),
81
+ decidim_admin_decidim_awesome.config_path(:verifications),
82
+ position: 10,
83
+ icon_name: "fingerprint-line",
84
+ if: menus[:verifications]
85
+
74
86
  menu.add_item :maintenance,
75
87
  I18n.t("maintenance", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
76
88
  decidim_admin_decidim_awesome.maintenance_path(:private_data),
77
- position: 10,
89
+ position: 11,
78
90
  icon_name: "tools-line",
91
+ active: is_active_link?(decidim_admin_decidim_awesome.maintenance_path(:private_data)) ||
92
+ is_active_link?(decidim_admin_decidim_awesome.checks_maintenance_index_path),
79
93
  submenu: { target_menu: :maintenance_submenu }
80
94
  end
81
95
  end
@@ -98,6 +112,24 @@ module Decidim
98
112
  end
99
113
  end
100
114
 
115
+ def register_custom_styles_submenu!
116
+ Decidim.menu :custom_styles_submenu do |menu|
117
+ menu.add_item :scoped_styles,
118
+ I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.scoped_styles"),
119
+ decidim_admin_decidim_awesome.config_path(:scoped_styles),
120
+ position: 4.1,
121
+ icon_name: "computer-line",
122
+ if: config_enabled?(:scoped_styles)
123
+
124
+ menu.add_item :scoped_admin_styles,
125
+ I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.scoped_admin_styles"),
126
+ decidim_admin_decidim_awesome.config_path(:scoped_admin_styles),
127
+ position: 4.2,
128
+ icon_name: "file-settings-line",
129
+ if: config_enabled?(:scoped_admin_styles)
130
+ end
131
+ end
132
+
101
133
  def register_menu_hacks_submenu!
102
134
  Decidim.menu :menu_hacks_submenu do |menu|
103
135
  menu.add_item :main_menu,
@@ -142,8 +174,11 @@ module Decidim
142
174
  :validate_body_min_length, :validate_body_max_caps_percent,
143
175
  :validate_body_max_marks_together, :validate_body_start_with_caps
144
176
  ),
145
- surveys: config_enabled?(:auto_save_forms),
146
- styles: config_enabled?(:scoped_styles),
177
+ surveys: config_enabled?(:auto_save_forms, :user_timezone),
178
+ styles: config_enabled?(:scoped_styles, :scoped_admin_styles),
179
+ scoped_styles: config_enabled?(:scoped_styles),
180
+ scoped_admin_styles: config_enabled?(:scoped_admin_styles),
181
+ custom_fields: config_enabled?(:proposal_custom_fields, :proposal_private_custom_fields),
147
182
  proposal_custom_fields: config_enabled?(:proposal_custom_fields),
148
183
  proposal_private_custom_fields: config_enabled?(:proposal_private_custom_fields),
149
184
  admins: config_enabled?(:scoped_admins),
@@ -151,7 +186,8 @@ module Decidim
151
186
  menu_hacks_menu: config_enabled?(:menu),
152
187
  menu_hacks_home_content_block_menu: config_enabled?(:home_content_block_menu),
153
188
  custom_redirects: config_enabled?(:custom_redirects),
154
- livechat: config_enabled?(:intergram_for_admins, :intergram_for_public)
189
+ livechat: config_enabled?(:intergram_for_admins, :intergram_for_public),
190
+ verifications: config_enabled?(:force_authorization_after_login)
155
191
  }
156
192
  end
157
193
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module RequestMemoizer
6
+ # memoize a piece of code in the global request instead of the helper instance (helpers are initialized for each view)
7
+ def memoize(key)
8
+ if defined?(request) && request.env["decidim.current_organization"]&.id
9
+ request.env["decidim_awesome.#{key}"] ||= block_given? ? yield : nil
10
+ elsif block_given?
11
+ yield
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "decidim/core/test/factories"
4
- require "decidim/proposals/test/factories"
5
- require "decidim/surveys/test/factories"
6
-
7
3
  FactoryBot.define do
8
4
  factory :awesome_config, class: "Decidim::DecidimAwesome::AwesomeConfig" do
9
5
  var { Faker::Hacker.noun }
@@ -7,9 +7,13 @@ Decidim::DecidimAwesome.configure do |config|
7
7
  :allow_videos_in_editors,
8
8
  :allow_images_in_proposals,
9
9
  :auto_save_forms,
10
+ :user_timezone,
11
+ :force_authorization_after_login,
12
+ :admins_available_authorizations,
10
13
  :intergram_for_admins,
11
14
  :intergram_for_public,
12
15
  :scoped_styles,
16
+ :scoped_admin_styles,
13
17
  :proposal_custom_fields,
14
18
  :proposal_private_custom_fields,
15
19
  :menu,
@@ -40,7 +40,7 @@ shared_examples "forbids disabled feature without redirect" do
40
40
  it "fails with error" do
41
41
  action
42
42
 
43
- expect(response.body).to eq("no permissions for #{feature}")
43
+ expect(response.body).to have_content("No permissions for #{feature}")
44
44
  end
45
45
  end
46
46
 
@@ -0,0 +1,156 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "creates a new box" do |name|
4
+ it "saves the content in the hash" do
5
+ click_on "Add a new \"#{name}\" CSS box"
6
+
7
+ expect(page).to have_admin_callout("created successfully")
8
+
9
+ sleep 1
10
+ page.execute_script('document.querySelector(".CodeMirror").CodeMirror.setValue("body {background: red;}");')
11
+
12
+ click_on "Update configuration"
13
+
14
+ expect(page).to have_admin_callout("updated successfully")
15
+ expect(page).to have_content("body {background: red;}")
16
+ end
17
+ end
18
+
19
+ shared_examples "saves content" do |key|
20
+ it "updates succesfully" do
21
+ expect(page).to have_content("body {background: red;}")
22
+ expect(page).to have_content("body {background: blue;}")
23
+
24
+ sleep 1
25
+ page.execute_script("document.querySelector(\"[data-key=#{key}] .CodeMirror\").CodeMirror.setValue(\"body {background: green;}\");")
26
+ click_link_or_button "Update configuration"
27
+
28
+ expect(page).to have_admin_callout("updated successfully")
29
+ expect(page).not_to have_content("body {background: red;}")
30
+ expect(page).to have_content("body {background: green;}")
31
+ expect(page).to have_content("body {background: blue;}")
32
+ end
33
+
34
+ it "shows error message if invalid" do
35
+ sleep 1
36
+ page.execute_script("document.querySelector(\"[data-key=#{key}] .CodeMirror\").CodeMirror.setValue(\"I am invalid CSS\");")
37
+ click_link_or_button "Update configuration"
38
+
39
+ expect(page).to have_admin_callout("Error updating configuration!")
40
+ expect(page).not_to have_content("body {background: red;}")
41
+ expect(page).to have_content("body {background: blue;}")
42
+ expect(page).to have_content("I am invalid CSS")
43
+ end
44
+ end
45
+
46
+ shared_examples "updates new box" do
47
+ it "updates the content in the hash" do
48
+ expect(page).to have_content("body {background: red;}")
49
+ expect(page).to have_content("body {background: blue;}")
50
+ end
51
+ end
52
+
53
+ shared_examples "removes a box" do
54
+ let(:styles) do
55
+ {
56
+ "foo" => "body {background: red;}",
57
+ "bar" => "body {background: blue;}"
58
+ }
59
+ end
60
+
61
+ it "updates the content in the hash" do
62
+ expect(page).to have_content("body {background: red;}")
63
+ expect(page).to have_content("body {background: blue;}")
64
+
65
+ within ".scoped_styles_container[data-key=\"foo\"]" do
66
+ accept_confirm { click_link_or_button "Remove this CSS box" }
67
+ end
68
+
69
+ expect(page).to have_admin_callout("removed successfully")
70
+ expect(page).to have_content("body {background: blue;}")
71
+ expect(page).not_to have_content("body {background: red;}")
72
+ expect(Decidim::DecidimAwesome::AwesomeConfig.find_by(organization:, var: "#{var_name}_foo")).not_to be_present
73
+ expect(Decidim::DecidimAwesome::AwesomeConfig.find_by(organization:, var: "#{var_name}_bar")).to be_present
74
+ end
75
+ end
76
+
77
+ shared_examples "adds a constraint" do |name|
78
+ let(:styles) do
79
+ {
80
+ "foo" => "body {background: red;}",
81
+ "bar" => "body {background: blue;}"
82
+ }
83
+ end
84
+
85
+ it "adds a new config helper var" do
86
+ click_on "Add a new \"#{name}\" CSS box"
87
+
88
+ expect(page).to have_content("Processes")
89
+
90
+ expect(Decidim::DecidimAwesome::AwesomeConfig.find_by(organization:, var: "#{var_name}_bar")).to be_present
91
+ expect(Decidim::DecidimAwesome::AwesomeConfig.find_by(organization:,
92
+ var: "#{var_name}_bar").constraints.first.settings).to eq("participatory_space_manifest" => "participatory_processes")
93
+ end
94
+ end
95
+
96
+ shared_examples "removes a constraint" do
97
+ let(:styles) do
98
+ {
99
+ "foo" => "body {background: red;}",
100
+ "bar" => "body {background: blue;}"
101
+ }
102
+ end
103
+
104
+ before do
105
+ visit decidim_admin_decidim_awesome.config_path("#{var_name}s")
106
+ click_on "Add case", id: "new-#{var_name}_bar"
107
+ end
108
+
109
+ it "removes the helper config var" do
110
+ within "#constraint-form-" do
111
+ select "Processes", from: "Apply to participatory spaces of type"
112
+ end
113
+ click_on "Save"
114
+
115
+ within ".scoped_styles_container[data-key=\"bar\"] .constraints-editor" do
116
+ expect(page).to have_content("Processes")
117
+ end
118
+
119
+ within ".scoped_styles_container[data-key=\"bar\"] .constraints-editor" do
120
+ click_on "Delete"
121
+ end
122
+
123
+ within ".scoped_styles_container[data-key=\"bar\"] .constraints-editor" do
124
+ expect(page).not_to have_content("Processes")
125
+ end
126
+
127
+ visit decidim_admin_decidim_awesome.config_path("#{var_name}s")
128
+
129
+ within ".scoped_styles_container[data-key=\"bar\"] .constraints-editor" do
130
+ expect(page).not_to have_content("Processes")
131
+ end
132
+
133
+ expect(Decidim::DecidimAwesome::AwesomeConfig.find_by(organization:, var: "#{var_name}_bar")).to be_present
134
+ expect(Decidim::DecidimAwesome::AwesomeConfig.find_by(organization:, var: "#{var_name}_bar").constraints).not_to be_present
135
+ end
136
+ end
137
+
138
+ shared_examples "extra css is added" do
139
+ it "css is present" do
140
+ expect(page.body).to have_content("body {background: red;}")
141
+ end
142
+
143
+ it "css is applied" do
144
+ expect(page.execute_script("return window.getComputedStyle($('body')[0]).backgroundColor")).to eq("rgb(255, 0, 0)")
145
+ end
146
+ end
147
+
148
+ shared_examples "no extra css is added" do
149
+ it "css is no present" do
150
+ expect(page.body).not_to have_content("body {background: red;}")
151
+ end
152
+
153
+ it "css is not applyied" do
154
+ expect(page.execute_script("return window.getComputedStyle($('body')[0]).backgroundColor")).to eq(default_background_color)
155
+ end
156
+ end
@@ -56,6 +56,15 @@ shared_examples "activated concerns" do |enabled|
56
56
  expect(Decidim::AmendmentsController.included_modules).to include(Decidim::DecidimAwesome::LimitPendingAmendments)
57
57
  expect(Decidim::Proposals::ProposalsController.included_modules).to include(Decidim::DecidimAwesome::Proposals::OrderableOverride)
58
58
  expect(Decidim::AdminLog::ComponentPresenter.included_modules).to include(Decidim::DecidimAwesome::AdminLog::ComponentPresenterOverride)
59
+ expect(Decidim::ApplicationController.included_modules).to include(Decidim::DecidimAwesome::CheckLoginAuthorizations)
60
+ expect(Decidim::ApplicationController.included_modules).to include(Decidim::DecidimAwesome::UseUserTimeZone)
61
+ expect(Decidim::AccountForm.included_modules).to include(Decidim::DecidimAwesome::AccountFormOverride)
62
+ expect(Decidim::UpdateAccount.included_modules).to include(Decidim::DecidimAwesome::UpdateAccountOverride)
63
+ expect(Decidim::System::RegisterOrganizationForm.included_modules).to include(Decidim::DecidimAwesome::System::OrganizationFormOverride)
64
+ expect(Decidim::System::UpdateOrganizationForm.included_modules).to include(Decidim::DecidimAwesome::System::OrganizationFormOverride)
65
+ expect(Decidim::System::UpdateOrganization.included_modules).to include(Decidim::DecidimAwesome::System::UpdateOrganizationOverride)
66
+ expect(Decidim::System::RegisterOrganization.included_modules).to include(Decidim::DecidimAwesome::System::RegisterOrganizationOverride)
67
+ expect(Decidim::AdminLog::UserPresenter.included_modules).to include(Decidim::DecidimAwesome::AdminLog::UserPresenterOverride)
59
68
  end
60
69
 
61
70
  else
@@ -84,6 +93,16 @@ shared_examples "activated concerns" do |enabled|
84
93
  expect(Decidim::AmendmentsController.included_modules).not_to include(Decidim::DecidimAwesome::LimitPendingAmendments)
85
94
  expect(Decidim::Proposals::ProposalsController.included_modules).not_to include(Decidim::DecidimAwesome::Proposals::OrderableOverride)
86
95
  expect(Decidim::AdminLog::ComponentPresenter.included_modules).not_to include(Decidim::DecidimAwesome::AdminLog::ComponentPresenterOverride)
96
+ expect(Decidim::ApplicationController.included_modules).not_to include(Decidim::DecidimAwesome::CheckLoginAuthorizations)
97
+ expect(Decidim::ApplicationController.included_modules).not_to include(Decidim::DecidimAwesome::UseUserTimeZone)
98
+ expect(Decidim::AccountForm.included_modules).not_to include(Decidim::DecidimAwesome::AccountFormOverride)
99
+ expect(Decidim::UpdateAccount.included_modules).not_to include(Decidim::DecidimAwesome::UpdateAccountOverride)
100
+ expect(Decidim::System::RegisterOrganizationForm.included_modules).not_to include(Decidim::DecidimAwesome::System::OrganizationFormOverride)
101
+ expect(Decidim::System::UpdateOrganizationForm.included_modules).not_to include(Decidim::DecidimAwesome::System::OrganizationFormOverride)
102
+ expect(Decidim::System::UpdateOrganization.included_modules).not_to include(Decidim::DecidimAwesome::System::UpdateOrganizationOverride)
103
+ expect(Decidim::DecidimAwesome::AwesomeHelpers.included_modules).not_to include(Decidim::DecidimAwesome::AwesomeHelpers)
104
+ expect(Decidim::DecidimAwesome::ContentSecurityPolicy.included_modules).not_to include(Decidim::DecidimAwesome::ContentSecurityPolicy)
105
+ expect(Decidim::DecidimAwesome::UserOverride.included_modules).not_to include(Decidim::DecidimAwesome::UserOverride)
87
106
  end
88
107
  end
89
108
  end
@@ -155,15 +174,12 @@ end
155
174
 
156
175
  shared_examples "basic rendering" do |enabled|
157
176
  describe "shows public pages", type: :system do
158
- let(:image_vars) do
177
+ let(:boolean_vars) do
159
178
  [
160
179
  :allow_images_in_proposals,
161
180
  :allow_videos_in_editors,
162
181
  :allow_images_in_editors,
163
- :allow_images_in_proposals,
164
- :auto_save_forms,
165
- :intergram_for_admins,
166
- :intergram_for_public
182
+ :auto_save_forms
167
183
  ]
168
184
  end
169
185
 
@@ -186,8 +202,8 @@ shared_examples "basic rendering" do |enabled|
186
202
  end
187
203
 
188
204
  if enabled
189
- it "has editor images configs enabled" do
190
- image_vars.each do |var|
205
+ it "has boolean configs enabled" do
206
+ boolean_vars.each do |var|
191
207
  expect(page.body).to have_content("\"#{var}\":true")
192
208
  end
193
209
  end
@@ -200,8 +216,8 @@ shared_examples "basic rendering" do |enabled|
200
216
  expect(page.body).to have_content(styles)
201
217
  end
202
218
  else
203
- it "has editor images configs disabled" do
204
- image_vars.each do |var|
219
+ it "has boolean configs disabled" do
220
+ boolean_vars.each do |var|
205
221
  expect(page.body).to have_content("\"#{var}\":false")
206
222
  end
207
223
  end
@@ -222,7 +238,7 @@ shared_examples "basic rendering" do |enabled|
222
238
  "config/editors",
223
239
  "config/proposals",
224
240
  "config/surveys",
225
- "config/styles",
241
+ "config/scoped_styles",
226
242
  "config/proposal_custom_fields",
227
243
  "config/admins",
228
244
  "menus/menu/hacks",
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  # This holds the decidim-decidim_awesome version.
5
5
  module DecidimAwesome
6
- VERSION = "0.11.2"
6
+ VERSION = "0.11.4"
7
7
  COMPAT_DECIDIM_VERSION = [">= 0.28.0", "< 0.29"].freeze
8
8
  end
9
9
  end
data/package.json CHANGED
@@ -40,12 +40,13 @@
40
40
  "@babel/plugin-transform-runtime": "^7.23.9",
41
41
  "@babel/preset-env": "^7.23.9",
42
42
  "@babel/preset-react": "^7.23.3",
43
- "@decidim/dev": "0.28.0",
44
- "@decidim/eslint-config": "0.28.0",
45
- "@decidim/prettier-config": "0.28.0",
46
- "@decidim/stylelint-config": "0.28.0",
43
+ "@decidim/dev": "0.28.4",
44
+ "@decidim/eslint-config": "0.28.4",
45
+ "@decidim/prettier-config": "0.28.4",
46
+ "@decidim/stylelint-config": "0.28.4",
47
47
  "postcss-scss": "^4.0.9",
48
- "sass-embedded": "~1.57.1"
48
+ "sass-embedded": "~1.57.1",
49
+ "@tarekraafat/autocomplete.js": "10.2.7"
49
50
  },
50
51
  "dependencies": {
51
52
  "@rails/actioncable": "^6.1.7-6",