added group memberships modal

This commit is contained in:
nilsding 2015-01-14 07:07:40 +01:00
parent f907c4b5a8
commit c99fe89235
6 changed files with 31 additions and 0 deletions

View File

@ -94,6 +94,12 @@ class User < ActiveRecord::Base
friends.include? target_user friends.include? target_user
end end
# @param group [Group]
# @return [Boolean] true if +self+ is a member of +group+
def member_of?(group)
group_memberships.pluck(:group_id).include? group.id
end
# answers a question # answers a question
# @param question [Question] the question to answer # @param question [Question] the question to answer
# @param content [String] the answer content # @param content [String] the answer content

View File

@ -20,6 +20,9 @@
%a{href: '#', name: 'user-action', data: { action: :block, type: type, target: user.screen_name }} %a{href: '#', name: 'user-action', data: { action: :block, type: type, target: user.screen_name }}
%i.fa.fa-minus-circle %i.fa.fa-minus-circle
Block Block
%li
%a{href: '#', data: { target: "#modal-group-memberships", toggle: :modal }}
Manage group memberships
%li %li
%a{href: '#', data: { action: 'report-user', target: user.screen_name }} %a{href: '#', data: { action: 'report-user', target: user.screen_name }}
%i.fa.fa-exclamation-triangle %i.fa.fa-exclamation-triangle

View File

@ -0,0 +1,16 @@
#modal-group-memberships.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "modal-group-memberships-label", :role => "dialog", :tabindex => "-1"}
.modal-dialog
.modal-content
.modal-header
%button.close{"data-dismiss" => "modal", :type => "button"}
%span{"aria-hidden" => "true"} ×
%span.sr-only Close
%h4#modal-group-memberships-label.modal-title Manage group memberships
.modal-body
- current_user.groups.each do |group|
%label
%input{type: :checkbox, name: 'gm-group-check', data: { group_name: group.name }, checked: @user.member_of?(group)}
= group.display_name
.modal-footer
%button.btn.btn-default{"data-dismiss" => "modal", :type => "button"} Cancel
%button.btn.btn-primary{name: 'gm-save', :type => "button"} Save

View File

@ -15,3 +15,5 @@
= group.display_name = group.display_name
.visible-xs= render 'shared/links' .visible-xs= render 'shared/links'
- if user_signed_in?
= render 'user/modal_group_memberships'

View File

@ -15,3 +15,5 @@
%button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @answers.current_page }} %button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @answers.current_page }}
Load more Load more
.visible-xs= render 'shared/links' .visible-xs= render 'shared/links'
- if user_signed_in?
= render 'user/modal_group_memberships'

View File

@ -17,3 +17,5 @@
%button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @users.current_page }} %button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @users.current_page }}
Load more Load more
.visible-xs= render 'shared/links' .visible-xs= render 'shared/links'
- if user_signed_in?
= render 'user/modal_group_memberships'