|
| 1 | +module Avo |
| 2 | + module Resources |
| 3 | + class User < Resource |
| 4 | + def initialize |
| 5 | + @title = :name |
| 6 | + @search = [:id, :first_name, :last_name] |
| 7 | + @includes = :posts |
| 8 | + @has_devise_password = true |
| 9 | + end |
| 10 | + |
| 11 | + fields do |
| 12 | + id |
| 13 | + gravatar :email, link_to_resource: true |
| 14 | + heading 'User information' |
| 15 | + text :first_name, required: true, placeholder: 'John' |
| 16 | + text :last_name, required: true, placeholder: 'Doe' |
| 17 | + text :email, name: 'User Email', required: true |
| 18 | + boolean :active, name: 'Is active', show_on: :show |
| 19 | + file :cv, name: 'CV' |
| 20 | + boolean :is_admin?, name: 'Is admin', only_on: :index |
| 21 | + boolean_group :roles, options: { admin: 'Administrator', manager: 'Manager', editor: 'Editor' } |
| 22 | + date :birthday, first_day_of_week: 1, picker_format: 'F J Y', format: 'MMMM Do YYYY', placeholder: 'Feb 24th 1955', required: true |
| 23 | + text :is_writer, format_using: -> (value) { value.truncate 3 }, hide_on: :edit do |model, resource, view, field| |
| 24 | + model.posts.to_a.count > 0 ? 'yes' : 'no' |
| 25 | + end |
| 26 | + |
| 27 | + password :password, name: 'User Password', required: false, except_on: :forms, help: 'You may verify the password strength <a href="http://www.passwordmeter.com/">here</a>.' |
| 28 | + password :password_confirmation, name: 'Password confirmation', required: false |
| 29 | + |
| 30 | + heading '<div class="text-gray-300 uppercase font-bold">DEV</div>', as_html: true |
| 31 | + |
| 32 | + hidden :team_id, default: 0 # For testing purposes |
| 33 | + |
| 34 | + has_and_belongs_to_many :projects |
| 35 | + has_many :posts |
| 36 | + end |
| 37 | + |
| 38 | + use_action Avo::Actions::MarkInactive |
| 39 | + end |
| 40 | + end |
| 41 | +end |
0 commit comments