Class: EasyAdmin::Profile::ChangePasswordModalComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/easy_admin/profile/change_password_modal_component.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#easy_admin_url_helpers, #helpers, #rails_url_helpers

Methods included from EasyAdmin::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(user:) ⇒ ChangePasswordModalComponent

Returns a new instance of ChangePasswordModalComponent.



4
5
6
# File 'app/components/easy_admin/profile/change_password_modal_component.rb', line 4

def initialize(user:)
  @user = user
end

Instance Method Details

#view_templateObject



8
9
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
68
69
70
71
72
# File 'app/components/easy_admin/profile/change_password_modal_component.rb', line 8

def view_template
  div do
    p(class: "text-sm text-gray-600 mb-6") { "Update your password to keep your account secure" }
    
    form(action: EasyAdmin::Engine.routes.url_helpers.update_password_path, method: :patch, data: { turbo_frame: "_top" }) do
      input(type: "hidden", name: "authenticity_token", value: helpers.form_authenticity_token) if helpers.respond_to?(:form_authenticity_token)
      input(type: "hidden", name: "_method", value: "patch")
      
      div(class: "space-y-4") do
        # Current Password
        div do
          label(for: "admin_user_current_password", class: "block text-sm font-medium text-gray-700 mb-2") { "Current Password" }
          input(
            type: "password",
            name: "admin_user[current_password]",
            id: "admin_user_current_password",
            class: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
            placeholder: "Enter current password",
            required: true
          )
        end
        
        # New Password
        div do
          label(for: "admin_user_password", class: "block text-sm font-medium text-gray-700 mb-2") { "New Password" }
          input(
            type: "password",
            name: "admin_user[password]",
            id: "admin_user_password",
            class: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
            placeholder: "Enter new password",
            required: true
          )
        end
        
        # Confirm Password
        div do
          label(for: "admin_user_password_confirmation", class: "block text-sm font-medium text-gray-700 mb-2") { "Confirm New Password" }
          input(
            type: "password",
            name: "admin_user[password_confirmation]",
            id: "admin_user_password_confirmation",
            class: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
            placeholder: "Confirm new password",
            required: true
          )
        end
        
        # Submit button
        div(class: "flex space-x-3 pt-4") do
          input(
            type: "submit",
            value: "Update Password",
            class: "flex-1 bg-blue-600 text-white py-2 px-4 rounded-lg hover:bg-blue-700 transition-colors cursor-pointer"
          )
          button(
            type: "button",
            class: "flex-1 bg-gray-300 text-gray-700 py-2 px-4 rounded-lg hover:bg-gray-400 transition-colors",
            data: { action: "click->modal#close" }
          ) { "Cancel" }
        end
      end
    end
  end
end