Bulk user add on project -> new team member

This commit is contained in:
Dmitriy Zaporozhets 2012-09-07 09:50:35 +03:00
parent 963746f978
commit 61c7449321
3 changed files with 19 additions and 23 deletions

View file

@ -17,13 +17,12 @@ class TeamMembersController < ApplicationController
end end
def create def create
@team_member = UsersProject.new(params[:team_member]) @project.add_users_ids_to_team(
@team_member.project = project params[:user_ids],
if @team_member.save params[:project_access]
)
redirect_to team_project_path(@project) redirect_to team_project_path(@project)
else
render "new"
end
end end
def update def update

View file

@ -1,4 +1,5 @@
%h3= "New Team member" %h3.page_title
= "New Team member(s)"
%hr %hr
= form_for @team_member, as: :team_member, url: project_team_members_path(@project, @team_member) do |f| = form_for @team_member, as: :team_member, url: project_team_members_path(@project, @team_member) do |f|
-if @team_member.errors.any? -if @team_member.errors.any?
@ -7,27 +8,23 @@
- @team_member.errors.full_messages.each do |msg| - @team_member.errors.full_messages.each do |msg|
%li= msg %li= msg
%h6 1. Choose people you want in the team
.clearfix .clearfix
= f.label :user_id, "Name" = f.label :user_ids, "Peolpe"
.input= f.select(:user_id, User.not_in_project(@project).all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, { style: "width:300px" }) .input= select_tag(:user_ids, options_from_collection_for_select(User.not_in_project(@project).all, :id, :name), { class: "xxlarge", multiple: true })
%h6 2. Set access level for them
.clearfix .clearfix
= f.label :project_access, "Project Access" = f.label :project_access, "Project Access"
.input= f.select :project_access, options_for_select(Project.access_options, @team_member.project_access), {}, class: "project-access-select" .input= select_tag :project_access, options_for_select(Project.access_options, @team_member.project_access), class: "project-access-select"
.actions .actions
= f.submit 'Save', class: "btn primary" = f.submit 'Save', class: "btn save-btn"
= link_to "Cancel", team_project_path(@project), class: "btn" = link_to "Cancel", team_project_path(@project), class: "btn cancel-btn"
:css
form select {
width:300px;
}
:javascript :javascript
$('select#team_member_user_id').chosen(); $('select#user_ids').chosen();
$('select#team_member_project_access').chosen(); $('select#project_access').chosen();
//$('select#team_member_repo_access').chosen();
//$('select#team_member_project_access').chosen();

View file

@ -22,8 +22,8 @@ end
Given /^I select "(.*?)" as "(.*?)"$/ do |arg1, arg2| Given /^I select "(.*?)" as "(.*?)"$/ do |arg1, arg2|
user = User.find_by_name(arg1) user = User.find_by_name(arg1)
within "#new_team_member" do within "#new_team_member" do
select user.name, :from => "team_member_user_id" select user.name, :from => "user_ids"
select arg2, :from => "team_member_project_access" select arg2, :from => "project_access"
end end
click_button "Save" click_button "Save"
end end