Cleanup groups view on profile page

This commit is contained in:
wvengen 2014-12-16 21:09:04 +01:00
parent b080fb5fda
commit bf6a31a032
3 changed files with 32 additions and 17 deletions

View file

@ -126,6 +126,9 @@ table {
td.odd { td.odd {
background-color: @tableBackgroundAccent; background-color: @tableBackgroundAccent;
} }
th.left, td.left { text-align: left; }
th.right, td.right { text-align: right; }
th.center, td.center { text-align: center; }
td.main_info { td.main_info {
font-weight: bold; font-weight: bold;

View file

@ -46,20 +46,19 @@ class HomeController < ApplicationController
@financial_transactions = @financial_transactions.where("note LIKE ?", "%#{params[:query]}%") if params[:query].present? @financial_transactions = @financial_transactions.where("note LIKE ?", "%#{params[:query]}%") if params[:query].present?
else else
redirect_to root_path, :alert => I18n.t('home.no_ordergroups') redirect_to root_path, alert: I18n.t('home.no_ordergroups')
end end
end end
# cancel personal memberships direct from the myProfile-page # cancel personal memberships direct from the myProfile-page
def cancel_membership def cancel_membership
membership = Membership.find(params[:membership_id]) if params[:membership_id]
if membership.user == current_user membership = @current_user.memberships.find!(params[:membership_id])
membership.destroy
flash[:notice] = I18n.t('home.ordergroup_cancelled', :group => membership.group.name)
else else
flash[:error] = I18n.t('errors.general') membership = @current_user.memberships.find_by_group_id!(params[:group_id])
end end
redirect_to my_profile_path membership.destroy
redirect_to my_profile_path, notice: I18n.t('home.ordergroup_cancelled', :group => membership.group.name)
end end
end end

View file

@ -9,15 +9,28 @@
= render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => 'store-only'} = render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => 'store-only'}
.form-actions .form-actions
= submit_tag t('ui.save'), class: 'btn' = submit_tag t('ui.save'), class: 'btn'
.span5 .span5
%h2= t '.groups.title' - if @current_user.ordergroup
%table.table.table-striped %h3= User.human_attribute_name(:ordergroup, count: 1)
- @current_user.memberships.each do |membership| %table.table.table-striped
%tr %tr
%td= membership.group.name %td
%td= link_to t('.groups.invite'), new_invite_path(id: membership.group_id), - if @current_user.ordergroup.users.count > 1
remote: true, class: 'btn btn-success btn-small' %strong= @current_user.ordergroup.name + ':'
- if membership.group.type != 'Ordergroup' = @current_user.ordergroup.users.map{|u| show_user u}.join(', ')
%td= link_to t('.groups.cancel'), cancel_membership_path(membership_id: membership), - else
:data => {confirm: t('.groups.cancel_confirm')}, method: :post, = @current_user.ordergroup.name
class: 'btn btn-danger btn-small' %td.right
= link_to t('.groups.invite'), new_invite_path(id: @current_user.ordergroup),
remote: true, class: 'btn btn-success btn-small'
- if @current_user.workgroups.count > 0
%h3= User.human_attribute_name(:workgroup, count: 2)
%table.table.table-striped
- @current_user.workgroups.each do |workgroup|
%tr
%td= workgroup.name
%td.right
= link_to t('.groups.cancel'), cancel_membership_path(group_id: workgroup),
:data => {confirm: t('.groups.cancel_confirm')}, method: :post,
class: 'btn btn-danger btn-small'