-
Notifications
You must be signed in to change notification settings - Fork 330
Update Column Action Flow
Sergio Cambra edited this page Nov 29, 2024
·
6 revisions
In-place editing usually displays a form using JS, but if :ajax
is set in inplace_edit
, it will use this action with GET request to render the form for in-place edit, which will call these methods in the following order:
-
render_field
-
render_field_for_inplace_editing
.- It sets @column with the column being updated.
- It loads the record into @record instance variable, which uses find_if_allowed to load it.
-
find_if_allowed
is called to load the record, checking permission with :update and column's name.
-
-
Then it will render the following view:
-
render_field_inplace.html.erb
is rendered to return the html field for the column
When form is submitted, these methods are called in the following order:
-
update_column
-
do_update_column
.- It sets @column with the column being updated
-
record_for_update_column
is called to load the record into @record instance variable, which uses find_if_allowed to load it-
find_if_allowed
is called to load the record, checking :read permission. - It checks permission for :update and column's name, and stops the action if not allowed, but don't return 404 error.
-
-
value_for_update_column
to convert the submitted value to ruby object, with the same methods used internally by create and update actions. -
before_update_save
will be called, after setting the value, before saving. - If record is saved successfully and
inplace_edit_update
is set in the column, it will call one of these methods:-
do_list
ifinplace_edit_update
is:table
. -
get_row
ifinplace_edit_update
is not:table
but has value.
-
-
after_update_save
is called after saving the record
-
Then it will render the following view and partials:
-
update_column.js.erb
is rendered to refresh the table, row, columns set inupdate_columns
or the column being edited, depending on the value ofinplace_edit_update
.- renders
_update_messages.js.erb
if updating failed - depending on the value of
inplace_edit_update
renders:- if it's
:row
renders_row
partial to refresh the row. - if it's
:table
renders_list
partial to refresh the list table. - otherwise, updates the column, and renders
_update_columns.js.erb
if it's:columns
andupdate_columns
is set.
- if it's
- If the column has calculation enabled, it will update the column calculation too.
- renders