Class: EasyAdmin::RowActionFormComponent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- EasyAdmin::RowActionFormComponent
- Defined in:
- app/components/easy_admin/row_action_form_component.rb
Instance Method Summary collapse
-
#initialize(record:, action_class:, resource_class:, submit_url:) ⇒ RowActionFormComponent
constructor
A new instance of RowActionFormComponent.
- #view_template ⇒ Object
Methods inherited from BaseComponent
#easy_admin_url_helpers, #helpers, #rails_url_helpers
Methods included from Permissions::Component
#current_user_can?, #current_user_has_role?, #if_can, #if_has_role, #permission_attrs, #permission_button, #permission_case, #permission_classes, #permission_field, #permission_link, #unless_can, #unless_has_role
Methods included from FieldsHelper
#field_component, #render_field
Methods included from DashboardsHelper
#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes
Constructor Details
#initialize(record:, action_class:, resource_class:, submit_url:) ⇒ RowActionFormComponent
Returns a new instance of RowActionFormComponent.
3 4 5 6 7 8 |
# File 'app/components/easy_admin/row_action_form_component.rb', line 3 def initialize(record:, action_class:, resource_class:, submit_url:) @record = record @action_class = action_class @resource_class = resource_class @submit_url = submit_url end |
Instance Method Details
#view_template ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 |
# File 'app/components/easy_admin/row_action_form_component.rb', line 10 def view_template div( id: "modal", class: "fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50", data: { controller: "row-modal", row_modal_submit_url_value: @submit_url, row_modal_record_id_value: @record.id, row_modal_action_class_value: @action_class.name } ) do div(class: "relative top-20 mx-auto p-5 border w-11/12 max-w-md shadow-lg rounded-md bg-white") do # Header div(class: "flex items-center justify-between pb-4 mb-4 border-b border-gray-200") do h3(class: "text-lg font-semibold text-gray-900") do @action_class.modal_title || @action_class.label || @action_class.name.humanize end ( type: "button", class: "text-gray-400 hover:text-gray-600 text-xl", data: { action: "click->row-modal#close" } ) { "×" } end # Description if @action_class.modal_description.present? p(class: "text-sm text-gray-600 mb-4") { @action_class.modal_description } end # Record info div(class: "mb-4 p-3 bg-gray-50 rounded") do div(class: "text-sm text-gray-600") do "Record: #{@record.respond_to?(:title) ? @record.title : @record.to_s}" end end # Simple form fields div(class: "space-y-4", data: { row_modal_target: "form" }) do render_simple_fields end # Action buttons div(class: "flex justify-end space-x-3 pt-4 border-t border-gray-200 mt-4") do ( type: "button", class: "px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50", data: { action: "click->row-modal#close" } ) { "Cancel" } ( type: "button", class: "px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700", data: { action: "click->row-modal#submit" } ) { @action_class.label } end end end end |