diff options
-rw-r--r-- | app/assets/javascripts/main.js.coffee | 4 | ||||
-rw-r--r-- | app/controllers/teams/members_controller.rb | 9 | ||||
-rw-r--r-- | app/views/teams/members/_show.html.haml | 36 |
3 files changed, 28 insertions, 21 deletions
diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 5aaea50cf21..d789f54a4e6 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -49,6 +49,10 @@ $ -> # Bottom tooltip $('.has_bottom_tooltip').tooltip(placement: 'bottom') + # Form submitter + $('.trigger-submit').on 'change', -> + $(@).parents('form').submit() + # Flash if (flash = $("#flash-container")).length > 0 flash.click -> $(@).slideUp("slow") diff --git a/app/controllers/teams/members_controller.rb b/app/controllers/teams/members_controller.rb index db218b8ca5e..ead62e13afa 100644 --- a/app/controllers/teams/members_controller.rb +++ b/app/controllers/teams/members_controller.rb @@ -27,7 +27,13 @@ class Teams::MembersController < Teams::ApplicationController end def update - options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]} + member_params = params[:team_member] + + options = { + default_projects_access: member_params[:permission], + group_admin: member_params[:group_admin] + } + if user_team.update_membership(team_member, options) redirect_to team_members_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users." else @@ -45,5 +51,4 @@ class Teams::MembersController < Teams::ApplicationController def team_member @member ||= user_team.members.find_by_username(params[:id]) end - end diff --git a/app/views/teams/members/_show.html.haml b/app/views/teams/members/_show.html.haml index 4a0287dee48..94d2fd50fe8 100644 --- a/app/views/teams/members/_show.html.haml +++ b/app/views/teams/members/_show.html.haml @@ -10,23 +10,21 @@ %br %small.cgray= user.email - .span6.pull-right + .span4 - if allow_admin - .left.span2 - = form_for(member, as: :team_member, url: team_member_path(@team, user)) do |f| - = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium project-access-select span2" - .left.span2 - %span - - if @team.admin?(user) - %i.icon-check - Admin access - .pull-right - - if current_user == user - %span.btn.disabled This is you! - - if @team.owner == user - %span.btn.disabled Owner - - elsif user.blocked - %span.btn.disabled.blocked Blocked - - elsif allow_admin - = link_to team_member_path(@team, user), confirm: remove_from_user_team_message(@team, user), method: :delete, class: "btn-tiny btn btn-remove" do - %i.icon-minus.icon-white + = form_for(member, as: :team_member, url: team_member_path(@team, user)) do |f| + = f.select :permission, options_for_select(UsersProject.access_roles, @team.default_projects_access(user)), {}, class: "medium trigger-submit" + %br + = label_tag do + = f.check_box :group_admin, class: 'trigger-submit' + %span Admin access + .pull-right + - if current_user == user + %span.btn.disabled This is you! + - if @team.owner == user + %span.btn.disabled Owner + - elsif user.blocked + %span.btn.disabled.blocked Blocked + - elsif allow_admin + = link_to team_member_path(@team, user), confirm: remove_from_user_team_message(@team, user), method: :delete, class: "btn-tiny btn btn-remove" do + %i.icon-minus.icon-white |