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
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 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 153 def commit_interactive_bulk_action raise NotImplementedError # respond_to do |format| # inputs = interaction_params.merge(resources: interactive_bulk) # @interaction = current_interactive_action.interaction.run(inputs) # if @interaction.valid? # collection_count = interactive_bulk.size # flash[:notice] = "TODO:#{current_interactive_action} #{collection_count} #{resource_class.model_name.human.pluralize(collection_count)} successfully updated." # format.html { redirect_to resource_url_for(resource_class) } # if helpers.current_turbo_frame == "remote_modal" # format.turbo_stream do # render turbo_stream: [ # helpers.turbo_stream_redirect(resource_url_for(resource_class)) # ] # end # end # else # format.html do # render :interactive_bulk_action, status: :unprocessable_content # end # format.any do # @errors = @interaction.errors # render "errors", status: :unprocessable_content # end # end # end end |
#commit_interactive_record_action ⇒ Object
POST /resources/1/record_actions/:interactive_action
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 75 76 77 78 79 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 38 def commit_interactive_record_action build_interactive_record_action_interaction if params[:pre_submit] respond_to do |format| format.html do render :interactive_record_action, status: :unprocessable_content end 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.any { redirect_to return_url, status: :see_other } if helpers.current_turbo_frame == "remote_modal" format.turbo_stream do render turbo_stream: [ helpers.turbo_stream_redirect(return_url) ] end end else format.html do render :interactive_record_action, 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
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 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 94 def commit_interactive_resource_action build_interactive_resource_action_interaction if params[:pre_submit] respond_to do |format| format.html do render :interactive_resource_action, status: :unprocessable_content end 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.any { redirect_to return_url, status: :see_other } if helpers.current_turbo_frame == "remote_modal" format.turbo_stream do render turbo_stream: [ helpers.turbo_stream_redirect(return_url) ] end end else format.html do render :interactive_resource_action, status: :unprocessable_content end format.any do @errors = @interaction.errors render "errors", status: :unprocessable_content end end end end end |
#interactive_bulk_action ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 139 def interactive_bulk_action raise NotImplementedError # # TODO: ensure that the selected list matches the returned value # interactive_bulk # @interaction = current_interactive_action.interaction.new((params[:interaction] || {}).except(:resources)) # if helpers.current_turbo_frame == "remote_modal" # render layout: false # else # render :interactive_bulk_action # end end |
#interactive_record_action ⇒ Object
GET /resources/1/record_actions/:interactive_action
27 28 29 30 31 32 33 34 35 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 27 def interactive_record_action build_interactive_record_action_interaction if helpers.current_turbo_frame == "remote_modal" render layout: false else render :interactive_record_action end end |
#interactive_resource_action ⇒ Object
GET /resources/resource_actions/:interactive_action
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 82 def interactive_resource_action build_interactive_resource_action_interaction if helpers.current_turbo_frame == "remote_modal" render layout: false else render :interactive_resource_action end end |