Class: Flexite::ConfigsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Flexite::ConfigsController
- Defined in:
- app/controllers/flexite/configs_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #reload ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/flexite/configs_controller.rb', line 17 def create @config_form = Config::Form.new(config_params) result = ServiceFactory.instance.get(:config_create, @config_form).call if result.succeed? @node = result.record.tv_node @parent_id = config_params[:config_id] end service_flash(result) service_response(result) end |
#destroy ⇒ Object
46 47 48 49 |
# File 'app/controllers/flexite/configs_controller.rb', line 46 def destroy Config.destroy(params[:id]) head :ok end |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/flexite/configs_controller.rb', line 30 def edit @config_form = Config::Form.new(Config.find(params[:id]).attributes) end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/flexite/configs_controller.rb', line 7 def index @configs = Config.tree_view(params[:config_id]) @cache_key = "#{controller_name}/#{action_name}.#{request.format.symbol}/#{Config.roots.maximum(:updated_at)&.to_s(:number)}/#{params.fetch(:config_id, :root)}" end |
#new ⇒ Object
12 13 14 15 |
# File 'app/controllers/flexite/configs_controller.rb', line 12 def new parent_config = Config.where(id: params[:config_id], selectable: false).first @config_form = Config::Form.new(config_id: parent_config.present? ? parent_config.id : nil) end |
#reload ⇒ Object
51 52 53 54 55 |
# File 'app/controllers/flexite/configs_controller.rb', line 51 def reload Flexite.reload_root_cache flash[:success] = 'Cache was reloaded' render partial: 'flexite/shared/show_flash' end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/flexite/configs_controller.rb', line 34 def update @config_form = Config::Form.new(config_params) result = ServiceFactory.instance.get(:update_config, @config_form).call if result.succeed? @node = result.record.tv_node end service_flash(result) service_response(result) end |