Class: Avo::Views::ResourceEditComponent
- Inherits:
-
ResourceComponent
- Object
- ResourceComponent
- Avo::Views::ResourceEditComponent
- Includes:
- ApplicationHelper
- Defined in:
- app/components/avo/views/resource_edit_component.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#display_breadcrumbs ⇒ Object
readonly
Returns the value of attribute display_breadcrumbs.
Instance Method Summary collapse
- #back_path ⇒ Object
- #can_see_the_destroy_button? ⇒ Boolean
-
#can_see_the_save_button? ⇒ Boolean
The save button is dependent on the edit? policy method.
- #controls ⇒ Object
-
#initialize(resource: nil, record: nil, actions: [], view: "edit", display_breadcrumbs: true) ⇒ ResourceEditComponent
constructor
A new instance of ResourceEditComponent.
- #resource_view_path ⇒ Object
- #resources_path ⇒ Object
- #title ⇒ Object
-
#view_for(field) ⇒ Object
Render :show view for read only trix fields.
Methods included from ApplicationHelper
#a_button, #a_link, #button_classes, #card_classes, #chart_color, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes
Methods included from ResourcesHelper
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table
Constructor Details
#initialize(resource: nil, record: nil, actions: [], view: "edit", display_breadcrumbs: true) ⇒ ResourceEditComponent
Returns a new instance of ResourceEditComponent.
8 9 10 11 12 13 14 |
# File 'app/components/avo/views/resource_edit_component.rb', line 8 def initialize(resource: nil, record: nil, actions: [], view: "edit", display_breadcrumbs: true) @resource = resource @record = record @actions = actions @view = Avo::ViewInquirer.new(view) @display_breadcrumbs = @reflection.blank? && end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
6 7 8 |
# File 'app/components/avo/views/resource_edit_component.rb', line 6 def actions @actions end |
#display_breadcrumbs ⇒ Object (readonly)
Returns the value of attribute display_breadcrumbs.
6 7 8 |
# File 'app/components/avo/views/resource_edit_component.rb', line 6 def @display_breadcrumbs end |
Instance Method Details
#back_path ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/components/avo/views/resource_edit_component.rb', line 20 def back_path return if via_belongs_to? return resource_view_path if via_resource? return resources_path if via_index? if is_edit? && Avo.configuration.resource_default_view.show? # via resource show or edit page return helpers.resource_path(record: @resource.record, resource: @resource, **keep_referrer_params) end resources_path end |
#can_see_the_destroy_button? ⇒ Boolean
40 41 42 43 44 |
# File 'app/components/avo/views/resource_edit_component.rb', line 40 def return super if is_edit? && Avo.configuration.resource_default_view.edit? false end |
#can_see_the_save_button? ⇒ Boolean
The save button is dependent on the edit? policy method. The update? method should be called only when the user clicks the Save button so the developer gets access to the params from the form.
48 49 50 |
# File 'app/components/avo/views/resource_edit_component.rb', line 48 def @resource.. @view, raise_exception: false end |
#controls ⇒ Object
52 53 54 |
# File 'app/components/avo/views/resource_edit_component.rb', line 52 def controls @resource.render_edit_controls end |
#resource_view_path ⇒ Object
36 37 38 |
# File 'app/components/avo/views/resource_edit_component.rb', line 36 def resource_view_path helpers.resource_view_path(record: association_resource.record, resource: association_resource) end |
#resources_path ⇒ Object
32 33 34 |
# File 'app/components/avo/views/resource_edit_component.rb', line 32 def resources_path helpers.resources_path(resource: @resource, **keep_referrer_params) end |
#title ⇒ Object
16 17 18 |
# File 'app/components/avo/views/resource_edit_component.rb', line 16 def title @resource.default_panel_name end |