Commit c5a48a6a9017d8e138564624a15427b8929606f3

Authored by Dmitriy Zaporozhets
1 parent fa8c0c78

add users to project from admin area easily

app/controllers/admin/projects_controller.rb
... ... @@ -9,6 +9,12 @@ class Admin::ProjectsController < ApplicationController
9 9  
10 10 def show
11 11 @admin_project = Project.find_by_code(params[:id])
  12 +
  13 + @users = if @admin_project.users.empty?
  14 + User
  15 + else
  16 + User.not_in_project(@admin_project)
  17 + end.all
12 18 end
13 19  
14 20 def new
... ... @@ -19,11 +25,6 @@ class Admin::ProjectsController < ApplicationController
19 25 @admin_project = Project.find_by_code(params[:id])
20 26 end
21 27  
22   - def team
23   - @admin_project = Project.find_by_code(params[:id])
24   - @users = User.not_in_project(@admin_project).all
25   - end
26   -
27 28 def team_update
28 29 @admin_project = Project.find_by_code(params[:id])
29 30  
... ...
app/views/admin/projects/show.html.haml
... ... @@ -38,6 +38,23 @@
38 38  
39 39 %h2 Team
40 40  
  41 + = form_tag team_update_admin_project_path(@admin_project), :class => "bulk_import", :method => :put do
  42 + %table
  43 + %thead
  44 + %tr
  45 + %th Users
  46 + %th Project Access:
  47 + %th Repo Access:
  48 +
  49 + %tr
  50 + %td= select_tag :user_ids, options_from_collection_for_select(@users , :id, :name), :multiple => true
  51 + %td= select_tag :project_access, options_for_select(Project.access_options), :class => "project-access-select"
  52 + %td= select_tag :repo_access, options_for_select(Repository.access_options), :class => "repo-access-select"
  53 +
  54 + %tr
  55 + %td{ :colspan => 3 }
  56 + = submit_tag 'Add', :class => "positive-button"
  57 +
41 58 %table.round-borders
42 59 %thead
43 60 %tr
... ... @@ -52,9 +69,22 @@
52 69 %td
53 70 = link_to tm.user_name, admin_team_member_path(tm)
54 71 %td= time_ago_in_words(tm.updated_at) + " ago"
55   - %td= select_tag :project_access, options_for_select(Project.access_options, tm.project_access), :class => "project-access-select", :disabled => :disabled
56   - %td= select_tag :repo_access, options_for_select(Repository.access_options, tm.repo_access), :class => "repo-access-select", :disabled => :disabled
  72 + %td= select_tag :tm_project_access, options_for_select(Project.access_options, tm.project_access), :class => "project-access-select", :disabled => :disabled
  73 + %td= select_tag :tm_repo_access, options_for_select(Repository.access_options, tm.repo_access), :class => "repo-access-select", :disabled => :disabled
57 74 %td= link_to 'Destroy', admin_team_member_path(tm), :confirm => 'Are you sure?', :method => :delete
58 75  
59   - = link_to 'New Team Member', new_admin_team_member_path(:team_member => {:project_id => @admin_project.id}), :class => "grey-button"
60   - .right= link_to 'Bulk Import', team_admin_project_path(@admin_project), :class => "grey-button"
  76 +:css
  77 + form select {
  78 + width:150px;
  79 + }
  80 +
  81 + #user_ids {
  82 + width:300px;
  83 + }
  84 +
  85 +
  86 +:javascript
  87 + $('select#user_ids').chosen();
  88 + $('select#repo_access').chosen();
  89 + $('select#project_access').chosen();
  90 +
... ...
app/views/admin/projects/team.html.haml
... ... @@ -1,30 +0,0 @@
1   -= form_tag team_update_admin_project_path(@admin_project), :class => "bulk_import", :method => :put do
2   - .span-6
3   - %b Project Access:
4   - .span-6
5   - = select_tag :project_access, options_for_select(Project.access_options), :class => "project-access-select"
6   -
7   - .span-6
8   - %b Repository Access:
9   - .span-6
10   - = select_tag :repo_access, options_for_select(Repository.access_options), :class => "repo-access-select"
11   -
12   - %br
13   - = select_tag :user_ids, options_from_collection_for_select(@users , :id, :name), :multiple => true
14   -
15   - %br
16   - .clear
17   - %br
18   - .actions
19   - = submit_tag 'Save', :class => "grey-button"
20   -
21   -:css
22   - form select {
23   - width:300px;
24   - }
25   -
26   -
27   -:javascript
28   - $('select#user_ids').chosen();
29   - $('select#repo_access').chosen();
30   - $('select#project_access').chosen();