Class: EasyAdmin::Profile::ProfileTabComponent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- EasyAdmin::Profile::ProfileTabComponent
- Defined in:
- app/components/easy_admin/profile/profile_tab_component.rb
Instance Method Summary collapse
-
#initialize(user:) ⇒ ProfileTabComponent
constructor
A new instance of ProfileTabComponent.
- #view_template ⇒ Object
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:) ⇒ ProfileTabComponent
Returns a new instance of ProfileTabComponent.
4 5 6 |
# File 'app/components/easy_admin/profile/profile_tab_component.rb', line 4 def initialize(user:) @user = user end |
Instance Method Details
#view_template ⇒ Object
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 73 74 75 76 77 |
# File 'app/components/easy_admin/profile/profile_tab_component.rb', line 8 def view_template div do # Section header div(class: "mb-6") do h2(class: "text-lg font-medium text-gray-900") { "Profile Information" } p(class: "text-sm text-gray-600 mt-1") { "Update your personal information" } end # Profile form form(action: EasyAdmin::Engine.routes.url_helpers.update_profile_path, method: :patch) do # Rails CSRF token input(type: "hidden", name: "authenticity_token", value: helpers.form_authenticity_token) if helpers.respond_to?(:form_authenticity_token) # Rails method spoofing for PATCH input(type: "hidden", name: "_method", value: "patch") div(class: "space-y-6") do # First Name div do label(for: "admin_user_first_name", class: "block text-sm font-medium text-gray-700 mb-2") { "First Name" } input( type: "text", name: "admin_user[first_name]", id: "admin_user_first_name", value: @user.first_name, 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 your first name" ) render_field_errors(@user, :first_name) end # Last Name div do label(for: "admin_user_last_name", class: "block text-sm font-medium text-gray-700 mb-2") { "Last Name" } input( type: "text", name: "admin_user[last_name]", id: "admin_user_last_name", value: @user.last_name, 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 your last name" ) render_field_errors(@user, :last_name) end # Email div do label(for: "admin_user_email", class: "block text-sm font-medium text-gray-700 mb-2") { "Email" } input( type: "email", name: "admin_user[email]", id: "admin_user_email", value: @user.email, 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 your email address" ) render_field_errors(@user, :email) end # Submit button div do input( type: "submit", value: "Update Profile", class: "bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors cursor-pointer" ) end end end end end |