summaryrefslogtreecommitdiff
path: root/app/views/admin/users/_form.html.haml
blob: b96c2e74111ee68257300816cd212c0558ab6b5c (plain)
1
2
3
4
5
6
7
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
.user_new
  = form_for [:admin, @user], html: { class: 'form-horizontal fieldset-form' } do |f|
    -if @user.errors.any?
      #error_explanation
        .alert.alert-danger
          - @user.errors.full_messages.each do |msg|
            %p= msg

    %fieldset
      %legend 账号
      .form-group
        = f.label :name, "姓名", class: 'control-label'
        .col-sm-10
          = f.text_field :name, required: true, autocomplete: "off", class: 'form-control'
          %span.help-inline * 必须填写
      .form-group
        = f.label :username, "用户名", class: 'control-label'
        .col-sm-10
          = f.text_field :username, required: true, autocomplete: "off", class: 'form-control'
          %span.help-inline * 必须填写
      .form-group
        = f.label :email, "电子邮箱", class: 'control-label'
        .col-sm-10
          = f.text_field :email, required: true, autocomplete: "off", class: 'form-control'
          %span.help-inline * 必须填写

    - if @user.new_record?
      %fieldset
        %legend 密码
        .form-group
          = f.label :password, "密码", class: 'control-label'
          .col-sm-10
            %strong
              重置链接将自动生成临时密码发送给用户。
              %br
              用户在第一次登录后需要强制修改密码
    - else
      %fieldset
        %legend 密码
        .form-group
          = f.label :password, "密码", class: 'control-label'
          .col-sm-10= f.password_field :password, disabled: f.object.force_random_password, class: 'form-control'
        .form-group
          = f.label :password_confirmation, "确认密码", class: 'control-label'
          .col-sm-10= f.password_field :password_confirmation, disabled: f.object.force_random_password, class: 'form-control'

    %fieldset
      %legend 权限
      .form-group
        = f.label :projects_limit, "项目限制", class: 'control-label'
        .col-sm-10= f.number_field :projects_limit, class: 'form-control'

      .form-group
        = f.label :can_create_group, "是否可以创建群组", class: 'control-label'
        .col-sm-10= f.check_box :can_create_group

      .form-group
        = f.label :admin, "管理", class: 'control-label'
        - if current_user == @user
          .col-sm-10= f.check_box :admin, disabled: true
          .col-sm-10 不能删除自己的管理权限
        - else
          .col-sm-10= f.check_box :admin

      .form-group
        = f.label :external, class: 'control-label'
        .col-sm-10= f.check_box :external
        .col-sm-10 External users cannot see internal or private projects unless access is explicitly granted. Also, external users cannot create projects or groups.

    %fieldset
      %legend 个人资料
      .form-group
        = f.label :avatar, "头像", class: 'control-label'
        .col-sm-10
          = f.file_field :avatar

      .form-group
        = f.label :skype, class: 'control-label'
        .col-sm-10= f.text_field :skype, class: 'form-control'
      .form-group
        = f.label :linkedin, "领英", class: 'control-label'
        .col-sm-10= f.text_field :linkedin, class: 'form-control'
      .form-group
        = f.label :twitter, "推特", class: 'control-label'
        .col-sm-10= f.text_field :twitter, class: 'form-control'
      .form-group
        = f.label :website_url, "网址", class: 'control-label'
        .col-sm-10= f.text_field :website_url, class: 'form-control'

    .form-actions
      - if @user.new_record?
        = f.submit '创建用户', class: "btn btn-create"
        = link_to '取消', admin_users_path, class: "btn btn-cancel"
      - else
        = f.submit '保存修改', class: "btn btn-save"
        = link_to '取消', admin_user_path(@user), class: "btn btn-cancel"