-
Notifications
You must be signed in to change notification settings - Fork 332
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_allowedis called to load the record, checking permission with :update and column's name.
-
-
Then it will render the following view:
-
render_field_inplace.html.erbis 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_columnis called to load the record into @record instance variable, which uses find_if_allowed to load it-
find_if_allowedis 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_columnto convert the submitted value to ruby object, with the same methods used internally by create and update actions. -
before_update_savewill be called, after setting the value, before saving. - If record is saved successfully and
inplace_edit_updateis set in the column, it will call one of these methods:-
do_listifinplace_edit_updateis:table. -
get_rowifinplace_edit_updateis not:tablebut has value.
-
-
after_update_saveis called after saving the record
-
Then it will render the following view and partials:
-
update_column.js.erbis rendered to refresh the table, row, columns set inupdate_columnsor the column being edited, depending on the value ofinplace_edit_update.- renders
_update_messages.js.erbif updating failed - depending on the value of
inplace_edit_updaterenders:- if it's
:rowrenders_rowpartial to refresh the row. - if it's
:tablerenders_listpartial to refresh the list table. - otherwise, updates the column, and renders
_update_columns.js.erbif it's:columnsandupdate_columnsis set.
- if it's
- If the column has calculation enabled, it will update the column calculation too.
- renders