Class: Collavre::Admin::IntegrationsController
- Inherits:
-
Collavre::ApplicationController
- Object
- ApplicationController
- Collavre::ApplicationController
- Collavre::Admin::IntegrationsController
- Defined in:
- app/controllers/collavre/admin/integrations_controller.rb
Constant Summary collapse
- Registry =
Collavre::IntegrationSettings::Registry
- Resolver =
Collavre::IntegrationSettings::Resolver
Instance Method Summary collapse
Instance Method Details
#bulk_update ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/collavre/admin/integrations_controller.rb', line 16 def bulk_update submitted = (params[:integration_setting] || {}).to_unsafe_h restart_required_changed = false Collavre::IntegrationSetting.transaction do submitted.each do |key, raw_value| value = raw_value.to_s next if value.blank? definition = Registry.instance.find(key) or next row = Collavre::IntegrationSetting.find_or_initialize_by(key: definition.key.to_s) row.category = definition.category row.value = value row.save! restart_required_changed ||= definition.requires_restart end end flash[:notice] = t("collavre.admin.integrations.flash.updated") flash[:warning] = t("collavre.admin.integrations.flash.restart_required") if restart_required_changed redirect_to collavre.admin_integrations_path end |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/collavre/admin/integrations_controller.rb', line 12 def index @grouped_settings = build_grouped_settings end |
#reset ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/collavre/admin/integrations_controller.rb', line 41 def reset Collavre::IntegrationSetting.where(key: @definition.key.to_s).destroy_all redirect_to collavre.admin_integrations_path, notice: t("collavre.admin.integrations.flash.reset_done", key: @definition.key) end |