Module: Decidim::Toggle
- Defined in:
- lib/decidim/toggle/version.rb,
lib/decidim/toggle.rb,
lib/decidim/toggle/engine.rb,
lib/decidim/toggle/tab_form.rb,
lib/decidim/toggle/gem_registry.rb,
lib/decidim/toggle/module_config.rb,
lib/decidim/toggle/settings_tabs.rb,
lib/decidim/toggle/javascript_config.rb,
lib/decidim/toggle/settings_tab_item.rb,
lib/decidim/toggle/module_config_form.rb,
lib/decidim/toggle/module_config_i18n.rb,
lib/decidim/toggle/informative_callouts.rb,
lib/decidim/toggle/settings_form_builder.rb,
lib/decidim/toggle/settings_tab_registry.rb,
app/forms/decidim/toggle/update_name_form.rb,
lib/decidim/toggle/expose_attributes_to_js.rb,
app/forms/decidim/toggle/update_emails_form.rb,
app/forms/decidim/toggle/update_locale_form.rb,
app/forms/decidim/toggle/update_omniauth_form.rb,
app/forms/decidim/toggle/update_security_form.rb,
lib/decidim/toggle/organization_settings_tabs.rb,
app/commands/decidim/toggle/update_name_command.rb,
app/commands/decidim/toggle/update_emails_command.rb,
app/commands/decidim/toggle/update_locale_command.rb,
lib/decidim/toggle/module_configuration_presenter.rb,
app/commands/decidim/toggle/update_omniauth_command.rb,
app/commands/decidim/toggle/update_security_command.rb,
app/forms/decidim/toggle/update_authorizations_form.rb,
app/helpers/decidim/toggle/javascript_config_helper.rb,
app/models/decidim/toggle/organization_module_config.rb,
lib/decidim/toggle/expose_attributes_to_js_validator.rb,
app/helpers/decidim/toggle/system_settings_tab_helper.rb,
app/commands/decidim/toggle/update_module_config_command.rb,
app/commands/decidim/toggle/update_authorizations_command.rb,
app/forms/decidim/toggle/update_file_upload_settings_form.rb,
app/commands/decidim/toggle/update_file_upload_settings_command.rb
Overview
This holds the decidim-toggle version.
Defined Under Namespace
Modules: ExposeAttributesToJs, ExposeAttributesToJsValidator, InformativeCallouts, JavascriptConfigHelper, ModuleConfigForm, ModuleConfigI18n, SystemSettingsTabHelper, TabForm
Classes: DuplicateTabRegistrationError, Engine, GemRegistry, JavascriptConfig, ModuleConfigurationPresenter, OrganizationModuleConfig, OrganizationSettingsTabs, SettingsFormBuilder, SettingsTabItem, SettingsTabRegistry, SettingsTabs, UpdateAuthorizationsCommand, UpdateAuthorizationsForm, UpdateEmailsCommand, UpdateEmailsForm, UpdateFileUploadSettingsCommand, UpdateFileUploadSettingsForm, UpdateLocaleCommand, UpdateLocaleForm, UpdateModuleConfigCommand, UpdateNameCommand, UpdateNameForm, UpdateOmniauthCommand, UpdateOmniauthForm, UpdateSecurityCommand, UpdateSecurityForm
Class Method Summary
collapse
Class Method Details
.config_for(organization, module_name, registry_name: :organization_settings) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/decidim/toggle/module_config.rb', line 12
def config_for(organization, module_name, registry_name: :organization_settings)
key = normalize_module_name(module_name)
raw = raw_config_hash(organization, key)
entry = SettingsTabRegistry.find(registry_name)&.form_tab_for_module(key)
if entry && entry[:form]
form = build_form_from_hash(entry[:form], organization, raw)
ModuleConfigurationPresenter.new(form).to_config_hash.with_indifferent_access
else
raw.with_indifferent_access
end
end
|
.decidim_version ⇒ Object
10
11
12
|
# File 'lib/decidim/toggle/version.rb', line 10
def self.decidim_version
[">= 0.29", "< 0.33"].freeze
end
|
.gem_present?(gem_name) ⇒ Boolean
25
26
27
|
# File 'lib/decidim/toggle.rb', line 25
def self.gem_present?(gem_name)
GemRegistry.present?(gem_name)
end
|
.javascript_config_for(organization, registry_name: :organization_settings) ⇒ Hash{String => Object}
Returns flat keys like "decidim_geo.enabled".
32
33
34
|
# File 'lib/decidim/toggle.rb', line 32
def self.javascript_config_for(organization, registry_name: :organization_settings)
JavascriptConfig.for(organization, registry_name:)
end
|
.normalize_module_name(name) ⇒ Object
8
9
10
|
# File 'lib/decidim/toggle/module_config.rb', line 8
def normalize_module_name(name)
name.to_s
end
|
.save_config!(organization, module_name, attributes, merge: true) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/decidim/toggle/module_config.rb', line 25
def save_config!(organization, module_name, attributes, merge: true)
key = normalize_module_name(module_name)
record = OrganizationModuleConfig.find_or_initialize_by(
decidim_organization_id: organization.id,
module_name: key
)
incoming = stringify_keys(attributes)
record.config = merge ? (record.config || {}).stringify_keys.merge(incoming) : incoming
record.save!
record
end
|
.settings_tabs(name) ⇒ Object
.version ⇒ Object
6
7
8
|
# File 'lib/decidim/toggle/version.rb', line 6
def self.version
"0.1.3" end
|