Rebuild team area

This commit is contained in:
Dmitriy Zaporozhets 2013-03-14 12:38:43 +02:00
parent f4f36f78dd
commit 441d256188
8 changed files with 81 additions and 116 deletions

View file

@ -11,6 +11,12 @@ table {
} }
} }
&.headless {
tr:first-child td{
border-top: 1px solid #CCC;
}
}
th { th {
font-weight: bold; font-weight: bold;
vertical-align: middle; vertical-align: middle;

View file

@ -1,20 +1,4 @@
class Teams::ProjectsController < Teams::ApplicationController class Teams::ProjectsController < Teams::ApplicationController
skip_before_filter :authorize_manage_user_team!, only: [:index]
def index
@projects = user_team.projects
@avaliable_projects = current_user.admin? ? Project.without_team(user_team) : current_user.owned_projects.without_team(user_team)
end
def new
user_team
@avaliable_projects = current_user.owned_projects.scoped
@avaliable_projects = @avaliable_projects.without_team(user_team) if user_team.projects.any?
redirect_to team_projects_path(user_team), notice: "No avalible projects." unless @avaliable_projects.any?
end
def create def create
redirect_to :back if params[:project_ids].blank? redirect_to :back if params[:project_ids].blank?
@ -28,7 +12,7 @@ class Teams::ProjectsController < Teams::ApplicationController
# Assign projects to team # Assign projects to team
user_team.assign_to_projects(project_ids, access) user_team.assign_to_projects(project_ids, access)
redirect_to team_projects_path(user_team), notice: 'Team of users was successfully assigned to projects.' redirect_to edit_team_path(user_team), notice: 'Team of users was successfully assigned to projects.'
end end
def edit def edit
@ -37,7 +21,7 @@ class Teams::ProjectsController < Teams::ApplicationController
def update def update
if user_team.update_project_access(team_project, params[:greatest_project_access]) if user_team.update_project_access(team_project, params[:greatest_project_access])
redirect_to team_projects_path(user_team), notice: 'Access was successfully updated.' redirect_to edit_team_path(user_team), notice: 'Access was successfully updated.'
else else
render :edit render :edit
end end
@ -53,5 +37,4 @@ class Teams::ProjectsController < Teams::ApplicationController
def team_project def team_project
@project ||= user_team.projects.find_with_namespace(params[:id]) @project ||= user_team.projects.find_with_namespace(params[:id])
end end
end end

View file

@ -14,6 +14,8 @@ class TeamsController < ApplicationController
end end
def edit def edit
projects
@avaliable_projects = current_user.admin? ? Project.without_team(user_team) : current_user.owned_projects.without_team(user_team)
end end
def update def update

View file

@ -26,14 +26,8 @@
%span.count= @team.members.count %span.count= @team.members.count
- if can? current_user, :admin_user_team, @team - if can? current_user, :admin_user_team, @team
= nav_link(controller: [:projects]) do
= link_to team_projects_path(@team), class: "team-tab tab" do
Projects
%span.count= @team.projects.count
= nav_link(path: 'teams#edit') do = nav_link(path: 'teams#edit') do
= link_to edit_team_path(@team), class: "stat-tab tab " do = link_to edit_team_path(@team), class: "stat-tab tab " do
%i.icon-edit Settings
Edit Team
.content= yield .content= yield

View file

@ -5,7 +5,7 @@
(#{projects.count}) (#{projects.count})
- if can? current_user, :manage_user_team, @team - if can? current_user, :manage_user_team, @team
%span.pull-right %span.pull-right
= link_to new_team_project_path(@team), class: "btn btn-tiny info" do = link_to edit_team_path(@team), class: "btn btn-tiny info" do
%i.icon-plus %i.icon-plus
Assign Project Assign Project
%ul.well-list %ul.well-list

View file

@ -1,34 +1,73 @@
%h3.page_title= "Edit Team #{@team.name}"
%hr
.row .row
.span7 .span3
= form_for @team, url: team_path(@team) do |f| %ul.nav.nav-pills.nav-stacked
- if @team.errors.any? %li.active
.alert.alert-error = link_to 'Projects', '#tab-projects', 'data-toggle' => 'tab'
%span= @team.errors.full_messages.first %li
.clearfix = link_to 'Edit Team', '#tab-edit', 'data-toggle' => 'tab'
= f.label :name do %li
Team name is = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab'
.input
= f.text_field :name, placeholder: "Ex. OpenSource", class: "xlarge left"
.clearfix.team-description-holder .span9
= f.label :description, "Details" .tab-content
.input .tab-pane.active#tab-projects
= f.text_area :description, maxlength: 250, class: "xlarge js-gfm-input", rows: 4 .ui-box
%h5.title Projects
%ul.well-list
- @projects.each do |project|
%li
- if project.public
%i.icon-share
- else
%i.icon-lock.cgreen
= link_to project.name_with_namespace, project
.pull-right
= link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn btn-small"
= link_to 'Relegate', team_project_path(@team, project), confirm: 'Remove project from team and move to global namespace. Are you sure?', method: :delete, class: "btn btn-remove small"
.form-holder
= form_tag team_projects_path(@team), id: "assign_projects", class: "bulk_import", method: :post do
%table.headless
%tr
%td= select_tag :project_ids, options_from_collection_for_select(@avaliable_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span4'
%td= select_tag :greatest_project_access, options_for_select(UserTeam.access_roles), {class: "project-access-select chosen" }
%td= submit_tag 'Add Project', class: "btn btn-create", id: :assign_projects_to_team
.clearfix
= f.label :path do
Team path is
.input
= f.text_field :path, placeholder: "opensource", class: "xlarge left"
.form-actions .tab-pane#tab-edit
= f.submit 'Save team changes', class: "btn btn-primary" .ui-box
.span5 %h5.title Edit Team
.ui-box %div.form-holder
%h5.title Remove team = form_for @team, url: team_path(@team) do |f|
.padded.bgred - if @team.errors.any?
%p .alert.alert-error
Removed team can not be restored! %span= @team.errors.full_messages.first
= link_to 'Remove team', team_path(@team), method: :delete, confirm: "You are sure?", class: "btn btn-remove btn-small" .clearfix
= f.label :name do
Team name is
.input
= f.text_field :name, placeholder: "Ex. OpenSource", class: "xlarge left"
.clearfix.team-description-holder
= f.label :description, "Details"
.input
= f.text_area :description, maxlength: 250, class: "xlarge js-gfm-input", rows: 4
.clearfix
= f.label :path do
Team path is
.input
= f.text_field :path, placeholder: "opensource", class: "xlarge left"
.form-actions
= f.submit 'Save team changes', class: "btn btn-primary"
.tab-pane#tab-remove
.ui-box.ui-box-danger
%h5.title Remove team
.ui-box-body
%p
Remove of team will cause removing members access to projects.
%p
%strong Removed team can not be restored!
= link_to 'Remove team', team_path(@team), method: :delete, confirm: "You are sure?", class: "btn btn-remove btn-small"

View file

@ -1,36 +0,0 @@
%h3.page_title
Assigned projects (#{@team.projects.count})
%small
Read more about project permissions
%strong= link_to "here", help_permissions_path, class: "vlink"
- if current_user.can?(:manage_user_team, @team) && @avaliable_projects.any?
%span.pull-right
= link_to new_team_project_path(@team), class: "btn btn-primary small grouped", title: "New Team Member" do
Assign project to Team
%hr
- if @team.projects.present?
%table.projects-table
%thead
%tr
%th Project name
%th Max access
- if current_user.can?(:admin_user_team, @team)
%th.span3
- @team.projects.each do |project|
%tr.project
%td
= link_to project.name_with_namespace, project_path(project)
%td
%span= @team.human_max_project_access(project)
- if current_user.can?(:admin_user_team, @team)
%td.bgred
= link_to 'Edit max access', edit_team_project_path(@team, project), class: "btn btn-small"
= link_to 'Relegate', team_project_path(@team, project), confirm: 'Remove project from team and move to global namespace. Are you sure?', method: :delete, class: "btn btn-remove small"
- else
%p.nothing_here_message This team has no projects yet

View file

@ -1,23 +0,0 @@
%h3.page_title
Team: #{@team.name}
%fieldset
%legend Projects (#{@team.projects.count})
= form_tag team_projects_path(@team), id: "assign_projects", class: "bulk_import", method: :post do
%table#projects_list
%thead
%tr
%th Project name
%th Max access
%th
- @team.projects.each do |project|
%tr.project
%td
= link_to project.name_with_namespace, team_project_path(@team, project)
%td
%span= @team.human_max_project_access(project)
%td
%tr
%td= select_tag :project_ids, options_from_collection_for_select(@avaliable_projects , :id, :name_with_namespace), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5'
%td= select_tag :greatest_project_access, options_for_select(UserTeam.access_roles), {class: "project-access-select chosen span3" }
%td= submit_tag 'Add Project', class: "btn btn-create", id: :assign_projects_to_team