decidim-toggle 0.1.3 → 0.1.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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +10 -8
- data/.rspec +1 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -1
- data/CONTRIBUTING.md +2 -1
- data/Gemfile +13 -10
- data/Gemfile.lock +502 -388
- data/README.md +3 -1
- data/Rakefile +56 -5
- data/app/forms/decidim/toggle/update_authorizations_form.rb +116 -11
- data/app/forms/decidim/toggle/update_file_upload_settings_form.rb +1 -1
- data/app/forms/decidim/toggle/update_locale_form.rb +5 -1
- data/app/forms/decidim/toggle/update_name_form.rb +6 -2
- data/app/forms/decidim/toggle/update_security_form.rb +2 -2
- data/app/helpers/decidim/toggle/system_settings_tab_helper.rb +8 -7
- data/app/packs/src/decidim/toggle/organization_settings_tabs.js +31 -0
- data/app/packs/stylesheets/decidim/toggle/organization_settings.scss +47 -7
- data/app/views/decidim_toggle/system/organizations/_default_form_tab.html.erb +1 -2
- data/app/views/decidim_toggle/system/organizations/_encryption_not_configured_callout.html.erb +1 -0
- data/app/views/decidim_toggle/system/organizations/_settings_tab_active_tab_field.html.erb +1 -0
- data/app/views/decidim_toggle/system/organizations/_settings_tab_submit.html.erb +1 -0
- data/app/views/decidim_toggle/system/organizations/_settings_tabs.html.erb +2 -2
- data/app/views/decidim_toggle/system/organizations/tabs/_authorizations_tab.html.erb +27 -3
- data/app/views/decidim_toggle/system/organizations/tabs/_emails_tab.html.erb +1 -2
- data/app/views/decidim_toggle/system/organizations/tabs/_file_upload_tab.html.erb +1 -2
- data/app/views/decidim_toggle/system/organizations/tabs/_language_tab.html.erb +4 -7
- data/app/views/decidim_toggle/system/organizations/tabs/_omniauth_tab.html.erb +1 -2
- data/app/views/decidim_toggle/system/organizations/tabs/_security_tab.html.erb +1 -3
- data/app/views/layouts/decidim/toggle/_javascript_config.html.erb +1 -0
- data/bin/check +2 -2
- data/bin/ci-setup +24 -0
- data/config/assets.rb +5 -2
- data/config/locales/decidim_toggle_en.yml +5 -0
- data/decidim-toggle.gemspec +1 -1
- data/docker-compose.ci.yml +46 -0
- data/docker-compose.yml +11 -7
- data/lib/decidim/toggle/authorization_workflows.rb +33 -0
- data/lib/decidim/toggle/engine.rb +1 -1
- data/lib/decidim/toggle/field_conditions.rb +35 -0
- data/lib/decidim/toggle/javascript_config.rb +1 -1
- data/lib/decidim/toggle/organization_settings_tabs.rb +5 -6
- data/lib/decidim/toggle/settings_form_builder.rb +126 -22
- data/lib/decidim/toggle/settings_tab_registry.rb +1 -1
- data/lib/decidim/toggle/settings_tabs.rb +4 -5
- data/lib/decidim/toggle/tab_form.rb +1 -0
- data/lib/decidim/toggle/version.rb +1 -1
- data/lib/decidim/toggle.rb +17 -0
- data/package.json +2 -2
- data/spec/commands/decidim/toggle/update_authorizations_command_spec.rb +28 -0
- data/spec/commands/decidim/toggle/update_emails_command_spec.rb +1 -17
- data/spec/commands/decidim/toggle/update_omniauth_command_spec.rb +1 -17
- data/spec/forms/decidim/toggle/update_authorizations_form_spec.rb +87 -0
- data/spec/forms/decidim/toggle/update_omniauth_form_spec.rb +3 -3
- data/spec/lib/decidim/toggle/settings_form_builder_spec.rb +114 -18
- data/spec/requests/decidim_toggle/system/settings_tab_spec.rb +54 -0
- data/website/docs/developer/contribute.md +2 -1
- data/website/docs/developer/view-customization.md +1 -1
- data/website/docs/index.md +1 -1
- data/website/docs/integrate/attributes.md +65 -4
- data/website/docs/integrate/quickstart.md +2 -0
- data/yarn.lock +4 -4
- metadata +8 -4
- /data/{.erb-lint.yml → .erb_lint.yml} +0 -0
data/README.md
CHANGED
|
@@ -53,6 +53,8 @@ end
|
|
|
53
53
|
|
|
54
54
|
3. **Read** — `Decidim::Toggle.config_for(organization, :my_module)`.
|
|
55
55
|
|
|
56
|
+
To filter System authorization workflows from another gem, use `Decidim::Toggle.filter_authorization_workflows` — do not prepend `UpdateAuthorizationsForm`.
|
|
57
|
+
|
|
56
58
|
Optional view partial: `form_layout_partial:` on `add_tab` — see [Customize views](https://octree-gva.github.io/decidim-toggle/integrate/customize-views).
|
|
57
59
|
|
|
58
60
|
Full walkthrough: [Add a settings tab](https://octree-gva.github.io/decidim-toggle/integrate/quickstart).
|
|
@@ -75,7 +77,7 @@ rails db:migrate
|
|
|
75
77
|
|
|
76
78
|
## Development (this gem)
|
|
77
79
|
|
|
78
|
-
Docker + `./bin/check` (RuboCop,
|
|
80
|
+
Docker + `./bin/check` (RuboCop, erb_lint, RSpec) — see [CONTRIBUTING.md](CONTRIBUTING.md) and [Contribute](https://octree-gva.github.io/decidim-toggle/contributing).
|
|
79
81
|
|
|
80
82
|
## Support
|
|
81
83
|
|
data/Rakefile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "decidim/dev/common_rake"
|
|
4
|
+
require "yaml"
|
|
4
5
|
|
|
5
|
-
def
|
|
6
|
+
def install_module(path)
|
|
6
7
|
Dir.chdir(path) do
|
|
7
|
-
system("bundle exec rails
|
|
8
|
-
system("bundle exec rake db:migrate")
|
|
8
|
+
system("bundle exec rails decidim_toggle:install:migrations")
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -15,8 +15,59 @@ def seed_db(path)
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
desc "Prepare for testing"
|
|
19
|
+
task :prepare_tests do
|
|
20
|
+
# Remove previous existing db, and recreate one.
|
|
21
|
+
disable_docker_compose = ENV.fetch("DISABLED_DOCKER_COMPOSE", "false") == "true"
|
|
22
|
+
unless disable_docker_compose
|
|
23
|
+
system("docker-compose -f docker-compose.yml down -v --remove-orphans")
|
|
24
|
+
system("docker-compose -f docker-compose.yml up -d ")
|
|
25
|
+
end
|
|
26
|
+
ENV["RAILS_ENV"] = "development"
|
|
27
|
+
common_db_config = {
|
|
28
|
+
"adapter" => "postgresql",
|
|
29
|
+
"encoding" => "unicode",
|
|
30
|
+
"host" => ENV.fetch("DATABASE_HOST", "toggledb"),
|
|
31
|
+
"port" => ENV.fetch("DATABASE_PORT", "5432").to_i,
|
|
32
|
+
"username" => ENV.fetch("DATABASE_USERNAME", "decidim"),
|
|
33
|
+
"password" => ENV.fetch("DATABASE_PASSWORD", "pleaseChangeMe"),
|
|
34
|
+
"database" => "#{base_app_name}_test_app"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
database_yml = {
|
|
38
|
+
"test" => common_db_config,
|
|
39
|
+
"development" => common_db_config
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
config_file = File.expand_path("spec/decidim_dummy_app/config/database.yml", __dir__)
|
|
43
|
+
File.open(config_file, "w") { |f| YAML.dump(database_yml, f) }
|
|
44
|
+
Dir.chdir("spec/decidim_dummy_app") do
|
|
45
|
+
system("bundle exec rails db:drop")
|
|
46
|
+
system("bundle exec rails db:create")
|
|
47
|
+
system("bundle exec rails db:migrate")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
18
51
|
desc "Generates a dummy app for testing"
|
|
19
|
-
task test_app
|
|
52
|
+
task :test_app do
|
|
53
|
+
Bundler.with_original_env do
|
|
54
|
+
generate_decidim_app(
|
|
55
|
+
"spec/decidim_dummy_app",
|
|
56
|
+
"--app_name",
|
|
57
|
+
"#{base_app_name}_test_app",
|
|
58
|
+
"--path",
|
|
59
|
+
"../..",
|
|
60
|
+
"--skip_spring",
|
|
61
|
+
"--demo",
|
|
62
|
+
"--force_ssl",
|
|
63
|
+
"false",
|
|
64
|
+
"--locales",
|
|
65
|
+
"en,fr,es"
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
install_module("spec/decidim_dummy_app")
|
|
69
|
+
Rake::Task["prepare_tests"].invoke
|
|
70
|
+
end
|
|
20
71
|
|
|
21
72
|
desc "Generates a development app."
|
|
22
73
|
task :development_app do
|
|
@@ -33,6 +84,6 @@ task :development_app do
|
|
|
33
84
|
"en,ca,es,fr"
|
|
34
85
|
)
|
|
35
86
|
end
|
|
36
|
-
|
|
87
|
+
install_module("development_app")
|
|
37
88
|
seed_db("development_app")
|
|
38
89
|
end
|
|
@@ -2,22 +2,77 @@
|
|
|
2
2
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Toggle
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
5
|
+
# Persists organization verification workflows.
|
|
6
|
+
#
|
|
7
|
+
# Vanilla Decidim: +available_authorizations+ is a string array of workflow names.
|
|
8
|
+
# With +decidim-ephemeral_participation+, persist a Hash with
|
|
9
|
+
# +allow_ephemeral_participation+ (that gem's jsonb column).
|
|
8
10
|
class UpdateAuthorizationsForm < Decidim::Form
|
|
9
11
|
mimic :organization
|
|
10
12
|
|
|
11
13
|
attribute :available_authorizations, [String]
|
|
14
|
+
attribute :ephemeral_participation_authorization, String
|
|
12
15
|
|
|
13
16
|
validate :available_authorizations_subset_of_workflows
|
|
17
|
+
validate :ephemeral_authorization_among_enabled
|
|
18
|
+
|
|
19
|
+
def self.ephemeral_mode?
|
|
20
|
+
Decidim::Toggle.ephemeral_participation?
|
|
21
|
+
end
|
|
14
22
|
|
|
15
23
|
def self.from_model(organization)
|
|
16
|
-
|
|
24
|
+
form = if Decidim::Toggle.ephemeral_participation?
|
|
25
|
+
from_model_ephemeral(organization)
|
|
26
|
+
else
|
|
27
|
+
from_model_vanilla(organization)
|
|
28
|
+
end
|
|
29
|
+
form.with_context(current_organization: organization)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.ephemerable_workflow?(workflow)
|
|
33
|
+
workflow.respond_to?(:ephemerable) && workflow.ephemerable
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.from_model_vanilla(organization)
|
|
37
|
+
from_params(
|
|
38
|
+
organization: {
|
|
39
|
+
available_authorizations: Array(organization.available_authorizations).map(&:to_s)
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.from_model_ephemeral(organization)
|
|
45
|
+
hash = normalize_hash(organization.read_attribute(:available_authorizations))
|
|
46
|
+
from_params(
|
|
47
|
+
organization: {
|
|
48
|
+
available_authorizations: hash.keys.map(&:to_s),
|
|
49
|
+
ephemeral_participation_authorization: ephemeral_name_from(hash)
|
|
50
|
+
}
|
|
51
|
+
)
|
|
17
52
|
end
|
|
18
53
|
|
|
19
54
|
def self.collection_for_available_authorizations
|
|
20
|
-
Decidim.authorization_workflows.map { |
|
|
55
|
+
Decidim.authorization_workflows.map { |workflow| [workflow.name, workflow.description] }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.collection_for_ephemeral_participation_authorization
|
|
59
|
+
return [] unless Decidim::Toggle.ephemeral_participation?
|
|
60
|
+
|
|
61
|
+
Decidim.authorization_workflows.filter_map do |workflow|
|
|
62
|
+
next unless ephemerable_workflow?(workflow)
|
|
63
|
+
|
|
64
|
+
[workflow.name, workflow.description]
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def collection_for_available_authorizations
|
|
69
|
+
workflow_pairs(Decidim::Toggle.authorization_workflows_for(current_organization))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def collection_for_ephemeral_participation_authorization
|
|
73
|
+
return [] unless self.class.ephemeral_mode?
|
|
74
|
+
|
|
75
|
+
workflow_pairs(ephemerable_workflows)
|
|
21
76
|
end
|
|
22
77
|
|
|
23
78
|
def self.from_params(params, additional_params = {})
|
|
@@ -27,28 +82,78 @@ module Decidim
|
|
|
27
82
|
params = params.dup
|
|
28
83
|
params[:organization] = (params[:organization] || {}).merge(available_authorizations: [])
|
|
29
84
|
end
|
|
30
|
-
super
|
|
85
|
+
super
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def self.normalize_hash(raw)
|
|
89
|
+
case raw
|
|
90
|
+
when Hash then stringify_hash(raw)
|
|
91
|
+
when Array then raw.index_with { |_name| { "allow_ephemeral_participation" => false } }
|
|
92
|
+
else {}
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.stringify_hash(raw)
|
|
97
|
+
raw.each_with_object({}) do |(name, value), memo|
|
|
98
|
+
memo[name.to_s] = value.is_a?(Hash) ? value.stringify_keys : {}
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.ephemeral_name_from(hash)
|
|
103
|
+
hash.find { |_name, options| options["allow_ephemeral_participation"] == true }&.first
|
|
31
104
|
end
|
|
32
105
|
|
|
33
106
|
def clean_available_authorizations
|
|
34
|
-
@clean_available_authorizations ||= if
|
|
35
|
-
|
|
107
|
+
@clean_available_authorizations ||= if self.class.ephemeral_mode?
|
|
108
|
+
clean_ephemeral_hash
|
|
36
109
|
else
|
|
37
|
-
|
|
110
|
+
clean_vanilla_array
|
|
38
111
|
end
|
|
39
112
|
end
|
|
40
113
|
|
|
41
114
|
private
|
|
42
115
|
|
|
116
|
+
def workflow_pairs(workflows)
|
|
117
|
+
workflows.map { |workflow| [workflow.name, workflow.description] }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def ephemerable_workflows
|
|
121
|
+
Decidim::Toggle.authorization_workflows_for(current_organization).select do |workflow|
|
|
122
|
+
self.class.ephemerable_workflow?(workflow)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def clean_vanilla_array
|
|
127
|
+
return [] if available_authorizations.blank?
|
|
128
|
+
|
|
129
|
+
available_authorizations.map(&:to_s).compact_blank
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def clean_ephemeral_hash
|
|
133
|
+
selected = ephemeral_participation_authorization.to_s
|
|
134
|
+
clean_vanilla_array.index_with do |name|
|
|
135
|
+
{ "allow_ephemeral_participation" => name == selected }
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
43
139
|
def available_authorizations_subset_of_workflows
|
|
44
|
-
|
|
140
|
+
names = clean_vanilla_array
|
|
141
|
+
return if names.blank?
|
|
45
142
|
|
|
46
143
|
allowed = Decidim.authorization_workflows.to_set(&:name)
|
|
47
|
-
invalid =
|
|
144
|
+
invalid = names.reject { |name| allowed.include?(name) }
|
|
48
145
|
return if invalid.empty?
|
|
49
146
|
|
|
50
147
|
errors.add(:available_authorizations, :invalid)
|
|
51
148
|
end
|
|
149
|
+
|
|
150
|
+
def ephemeral_authorization_among_enabled
|
|
151
|
+
return unless Decidim::Toggle.ephemeral_participation?
|
|
152
|
+
return if ephemeral_participation_authorization.blank?
|
|
153
|
+
return if clean_vanilla_array.include?(ephemeral_participation_authorization.to_s)
|
|
154
|
+
|
|
155
|
+
errors.add(:ephemeral_participation_authorization, :invalid)
|
|
156
|
+
end
|
|
52
157
|
end
|
|
53
158
|
end
|
|
54
159
|
end
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Toggle
|
|
5
5
|
class UpdateLocaleForm < Decidim::Form
|
|
6
|
+
include FieldConditions
|
|
7
|
+
|
|
6
8
|
mimic :organization
|
|
7
9
|
|
|
8
10
|
attribute :available_locales, Array
|
|
@@ -10,6 +12,8 @@ module Decidim
|
|
|
10
12
|
attribute :enable_machine_translations, Boolean
|
|
11
13
|
attribute :machine_translation_display_priority, String
|
|
12
14
|
|
|
15
|
+
disable :machine_translation_display_priority, if_unchecked: :enable_machine_translations
|
|
16
|
+
|
|
13
17
|
# Decidim::Form delegates :available_locales to current_organization; this form is often
|
|
14
18
|
# built without context (e.g. system settings tabs), so prefer the attribute value.
|
|
15
19
|
def available_locales
|
|
@@ -75,7 +79,7 @@ module Decidim
|
|
|
75
79
|
params = params.dup
|
|
76
80
|
params[:organization] = (params[:organization] || {}).merge(available_locales: attrs[:available_locales].keys.compact_blank)
|
|
77
81
|
end
|
|
78
|
-
super
|
|
82
|
+
super
|
|
79
83
|
end
|
|
80
84
|
|
|
81
85
|
def clean_available_locales
|
|
@@ -13,6 +13,10 @@ module Decidim
|
|
|
13
13
|
attribute :host, String
|
|
14
14
|
attribute :secondary_hosts, String
|
|
15
15
|
|
|
16
|
+
def self.cols_for_secondary_hosts
|
|
17
|
+
55
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
validates :host, presence: true
|
|
17
21
|
validate :validate_name_presence
|
|
18
22
|
|
|
@@ -41,13 +45,13 @@ module Decidim
|
|
|
41
45
|
params = params.dup
|
|
42
46
|
params[:organization] = (params[:organization] || {}).merge(name: name_hash)
|
|
43
47
|
end
|
|
44
|
-
super
|
|
48
|
+
super
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
def clean_secondary_hosts
|
|
48
52
|
return [] if secondary_hosts.blank?
|
|
49
53
|
|
|
50
|
-
secondary_hosts.split("\n").map(&:chomp).
|
|
54
|
+
secondary_hosts.split("\n").map(&:chomp).compact_blank
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
private
|
|
@@ -39,10 +39,10 @@ module Decidim
|
|
|
39
39
|
def self.from_params(params, additional_params = {})
|
|
40
40
|
params = params.to_h.with_indifferent_access if params.respond_to?(:to_h)
|
|
41
41
|
params[:organization] || params
|
|
42
|
-
super
|
|
42
|
+
super
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def self.
|
|
45
|
+
def self.select_for_users_registration_mode
|
|
46
46
|
Decidim::Organization.users_registration_modes.map do |mode|
|
|
47
47
|
[mode.first, I18n.t("decidim.system.organizations.users_registration_mode.#{mode.first}", default: mode.first)]
|
|
48
48
|
end
|
|
@@ -25,15 +25,16 @@ module Decidim
|
|
|
25
25
|
prefixed.sub(%r{\A/decidim_toggle/decidim_toggle}, "/decidim_toggle")
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def decidim_toggle_settings_tab_form(organization, tab, &
|
|
28
|
+
def decidim_toggle_settings_tab_form(organization, tab, &)
|
|
29
29
|
tab_form = tab.form_class.from_model(organization)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
stored[
|
|
30
|
+
tab_form = tab_form.with_context(current_organization: organization) if tab_form.respond_to?(:with_context)
|
|
31
|
+
if (stored = flash["decidim_toggle_invalid_settings_tab"]) &&
|
|
32
|
+
stored["organization_id"].to_i == organization.id &&
|
|
33
|
+
stored["tab_id"].to_s == tab.identifier.to_s
|
|
33
34
|
flash.delete(:decidim_toggle_invalid_settings_tab)
|
|
34
|
-
tab_form = tab.form_class.from_params(organization: stored[
|
|
35
|
+
tab_form = tab.form_class.from_params(organization: stored["params"])
|
|
35
36
|
tab_form = tab_form.with_context(current_organization: organization) if tab_form.respond_to?(:with_context)
|
|
36
|
-
stored[
|
|
37
|
+
stored["errors"].each do |attribute, messages|
|
|
37
38
|
messages.each { |message| tab_form.errors.add(attribute, message) }
|
|
38
39
|
end
|
|
39
40
|
end
|
|
@@ -49,7 +50,7 @@ module Decidim
|
|
|
49
50
|
safe_join([
|
|
50
51
|
render("decidim_toggle/system/organizations/settings_tab_active_tab_field", tab:),
|
|
51
52
|
tf.informative_callouts,
|
|
52
|
-
content_tag(:div, class: "form__wrapper") { capture(tf, &
|
|
53
|
+
content_tag(:div, class: "form__wrapper") { capture(tf, &) },
|
|
53
54
|
render("decidim_toggle/system/organizations/settings_tab_submit", form: tf)
|
|
54
55
|
])
|
|
55
56
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Self-contained settings tabs (no Decidim accordion).
|
|
3
3
|
* Keeps tab selection in the URL hash (#panel-toggle-<id>) so it survives save redirects.
|
|
4
|
+
* Also syncs disable-if-unchecked field conditions declared on tab forms.
|
|
4
5
|
*/
|
|
5
6
|
const CONTAINER_SELECTOR = ".js-decidim-toggle-settings-tabs";
|
|
6
7
|
const PANEL_PREFIX = "panel-toggle-";
|
|
@@ -83,10 +84,40 @@ function syncHash(panelId) {
|
|
|
83
84
|
window.history.replaceState(null, "", url);
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
function syncDisableCondition(field) {
|
|
88
|
+
const controllerId = field.dataset.disabledIfUnchecked;
|
|
89
|
+
if (!controllerId) return;
|
|
90
|
+
|
|
91
|
+
const controller = document.getElementById(controllerId);
|
|
92
|
+
if (!controller) return;
|
|
93
|
+
|
|
94
|
+
const disabled = !controller.checked;
|
|
95
|
+
field.classList.toggle("is-disabled", disabled);
|
|
96
|
+
field.querySelectorAll("input, select, textarea, button").forEach((el) => {
|
|
97
|
+
el.disabled = disabled;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function initDisableConditions(container) {
|
|
102
|
+
container
|
|
103
|
+
.querySelectorAll("[data-disabled-if-unchecked]")
|
|
104
|
+
.forEach((field) => {
|
|
105
|
+
const controllerId = field.dataset.disabledIfUnchecked;
|
|
106
|
+
const controller = document.getElementById(controllerId);
|
|
107
|
+
if (!controller) return;
|
|
108
|
+
|
|
109
|
+
const sync = () => syncDisableCondition(field);
|
|
110
|
+
controller.addEventListener("change", sync);
|
|
111
|
+
sync();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
86
115
|
function initContainer(container) {
|
|
87
116
|
const trigger = initialTrigger(container);
|
|
88
117
|
if (trigger) activateTab(container, trigger, { scrollBehavior: "auto" });
|
|
89
118
|
|
|
119
|
+
initDisableConditions(container);
|
|
120
|
+
|
|
90
121
|
container.addEventListener("click", (event) => {
|
|
91
122
|
const button = event.target.closest(".tab-x[data-controls]");
|
|
92
123
|
if (!button || !container.contains(button)) return;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.field-helptext {
|
|
31
|
-
@apply text-xs font-normal text-gray
|
|
31
|
+
@apply text-xs font-normal text-gray mt-1 mb-2;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.form__wrapper-block {
|
|
@@ -78,6 +78,14 @@
|
|
|
78
78
|
@apply mb-3 !important;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
.form__wrapper .field.field--radios {
|
|
82
|
+
@apply mt-2;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.form__wrapper .radio-field {
|
|
86
|
+
@apply mt-1;
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
.form__wrapper .field:last-child {
|
|
82
90
|
@apply mb-0;
|
|
83
91
|
}
|
|
@@ -85,14 +93,20 @@
|
|
|
85
93
|
.form__wrapper .field.is-disabled {
|
|
86
94
|
@apply cursor-not-allowed;
|
|
87
95
|
label,
|
|
88
|
-
input
|
|
89
|
-
|
|
96
|
+
input,
|
|
97
|
+
select,
|
|
98
|
+
textarea {
|
|
99
|
+
opacity: 0.6;
|
|
90
100
|
@apply cursor-not-allowed;
|
|
91
101
|
}
|
|
92
102
|
}
|
|
93
103
|
|
|
104
|
+
// Align fieldsets with sibling .field rows (no extra inline offset).
|
|
94
105
|
fieldset {
|
|
95
|
-
@apply border-0 rounded-none m-0 mb-2
|
|
106
|
+
@apply border-0 rounded-none m-0 mb-2 p-0 pt-2 pb-1;
|
|
107
|
+
margin-inline: 0;
|
|
108
|
+
min-width: 0;
|
|
109
|
+
padding-inline: 0;
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
fieldset:last-of-type {
|
|
@@ -109,13 +123,39 @@
|
|
|
109
123
|
@apply text-sm font-normal p-0 normal-case;
|
|
110
124
|
}
|
|
111
125
|
|
|
112
|
-
|
|
113
|
-
@apply
|
|
126
|
+
label.form__wrapper-checkbox-label {
|
|
127
|
+
@apply inline-flex items-center gap-2 text-sm font-normal text-gray-2 cursor-pointer;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Shared label→control spacing for text, number, select, textarea.
|
|
131
|
+
input[type="date"],
|
|
132
|
+
input[type="datetime-local"],
|
|
133
|
+
input[type="email"],
|
|
134
|
+
input[type="month"],
|
|
135
|
+
input[type="number"],
|
|
136
|
+
input[type="password"],
|
|
137
|
+
input[type="search"],
|
|
138
|
+
input[type="tel"],
|
|
139
|
+
input[type="text"],
|
|
140
|
+
input[type="time"],
|
|
141
|
+
input[type="url"],
|
|
142
|
+
input[type="week"],
|
|
143
|
+
select,
|
|
144
|
+
textarea {
|
|
145
|
+
@apply mt-1.5 mb-1.5 py-0.5 px-2 w-full max-w-[55rem] block !important;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
select {
|
|
149
|
+
@apply w-auto min-w-[12rem] max-w-[55rem] pr-8 !important;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
textarea {
|
|
153
|
+
@apply w-auto max-w-[55rem] !important;
|
|
114
154
|
}
|
|
115
155
|
|
|
116
156
|
input[type="checkbox"],
|
|
117
157
|
input[type="radio"] {
|
|
118
|
-
@apply my-
|
|
158
|
+
@apply my-0 mr-2 py-0 px-0 w-auto inline-block !important;
|
|
119
159
|
}
|
|
120
160
|
|
|
121
161
|
.table-fields {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<%# locals: (form:) %>
|
|
1
2
|
<div class="flex justify-end items-center gap-6 mr-6">
|
|
2
3
|
<%= link_to t("cancel", scope: "decidim_toggle.system.organizations.form_tab"), decidim_system.organizations_path, class: "button button__sm" %>
|
|
3
4
|
<%= form.submit t("save", scope: "decidim_toggle.system.organizations.form_tab"), class: "button button__sm button__primary" %>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
<%# locals: (organization:) %>
|
|
1
2
|
<% if encryption_configured? %>
|
|
2
3
|
<%= append_stylesheet_pack_tag "decidim_toggle", media: "all" %>
|
|
3
4
|
<%= append_javascript_pack_tag "decidim_toggle" %>
|
|
4
|
-
<% organization = local_assigns[:organization] %>
|
|
5
5
|
<% tabs = Decidim::Toggle::SettingsTabs.new(:organization_settings) %>
|
|
6
6
|
<% tabs.build_for(self) %>
|
|
7
7
|
<div class="js-decidim-toggle-settings-tabs" id="decidim-toggle-settings-tabs">
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</ul>
|
|
17
17
|
|
|
18
18
|
<% tabs.items.each do |tab| %>
|
|
19
|
-
<div id="panel-toggle-<%= tab.identifier %>" class="border-2 rounded border-background
|
|
19
|
+
<div id="panel-toggle-<%= tab.identifier %>" class="border-2 rounded border-background py-4 px-0 form__wrapper mt-8" aria-hidden="<%= tab.open? ? "false" : "true" %>">
|
|
20
20
|
<% if tab.form_layout_partial.present? %>
|
|
21
21
|
<%= render tab.form_layout_partial, tab:, organization: %>
|
|
22
22
|
<% else %>
|
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
<% tab = local_assigns[:tab] %>
|
|
1
|
+
<%# locals: (organization:, tab:) %>
|
|
3
2
|
<%= decidim_toggle_settings_tab_form(organization, tab) do |tf| %>
|
|
3
|
+
<% tab_form = tf.object %>
|
|
4
4
|
<fieldset>
|
|
5
5
|
<legend class="form-legend"><%= t("decidim_toggle.system.organizations.authorizations_tab.legend") %></legend>
|
|
6
6
|
<p class="text-sm text-gray-2 mb-4"><%= t("decidim_toggle.system.organizations.authorizations_tab.hint") %></p>
|
|
7
|
-
|
|
7
|
+
<% if Decidim::Toggle.ephemeral_participation? %>
|
|
8
|
+
<p class="text-sm text-gray-2 mb-4"><%= t("decidim_toggle.system.organizations.authorizations_tab.ephemeral_hint") %></p>
|
|
9
|
+
<table class="table-fields table table-bordered max-w-[1/2]">
|
|
10
|
+
<thead>
|
|
11
|
+
<tr>
|
|
12
|
+
<th><%= t("decidim_toggle.system.organizations.authorizations_tab.workflow") %></th>
|
|
13
|
+
<th><%= t("decidim_toggle.system.organizations.authorizations_tab.enabled") %></th>
|
|
14
|
+
<th><%= t("decidim_toggle.system.organizations.authorizations_tab.ephemeral") %></th>
|
|
15
|
+
</tr>
|
|
16
|
+
</thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
<% tab_form.collection_for_available_authorizations.each do |name, description| %>
|
|
19
|
+
<% workflow = Decidim::Verifications.find_workflow_manifest(name) %>
|
|
20
|
+
<% next unless workflow %>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><%= description %></td>
|
|
23
|
+
<td><%= check_box_tag "organization[available_authorizations][]", workflow.name, Array(tab_form.available_authorizations).map(&:to_s).include?(workflow.name.to_s), id: "organization_available_authorizations_#{workflow.name}", class: "!m-0" %></td>
|
|
24
|
+
<td><%= radio_button_tag "organization[ephemeral_participation_authorization]", workflow.name, tab_form.ephemeral_participation_authorization.to_s == workflow.name.to_s, id: "organization_ephemeral_participation_authorization_#{workflow.name}", class: "!m-0", disabled: !Decidim::Toggle::UpdateAuthorizationsForm.ephemerable_workflow?(workflow) %></td>
|
|
25
|
+
</tr>
|
|
26
|
+
<% end %>
|
|
27
|
+
</tbody>
|
|
28
|
+
</table>
|
|
29
|
+
<% else %>
|
|
30
|
+
<%= tf.fields_for_names(:available_authorizations) %>
|
|
31
|
+
<% end %>
|
|
8
32
|
</fieldset>
|
|
9
33
|
<% end %>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
<% tab = local_assigns[:tab] %>
|
|
1
|
+
<%# locals: (organization:, tab:) %>
|
|
3
2
|
<%= decidim_toggle_settings_tab_form(organization, tab) do |tf| %>
|
|
4
3
|
<%= render "decidim/system/organizations/smtp_settings", f: tf %>
|
|
5
4
|
<% end %>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
<% tab = local_assigns[:tab] %>
|
|
1
|
+
<%# locals: (organization:, tab:) %>
|
|
3
2
|
<%= decidim_toggle_settings_tab_form(organization, tab) do |tf| %>
|
|
4
3
|
<%= render "decidim/system/organizations/file_upload_settings", f: tf %>
|
|
5
4
|
<% end %>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
<% tab = local_assigns[:tab] %>
|
|
1
|
+
<%# locals: (organization:, tab:) %>
|
|
3
2
|
<%= decidim_toggle_settings_tab_form(organization, tab) do |tf| %>
|
|
4
3
|
<% tab_form = tf.object %>
|
|
5
4
|
<fieldset>
|
|
6
5
|
<legend class="form-legend"><%= t("decidim_toggle.system.organizations.language_tab.legend") %></legend>
|
|
7
|
-
<table class="table-fields">
|
|
6
|
+
<table class="table-fields table table-bordered max-w-[1/2]">
|
|
8
7
|
<thead>
|
|
9
8
|
<tr>
|
|
10
9
|
<th><%= t("decidim_toggle.system.organizations.language_tab.locale") %></th>
|
|
@@ -27,9 +26,7 @@
|
|
|
27
26
|
<legend class="form-legend"><%= t("decidim_toggle.system.organizations.language_tab.machine_translations_legend") %></legend>
|
|
28
27
|
<%= tf.fields_for_names(:enable_machine_translations) %>
|
|
29
28
|
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
<%= tf.fields_for_names(:machine_translation_display_priority) %>
|
|
33
|
-
</p>
|
|
29
|
+
<label class="form-legend" for="organization[machine_translation_display_priority]"><%= t("decidim_toggle.system.organizations.language_tab.machine_translation_display_priority_hint") %></label>
|
|
30
|
+
<%= tf.fields_for_names(:machine_translation_display_priority) %>
|
|
34
31
|
</fieldset>
|
|
35
32
|
<% end %>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
<% tab = local_assigns[:tab] %>
|
|
1
|
+
<%# locals: (organization:, tab:) %>
|
|
3
2
|
<%= decidim_toggle_settings_tab_form(organization, tab) do |tf| %>
|
|
4
3
|
<%= render "decidim/system/organizations/omniauth_settings", f: tf %>
|
|
5
4
|
<% end %>
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
<% tab = local_assigns[:tab] %>
|
|
1
|
+
<%# locals: (organization:, tab:) %>
|
|
3
2
|
<%= decidim_toggle_settings_tab_form(organization, tab) do |tf| %>
|
|
4
3
|
<fieldset>
|
|
5
4
|
<legend class="form-legend"><%= t("decidim_toggle.system.organizations.security_tab.access_legend") %></legend>
|
|
6
|
-
|
|
7
5
|
<p>
|
|
8
6
|
<%= tf.check_box :force_users_to_authenticate_before_access_organization %>
|
|
9
7
|
</p>
|