Sha256: 57f6b360c4ba396e267b847c85b0ae9c0f2cf63840fef4d15d631b91662ad537

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

Trestle.resource(:<%= plural_name %>, model: <%= model %>, scope: Auth) do
  menu do
    group :configuration, priority: :last do
      item :<%= plural_name %>, icon: "fa fa-users"
    end
  end

  table do
    column :avatar, header: false do |administrator|
      avatar_for(administrator)
    end
    column :email, link: true
    <%- unless devise? -%>
    column :first_name
    column :last_name
    <%- end -%>
    actions do |a|
      a.delete unless a.instance == current_user
    end
  end

  form do |administrator|
    text_field :email

    <%- unless devise? -%>
    row do
      col(sm: 6) { text_field :first_name }
      col(sm: 6) { text_field :last_name }
    end

    <%- end -%>
    row do
      col(sm: 6) { password_field :password }
      col(sm: 6) { password_field :password_confirmation }
    end
  end
  <%- if devise? -%>

  update_instance do |instance, attrs|
    if attrs[:password].blank?
      attrs.delete(:password)
      attrs.delete(:password_confirmation) if attrs[:password_confirmation].blank?
    end

    instance.assign_attributes(attrs)
  end

  after_action on: :update do
    if Devise.sign_in_after_reset_password && instance == current_user
      login!(instance)
    end
  end
  <%- end -%>
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trestle-auth-0.4.0 lib/generators/trestle/auth/admin/templates/admin.rb.erb