Module: Plutonium::Resource::Controllers::InteractiveActions

Extended by:
ActiveSupport::Concern
Includes:
StructuredInputs::ParamsConcern
Included in:
Plutonium::Resource::Controller
Defined in:
lib/plutonium/resource/controllers/interactive_actions.rb

Instance Method Summary collapse

Methods included from StructuredInputs::ParamsConcern

#clean_structured_inputs

Instance Method Details

#commit_interactive_bulk_actionObject



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
171
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 133

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(helpers.turbo_scoped_dom_id("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], content_type: "text/html", **modal_render_options, status: :unprocessable_content
        end
        format.any do
          @errors = @interaction.errors
          render "errors", status: :unprocessable_content
        end
      end
    end
  end
end

#commit_interactive_record_actionObject

POST /resources/1/record_actions/:interactive_action



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
75
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 37

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(helpers.turbo_scoped_dom_id("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], content_type: "text/html", **modal_render_options, status: :unprocessable_content
        end
        format.any do
          @errors = @interaction.errors
          render "errors", status: :unprocessable_content
        end
      end
    end
  end
end

#commit_interactive_resource_actionObject

POST /resources/resource_actions/:interactive_action



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
124
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 85

def commit_interactive_resource_action
  skip_verify_current_authorized_scope!
  build_interactive_resource_action_interaction

  if params[:pre_submit]
    respond_to do |format|
      format.turbo_stream { render turbo_stream: turbo_stream.replace(helpers.turbo_scoped_dom_id("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], content_type: "text/html", **modal_render_options, status: :unprocessable_content
        end
        format.any do
          @errors = @interaction.errors
          render "errors", status: :unprocessable_content
        end
      end
    end
  end
end

#interactive_bulk_actionObject



127
128
129
130
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 127

def interactive_bulk_action
  build_interactive_bulk_action_interaction
  render :interactive_bulk_action, formats: [:html], **modal_render_options
end

#interactive_record_actionObject

GET /resources/1/record_actions/:interactive_action



31
32
33
34
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 31

def interactive_record_action
  build_interactive_record_action_interaction
  render :interactive_record_action, formats: [:html], **modal_render_options
end

#interactive_resource_actionObject

GET /resources/resource_actions/:interactive_action



78
79
80
81
82
# File 'lib/plutonium/resource/controllers/interactive_actions.rb', line 78

def interactive_resource_action
  skip_verify_current_authorized_scope!
  build_interactive_resource_action_interaction
  render :interactive_resource_action, formats: [:html], **modal_render_options
end