Class: EasyAdmin::ConfirmationModalComponent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- EasyAdmin::ConfirmationModalComponent
- Defined in:
- app/components/easy_admin/confirmation_modal_component.rb
Instance Method Summary collapse
-
#initialize(title:, message:, confirm_text: "Confirm", cancel_text: "Cancel", danger: false) ⇒ ConfirmationModalComponent
constructor
A new instance of ConfirmationModalComponent.
- #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(title:, message:, confirm_text: "Confirm", cancel_text: "Cancel", danger: false) ⇒ ConfirmationModalComponent
Returns a new instance of ConfirmationModalComponent.
3 4 5 6 7 8 9 |
# File 'app/components/easy_admin/confirmation_modal_component.rb', line 3 def initialize(title:, message:, confirm_text: "Confirm", cancel_text: "Cancel", danger: false) @title = title @message = @confirm_text = confirm_text @cancel_text = cancel_text @danger = danger 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 |
# File 'app/components/easy_admin/confirmation_modal_component.rb', line 11 def view_template div( id: "confirmation-modal", class: "fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50", data: { controller: "confirmation-modal", action: "click->confirmation-modal#clickOutside" } ) do div( class: "relative top-20 mx-auto p-5 border w-11/12 max-w-md shadow-lg rounded-md bg-white", data: { confirmation_modal_target: "modal" } ) 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") { @title } ( type: "button", class: "text-gray-400 hover:text-gray-600 text-xl", data: { action: "click->confirmation-modal#cancel" } ) { "×" } end # Message p(class: "text-sm text-gray-600 mb-4") { @message } # 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->confirmation-modal#cancel" } ) { @cancel_text } = if @danger "px-4 py-2 text-sm font-medium text-white bg-red-600 border border-transparent rounded-md hover:bg-red-700" else "px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700" end ( type: "button", class: , data: { action: "click->confirmation-modal#confirm" } ) { @confirm_text } end end end end |