Cleanup groups view on profile page
This commit is contained in:
parent
b080fb5fda
commit
bf6a31a032
3 changed files with 32 additions and 17 deletions
|
@ -126,6 +126,9 @@ table {
|
|||
td.odd {
|
||||
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 {
|
||||
font-weight: bold;
|
||||
|
|
|
@ -46,20 +46,19 @@ class HomeController < ApplicationController
|
|||
@financial_transactions = @financial_transactions.where("note LIKE ?", "%#{params[:query]}%") if params[:query].present?
|
||||
|
||||
else
|
||||
redirect_to root_path, :alert => I18n.t('home.no_ordergroups')
|
||||
redirect_to root_path, alert: I18n.t('home.no_ordergroups')
|
||||
end
|
||||
end
|
||||
|
||||
# cancel personal memberships direct from the myProfile-page
|
||||
def cancel_membership
|
||||
membership = Membership.find(params[:membership_id])
|
||||
if membership.user == current_user
|
||||
membership.destroy
|
||||
flash[:notice] = I18n.t('home.ordergroup_cancelled', :group => membership.group.name)
|
||||
if params[:membership_id]
|
||||
membership = @current_user.memberships.find!(params[:membership_id])
|
||||
else
|
||||
flash[:error] = I18n.t('errors.general')
|
||||
membership = @current_user.memberships.find_by_group_id!(params[:group_id])
|
||||
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
|
||||
|
|
|
@ -9,15 +9,28 @@
|
|||
= render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => 'store-only'}
|
||||
.form-actions
|
||||
= submit_tag t('ui.save'), class: 'btn'
|
||||
|
||||
.span5
|
||||
%h2= t '.groups.title'
|
||||
%table.table.table-striped
|
||||
- @current_user.memberships.each do |membership|
|
||||
- if @current_user.ordergroup
|
||||
%h3= User.human_attribute_name(:ordergroup, count: 1)
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
%td= membership.group.name
|
||||
%td= link_to t('.groups.invite'), new_invite_path(id: membership.group_id),
|
||||
remote: true, class: 'btn btn-success btn-small'
|
||||
- if membership.group.type != 'Ordergroup'
|
||||
%td= link_to t('.groups.cancel'), cancel_membership_path(membership_id: membership),
|
||||
:data => {confirm: t('.groups.cancel_confirm')}, method: :post,
|
||||
class: 'btn btn-danger btn-small'
|
||||
%td
|
||||
- if @current_user.ordergroup.users.count > 1
|
||||
%strong= @current_user.ordergroup.name + ':'
|
||||
= @current_user.ordergroup.users.map{|u| show_user u}.join(', ')
|
||||
- else
|
||||
= @current_user.ordergroup.name
|
||||
%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'
|
||||
|
|
Loading…
Reference in a new issue