Class: LcpRuby::DialogsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- LcpRuby::DialogsController
- Includes:
- DialogRendering, FormActionExecution, ZoneResolution
- Defined in:
- app/controllers/lcp_ruby/dialogs_controller.rb
Constant Summary
Constants included from FormActionExecution
FormActionExecution::VALID_FORM_ACTION_REDIRECTS
Constants included from DialogRendering
LcpRuby::DialogRendering::DIALOG_PASS_THROUGH_KEYS
Constants included from Controller::BearerAuthentication
Controller::BearerAuthentication::BASIC_PREFIX_LENGTH, Controller::BearerAuthentication::BEARER_PREFIX_LENGTH
Instance Method Summary collapse
Methods included from FormActionExecution
#apply_set_fields!, #current_form_actions, #dispatch_deferred_events, #execute_form_action_pipeline, #form_action_dialog_behavior, #form_action_redirect_path, #pipeline_flash_message, #pipeline_redirect_path, #resolve_form_action
Methods included from DialogRendering
#composite_dialog?, #defaults_from_params, #dialog_context?, #dialog_form_url, #dialog_locals, #dialog_pass_through_params, #partial_for_dialog_result_style, #render_composite_dialog_form, #render_dialog_form, #render_dialog_form_with_errors, #render_dialog_result, #render_dialog_success, #resolved_dialog_config, #resolved_dialog_page
Methods included from Controller::Authorization
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/lcp_ruby/dialogs_controller.rb', line 21 def create if virtual_model? @record = JsonItemWrapper.new(dialog_permitted_params, @model_definition) @record.validate_with_model_rules! if @record.errors.none? result = dispatch_virtual_model_action handle_virtual_model_result(result) else resolve_dialog_form_actions! render_dialog_form_with_errors end else @record = @model_class.new(dialog_permitted_params) @record fa_config = resolve_form_action(@record) apply_set_fields!(@record, fa_config) if @record.errors.any? @form_actions = current_form_actions(@record) return render_dialog_form_with_errors end result = execute_form_action_pipeline(@record, fa_config) if result.success? dispatch_deferred_events(result) behavior = form_action_dialog_behavior(fa_config) flash_msg = behavior == "reset" ? ("create", result) : nil render_dialog_success(behavior, flash_message: flash_msg, result_config: fa_config["result"]) else resolve_dialog_form_actions! render_dialog_form_with_errors end end end |
#edit ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/controllers/lcp_ruby/dialogs_controller.rb', line 58 def edit @record = policy_scope(@model_class).find(params[:id]) @record @form_actions = current_form_actions(@record) render_dialog_form end |
#new ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/lcp_ruby/dialogs_controller.rb', line 10 def new if virtual_model? @record = JsonItemWrapper.new(defaults_from_params, @model_definition) else @record = @model_class.new(defaults_from_params) end resolve_dialog_form_actions! render_dialog_form end |
#update ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/lcp_ruby/dialogs_controller.rb', line 66 def update @record = policy_scope(@model_class).find(params[:id]) @record @record.assign_attributes(dialog_permitted_params) fa_config = resolve_form_action(@record) apply_set_fields!(@record, fa_config) if @record.errors.any? @form_actions = current_form_actions(@record) return render_dialog_form_with_errors end result = execute_form_action_pipeline(@record, fa_config) if result.success? dispatch_deferred_events(result) behavior = form_action_dialog_behavior(fa_config) flash_msg = behavior == "reset" ? ("update", result) : nil render_dialog_success(behavior, flash_message: flash_msg, result_config: fa_config["result"]) else @form_actions = current_form_actions(@record) render_dialog_form_with_errors end end |