Module: Plutonium::Resource::Controllers::InteractiveActions
- Extended by:
- ActiveSupport::Concern
- Included in:
- Plutonium::Resource::Controller
- Defined in:
- lib/plutonium/resource/controllers/interactive_actions.rb
Instance Method Summary collapse
- #commit_interactive_bulk_action ⇒ Object
-
#commit_interactive_record_action ⇒ Object
POST /resources/1/record_actions/:interactive_action.
-
#commit_interactive_resource_action ⇒ Object
POST /resources/resource_actions/:interactive_action.
- #interactive_bulk_action ⇒ Object
-
#interactive_record_action ⇒ Object
GET /resources/1/record_actions/:interactive_action.
-
#interactive_resource_action ⇒ Object
GET /resources/resource_actions/:interactive_action.
Instance Method Details
#commit_interactive_bulk_action ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 132 def commit_interactive_bulk_action build_interactive_bulk_action_interaction if params[:pre_submit] respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.replace("interaction-form", view_context.render(@interaction.build_form)) } format.html { render :interactive_bulk_action, formats: [:html], status: :unprocessable_content } end return end outcome = @interaction.call outcome.to_response.process(self) do |value| respond_to do |format| if outcome.success? return_url = redirect_url_after_action_on(resource_class) format.turbo_stream do render turbo_stream: helpers.turbo_stream_redirect(return_url) end format.html do redirect_to return_url, status: :see_other end format.any do head :no_content, location: return_url end else format.any(:html, :turbo_stream) do render :interactive_bulk_action, layout: modal_layout, formats: [:html], status: :unprocessable_content end format.any do @errors = @interaction.errors render "errors", status: :unprocessable_content end end end end end |
#commit_interactive_record_action ⇒ Object
POST /resources/1/record_actions/:interactive_action
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 36 def commit_interactive_record_action build_interactive_record_action_interaction if params[:pre_submit] respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.replace("interaction-form", view_context.render(@interaction.build_form)) } format.html { render :interactive_record_action, formats: [:html], status: :unprocessable_content } end return end outcome = @interaction.call outcome.to_response.process(self) do |value| respond_to do |format| if outcome.success? return_url = redirect_url_after_action_on(resource_record!) format.turbo_stream do render turbo_stream: helpers.turbo_stream_redirect(return_url) end format.html do redirect_to return_url, status: :see_other end format.any do render :show, status: :ok, location: return_url end else format.any(:html, :turbo_stream) do render :interactive_record_action, layout: modal_layout, formats: [:html], status: :unprocessable_content end format.any do @errors = @interaction.errors render "errors", status: :unprocessable_content end end end end end |
#commit_interactive_resource_action ⇒ Object
POST /resources/resource_actions/:interactive_action
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 84 def commit_interactive_resource_action build_interactive_resource_action_interaction if params[:pre_submit] respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.replace("interaction-form", view_context.render(@interaction.build_form)) } format.html { render :interactive_resource_action, status: :unprocessable_content } end return end outcome = @interaction.call outcome.to_response.process(self) do |value| respond_to do |format| if outcome.success? return_url = redirect_url_after_action_on(resource_class) format.turbo_stream do render turbo_stream: helpers.turbo_stream_redirect(return_url) end format.html do redirect_to return_url, status: :see_other end format.any do head :no_content, location: return_url end else format.any(:html, :turbo_stream) do render :interactive_resource_action, layout: modal_layout, formats: [:html], status: :unprocessable_content end format.any do @errors = @interaction.errors render "errors", status: :unprocessable_content end end end end end |
#interactive_bulk_action ⇒ Object
126 127 128 129 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 126 def interactive_bulk_action build_interactive_bulk_action_interaction render :interactive_bulk_action, layout: modal_layout, formats: [:html] end |
#interactive_record_action ⇒ Object
GET /resources/1/record_actions/:interactive_action
30 31 32 33 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 30 def interactive_record_action build_interactive_record_action_interaction render :interactive_record_action, layout: modal_layout, formats: [:html] end |
#interactive_resource_action ⇒ Object
GET /resources/resource_actions/:interactive_action
77 78 79 80 81 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 77 def interactive_resource_action build_interactive_resource_action_interaction render :interactive_resource_action, layout: modal_layout, formats: [:html] end |