Class: EasyAdmin::Fields::BelongsToEditModalComponent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- EasyAdmin::Fields::BelongsToEditModalComponent
- Defined in:
- app/components/easy_admin/fields/belongs_to_edit_modal_component.rb
Instance Method Summary collapse
-
#initialize(record:, resource_class:, parent_record:, parent_field:) ⇒ BelongsToEditModalComponent
constructor
A new instance of BelongsToEditModalComponent.
- #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 EasyAdmin::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:, resource_class:, parent_record:, parent_field:) ⇒ BelongsToEditModalComponent
Returns a new instance of BelongsToEditModalComponent.
4 5 6 7 8 9 |
# File 'app/components/easy_admin/fields/belongs_to_edit_modal_component.rb', line 4 def initialize(record:, resource_class:, parent_record:, parent_field:) @record = record @resource_class = resource_class @parent_record = parent_record @parent_field = parent_field end |
Instance Method Details
#view_template ⇒ Object
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 68 69 70 71 72 73 74 |
# File 'app/components/easy_admin/fields/belongs_to_edit_modal_component.rb', line 11 def view_template turbo_frame(id: "modal") do div( id: "modal-backdrop", class: "fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50 opacity-100 transition-opacity duration-300", data: { controller: "modal", action: "click->modal#closeOnBackdrop" } ) do div(class: "relative top-20 mx-auto p-5 border w-11/12 md:w-3/4 lg:w-1/2 xl:w-2/5 shadow-lg rounded-md bg-white") do div(class: "mt-3") do # Modal header div(class: "flex items-center justify-between mb-4") do h3(class: "text-lg font-medium text-gray-900") do "Edit #{@resource_class.singular_title}" end ( class: "text-gray-400 hover:text-gray-600 focus:outline-none", data: { action: "click->modal#close" } ) do unsafe_raw <<~SVG <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path> </svg> SVG end end # Modal form form( action: update_attached_url, method: "patch", data: { turbo_frame: "_top", controller: "form", action: "submit->form#submit turbo:submit-end->modal#handleSubmitEnd" } ) do render_form_fields # Form actions div(class: "flex justify-end space-x-3 mt-6") 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 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500", data: { action: "click->modal#close" } ) do "Cancel" end ( type: "submit", class: "px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" ) do "Save Changes" end end end end end end end end |