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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 151 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, 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
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 75 76 77 78 79 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 41 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, 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
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 98 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, 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
140 141 142 143 144 145 146 147 148 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 140 def interactive_bulk_action build_interactive_bulk_action_interaction if helpers.current_turbo_frame == "remote_modal" render layout: false, formats: [:html] else render :interactive_bulk_action, formats: [:html] end end |
#interactive_record_action ⇒ Object
GET /resources/1/record_actions/:interactive_action
30 31 32 33 34 35 36 37 38 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 30 def interactive_record_action build_interactive_record_action_interaction if helpers.current_turbo_frame == "remote_modal" render layout: false, formats: [:html] else render :interactive_record_action, formats: [:html] end end |
#interactive_resource_action ⇒ Object
GET /resources/resource_actions/:interactive_action
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 82 def interactive_resource_action build_interactive_resource_action_interaction respond_to do |format| format.any(:html, :turbo_stream) do if helpers.current_turbo_frame == "remote_modal" render layout: false, formats: [:html] else render :interactive_resource_action, formats: [:html] end end end end |