simple_teams 0.1.3 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -7
  3. data/app/controllers/simple_teams/accept_invitations_controller.rb +4 -5
  4. data/app/controllers/simple_teams/application_controller.rb +1 -8
  5. data/app/controllers/simple_teams/base_controller.rb +12 -0
  6. data/app/controllers/simple_teams/invitations_controller.rb +2 -2
  7. data/app/controllers/simple_teams/leave_teams_controller.rb +2 -2
  8. data/app/controllers/simple_teams/memberships_controller.rb +2 -2
  9. data/app/controllers/simple_teams/related_members_controller.rb +1 -1
  10. data/app/controllers/simple_teams/teams_controller.rb +1 -1
  11. data/app/forms/application_form.rb +3 -0
  12. data/app/forms/simple_teams/invitation_forms/create.rb +1 -1
  13. data/app/forms/simple_teams/invitation_forms/create_bulk.rb +1 -1
  14. data/app/forms/simple_teams/invitation_forms/update.rb +1 -1
  15. data/app/forms/simple_teams/membership_form.rb +1 -1
  16. data/app/helpers/simple_teams/base_helper.rb +11 -0
  17. data/app/helpers/simple_teams/teams_helper.rb +7 -0
  18. data/app/mailers/simple_teams/application_mailer.rb +1 -1
  19. data/app/models/concerns/simple_teams/member_object.rb +1 -0
  20. data/app/models/simple_teams/ability.rb +2 -2
  21. data/app/notifiers/concerns/simple_teams/invitation_notifier.rb +59 -0
  22. data/app/notifiers/concerns/simple_teams/membership_notifier.rb +63 -0
  23. data/app/notifiers/simple_teams/application_notifier.rb +6 -0
  24. data/app/notifiers/simple_teams/bulk_invitations_notifier.rb +52 -0
  25. data/app/notifiers/simple_teams/invitations/accepted_notifier.rb +16 -0
  26. data/app/notifiers/simple_teams/invitations/created_notifier.rb +16 -0
  27. data/app/notifiers/simple_teams/invitations/destroyed_notifier.rb +16 -0
  28. data/app/notifiers/simple_teams/invitations/updated_notifier.rb +16 -0
  29. data/app/notifiers/simple_teams/memberships/destroyed_notifier.rb +16 -0
  30. data/app/notifiers/simple_teams/memberships/left_notifier.rb +20 -0
  31. data/app/notifiers/simple_teams/memberships/updated_notifier.rb +20 -0
  32. data/app/service_objects/simple_teams/accept_invitation_service.rb +1 -1
  33. data/app/service_objects/simple_teams/leave_team_service.rb +1 -1
  34. data/app/views/simple_teams/_nested_action_breadcrumb.html.erb +8 -0
  35. data/app/views/simple_teams/_roles_field.html.erb +2 -2
  36. data/app/views/simple_teams/invitations/_invitation.html.erb +1 -1
  37. data/app/views/simple_teams/invitations/edit.html.erb +1 -6
  38. data/app/views/simple_teams/invitations/new.html.erb +1 -6
  39. data/app/views/simple_teams/memberships/_membership.html.erb +1 -1
  40. data/app/views/simple_teams/memberships/edit.html.erb +1 -6
  41. data/app/views/simple_teams/teams/_add_member_link.html.erb +1 -1
  42. data/app/views/simple_teams/teams/_dropdown_menu.html.erb +13 -0
  43. data/app/views/simple_teams/teams/_index_breadcrumb.html.erb +7 -0
  44. data/app/views/simple_teams/teams/_members_table.html.erb +1 -1
  45. data/app/views/simple_teams/teams/show.html.erb +6 -33
  46. data/config/locales/simple_teams.en.yml +18 -3
  47. data/config/routes.rb +2 -2
  48. data/lib/simple_teams/engine.rb +5 -0
  49. data/lib/simple_teams/version.rb +1 -1
  50. metadata +79 -38
  51. data/app/controllers/simple_teams/admin/invitations_controller.rb +0 -60
  52. data/app/controllers/simple_teams/admin/memberships_controller.rb +0 -60
  53. data/app/controllers/simple_teams/admin/teams_controller.rb +0 -60
  54. data/app/notifications/application_notification.rb +0 -4
  55. data/app/notifications/simple_teams/bulk_invitations_notification.rb +0 -51
  56. data/app/notifications/simple_teams/invitation_notification.rb +0 -54
  57. data/app/notifications/simple_teams/invitations/accepted_notification.rb +0 -13
  58. data/app/notifications/simple_teams/invitations/created_notification.rb +0 -13
  59. data/app/notifications/simple_teams/invitations/destroyed_notification.rb +0 -13
  60. data/app/notifications/simple_teams/invitations/updated_notification.rb +0 -13
  61. data/app/notifications/simple_teams/membership_notification.rb +0 -58
  62. data/app/notifications/simple_teams/memberships/destroyed_notification.rb +0 -13
  63. data/app/notifications/simple_teams/memberships/left_notification.rb +0 -17
  64. data/app/notifications/simple_teams/memberships/updated_notification.rb +0 -17
  65. data/app/views/simple_teams/admin/invitations/_form.html.erb +0 -62
  66. data/app/views/simple_teams/admin/invitations/_invitation.html.erb +0 -47
  67. data/app/views/simple_teams/admin/invitations/edit.html.erb +0 -10
  68. data/app/views/simple_teams/admin/invitations/index.html.erb +0 -14
  69. data/app/views/simple_teams/admin/invitations/new.html.erb +0 -9
  70. data/app/views/simple_teams/admin/invitations/show.html.erb +0 -10
  71. data/app/views/simple_teams/admin/memberships/_form.html.erb +0 -32
  72. data/app/views/simple_teams/admin/memberships/_membership.html.erb +0 -17
  73. data/app/views/simple_teams/admin/memberships/edit.html.erb +0 -10
  74. data/app/views/simple_teams/admin/memberships/index.html.erb +0 -14
  75. data/app/views/simple_teams/admin/memberships/new.html.erb +0 -9
  76. data/app/views/simple_teams/admin/memberships/show.html.erb +0 -10
  77. data/app/views/simple_teams/admin/teams/_form.html.erb +0 -22
  78. data/app/views/simple_teams/admin/teams/_team.html.erb +0 -7
  79. data/app/views/simple_teams/admin/teams/edit.html.erb +0 -10
  80. data/app/views/simple_teams/admin/teams/index.html.erb +0 -14
  81. data/app/views/simple_teams/admin/teams/new.html.erb +0 -9
  82. data/app/views/simple_teams/admin/teams/show.html.erb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acdf88bfe936ac559c9454125c3219d9eba2e9a8d029cda43ac7d749231ac273
4
- data.tar.gz: 5eb9a31ff2ab4a078e086c80396ad822f0baf718823de36ca3927290ea1b3a2b
3
+ metadata.gz: 567aba40fd5afd3451c19e11fe6eeea9bfe7759a880e44f08de06cf408163d69
4
+ data.tar.gz: 8998c1d483358d8eae9177d2e2f7511fc0548838140943424732fa2188450b84
5
5
  SHA512:
6
- metadata.gz: d5dc54ba9215f56f8161b8b22e7e1b110f5e3a73a74be7ed3e57460dc119e38d1bc323c99e21b7ffa92413a942e05144d13892fc9693da96142b0dcbea969326
7
- data.tar.gz: c345c9fc4fcbedbf30055ff8af61b48751badceebccfd1b36921a08b038c65757f90088fb41032226ea09e9510896e43fa2c968ef30e192decee50cb31dd9ccd
6
+ metadata.gz: 26b0d136ea943750ca8e1db97bba98cdaa182d9eaba09f7c2d3b5d7688b5cac0395bb757b8984e17a3f3a422cf6f71558fa4ac3688d3824c80d8a12eec801a53
7
+ data.tar.gz: 4377afe7493f8a876c52657587f489d16a22aeac639ed46bdd0136a286bf3e836a51b550e77fa2f16da32d2e174a37ef30806497cdf8470fca057a21f3754fb0
data/README.md CHANGED
@@ -1,17 +1,72 @@
1
- # WARNING:
2
- This gem is a work in progress. If you like what we are doing, feel free to watch it for updates, but please do not attempt to use it in production.
3
-
4
1
  # SimpleTeams
5
2
  SimpleTeams is an all-in-one solution for implementing teams quickly in a Ruby on Rails (RoR) application. It follows best practices, using the Rails Engine design pattern for easy configurability, CanCan for authorization, and polymorphic association (like ActiveStorage) to avoid dictating model names.
6
3
 
7
- ## Usage
8
- Pending...
4
+ ## STATUS
5
+ SimpleTeams is actually in use within several client-facing applications. However, the gem is still under development, and notably lacks standalone testing.
6
+
7
+ That said, feel free to try it out, and let us know if you have any comments/questions. Just make sure to test things thoroughly, and be patient with the (sparse) documentation.
9
8
 
10
9
  ## Installation
11
- Pending...
10
+ 1. Add simple\_teams to your Gemfile and run bundle install
11
+
12
+ 2. Add the necessary initializers to your config directory (NEED TO ADD DETAILS)
13
+ a. devise.rb (see devise gem for further details)
14
+ b. simple\_form.rb (see simple\_form gem for further details)
15
+ c. simple\_teams.rb (NEED TO MAKE THIS AN INSTALL SCRIPT)
16
+
17
+ 3. Install the necessary migrations for simple\_teams and it's dependencies
18
+ `
19
+ devise generate User
20
+ rails noticed:install:migrations
21
+ rails simple\_teams:install:migrations
22
+ `
23
+
24
+ 4. Add the SimpleTeams concerns to the desired models. E.g.
25
+ `
26
+ #app/models/user.rb
27
+ class User
28
+ include SimpleTeams::MemberObject
29
+ ...
30
+
31
+ #app/models/Organization.rb
32
+ class Organization
33
+ include SimpleTeams::TeamObject
34
+ ...
35
+ `
36
+
37
+ 5. Make sure to initialize the TeamObject properly via the InitializeTeamService to specify the owner of the team. E.g.
38
+
39
+ `
40
+ #within the create action of app/controllers/organizations_controller.rb
41
+
42
+ def create
43
+ if @organization.update(organization_params)
44
+ SimpleTeams::InitializeTeamService.new(current_user, @organization.team).perform
45
+ redirect_to @organization, ...
46
+ ...
47
+ `
48
+
49
+ ## Usage
50
+ 1. SimpleTeams comes pre-packaged with all of the necessary controllers and views for adding/updating/removing team members. For the default functionality, you can simply link from the teamable object (e.g. the "Organization") to the team for users to view/manage these permissions. E.g.
51
+
52
+ `
53
+ #app/views/organizations/show.html.erb
54
+ ...
55
+ link_to "Organization Roles", simple_teams.team_path(@organization.team)
56
+ ...
57
+ `
58
+
59
+ 2. The breadcrumbs in these views will reference the default routes for the teamable resource automatically. E.g.
60
+ Organizations / Test Organization / Team Members
61
+
62
+ However, you can customize these views, as well, by installing them in your application via the standard Engine functionality (i.e. "rails simple\_teams:install:views")
63
+
64
+ 3. NOTE: NEED TO ADD INSTRUCTIONS REGARDING locale configuration.
12
65
 
13
66
  ## Contributing
14
- Contribution directions go here.
67
+ This gem is still in its initial stages, so it is important to ensure that it grows in the proper directions.
68
+
69
+ That said, contributions are welcome, but please give me a heads up on your ideas (via Github issues) so that we can discuss them beforehand.
15
70
 
16
71
  ## License
17
72
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,6 +1,5 @@
1
1
  module SimpleTeams
2
- class AcceptInvitationsController < ApplicationController
3
- skip_before_action :authenticate_user!
2
+ class AcceptInvitationsController < BaseController
4
3
  before_action :set_invitation
5
4
  before_action :ensure_invitation_token_is_valid
6
5
  before_action :set_team
@@ -12,12 +11,12 @@ module SimpleTeams
12
11
  def create
13
12
  if params[:commit] == "Decline"
14
13
  @invitation.declined!
15
- redirect_to root_path, :notice => "You have declined the invitation to the '#{@team.name}' #{@team.teamable.class.model_name.human}."
14
+ redirect_to main_app.root_path, :notice => "You have declined the invitation to the '#{@team.name}' #{@team.teamable.class.model_name.human}."
16
15
  else
17
16
  if @service_object.valid?
18
17
  @service_object.perform
19
18
 
20
- SimpleTeams::Invitations::AcceptedNotification.with(
19
+ SimpleTeams::Invitations::AcceptedNotifier.with(
21
20
  :team_id => @team.id,
22
21
  :invitation_id => @invitation.id,
23
22
  :user_id => current_user.id,
@@ -26,7 +25,7 @@ module SimpleTeams
26
25
  :user_name => current_user.full_name
27
26
  ).deliver_later(@team.members)
28
27
 
29
- redirect_to url_for(@team.teamable), :notice => "You have accepted the invitation to the '#{@team.name}' #{@team.teamable.class.model_name.human}."
28
+ redirect_to main_app.url_for(@team.teamable), :notice => "You have accepted the invitation to the '#{@team.name}' #{@team.teamable.class.model_name.human}."
30
29
  else
31
30
  render :new
32
31
  end
@@ -1,13 +1,6 @@
1
1
  module SimpleTeams
2
- class ApplicationController < SimpleTeams.parent_controller
2
+ class ApplicationController < ActionController::Base
3
3
  before_action :authenticate_user!
4
4
 
5
- layout SimpleTeams.layout
6
-
7
- def current_ability
8
- SimpleTeams::Ability.new(current_user)
9
- end
10
- helper_method :current_ability
11
-
12
5
  end
13
6
  end
@@ -0,0 +1,12 @@
1
+ module SimpleTeams
2
+ class BaseController < SimpleTeams.parent_controller
3
+
4
+ layout SimpleTeams.layout
5
+
6
+ def current_ability
7
+ SimpleTeams::Ability.new(current_user)
8
+ end
9
+ helper_method :current_ability
10
+
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  module SimpleTeams
2
- class InvitationsController < ApplicationController
2
+ class InvitationsController < BaseController
3
3
  before_action :set_team
4
4
  before_action :set_invitation, except: %i[ new create index]
5
5
 
@@ -60,7 +60,7 @@ module SimpleTeams
60
60
  invitation_email = @invitation.email
61
61
  @invitation.destroy
62
62
 
63
- SimpleTeams::Invitations::DestroyedNotification.with(
63
+ SimpleTeams::Invitations::DestroyedNotifier.with(
64
64
  :team_id => @team.id,
65
65
  :invitation_id => invitation_id,
66
66
  :user_id => current_user.id,
@@ -1,11 +1,11 @@
1
1
  module SimpleTeams
2
- class LeaveTeamsController < ApplicationController
2
+ class LeaveTeamsController < BaseController
3
3
  before_action :set_team
4
4
  before_action :set_service_object
5
5
 
6
6
  def destroy
7
7
  if @service_object.valid? and @service_object.perform
8
- redirect_to root_path, :notice => "You have successfully left the #{@team.name} #{@team.teamable.class.model_name.human}."
8
+ redirect_to main_app.url_for(@team.teamable.class), :notice => "You have successfully left the #{@team.name} #{@team.teamable.class.model_name.human}."
9
9
  else
10
10
  redirect_to team_path(@team), :notice => @service_object.errors[:user_id].first
11
11
  end
@@ -1,5 +1,5 @@
1
1
  module SimpleTeams
2
- class MembershipsController < ApplicationController
2
+ class MembershipsController < BaseController
3
3
  before_action :set_team
4
4
  before_action :set_membership, :except => [:index]
5
5
 
@@ -32,7 +32,7 @@ module SimpleTeams
32
32
 
33
33
  @membership.destroy
34
34
 
35
- SimpleTeams::Memberships::DestroyedNotification.with(
35
+ SimpleTeams::Memberships::DestroyedNotifier.with(
36
36
  :team_id => @team.id,
37
37
  :member_id => member_id,
38
38
  :user_id => current_user.id,
@@ -1,5 +1,5 @@
1
1
  module SimpleTeams
2
- class RelatedMembersController < ApplicationController
2
+ class RelatedMembersController < BaseController
3
3
 
4
4
  def index
5
5
  if params[:term].present?
@@ -1,5 +1,5 @@
1
1
  module SimpleTeams
2
- class TeamsController < ApplicationController
2
+ class TeamsController < BaseController
3
3
  before_action :set_team
4
4
 
5
5
  def show
@@ -0,0 +1,3 @@
1
+ class ApplicationForm
2
+ include ActiveModel::Model
3
+ end
@@ -10,7 +10,7 @@ module SimpleTeams
10
10
  private
11
11
 
12
12
  def generate_notification
13
- SimpleTeams::Invitations::CreatedNotification.with(
13
+ SimpleTeams::Invitations::CreatedNotifier.with(
14
14
  :team_id => team.id,
15
15
  :invitation_id => invitation.id,
16
16
  :user_id => current_user.id,
@@ -112,7 +112,7 @@ module SimpleTeams
112
112
  end
113
113
 
114
114
  def generate_notification
115
- SimpleTeams::BulkInvitationsNotification.with(
115
+ SimpleTeams::BulkInvitationsNotifier.with(
116
116
  :team_id => team.id,
117
117
  :user_id => current_user.id,
118
118
  :team_name => team.name,
@@ -15,7 +15,7 @@ module SimpleTeams
15
15
  private
16
16
 
17
17
  def generate_notification
18
- SimpleTeams::Invitations::UpdatedNotification.with(
18
+ SimpleTeams::Invitations::UpdatedNotifier.with(
19
19
  :team_id => team.id,
20
20
  :invitation_id => invitation.id,
21
21
  :user_id => current_user.id,
@@ -77,7 +77,7 @@ module SimpleTeams
77
77
  end
78
78
 
79
79
  def generate_notification
80
- SimpleTeams::Memberships::UpdatedNotification.with(
80
+ SimpleTeams::Memberships::UpdatedNotifier.with(
81
81
  :team_id => team.id,
82
82
  :member_id => membership.member.id,
83
83
  :user_id => current_user.id,
@@ -0,0 +1,11 @@
1
+ module SimpleTeams
2
+ module BaseHelper
3
+ def team_based_role_name(team, role)
4
+ t "simple_teams.#{team.teamable.class.model_name.plural}.roles.names.#{role}", :default => [t("simple_teams.roles.names.#{role}")]
5
+ end
6
+
7
+ def team_based_role_description(team, role)
8
+ t "simple_teams.#{team.teamable.class.model_name.plural}.roles.descriptions.#{role}", :default => [t("simple_teams.roles.descriptions.#{role}")]
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,11 @@
1
1
  module SimpleTeams
2
2
  module TeamsHelper
3
+ def team_based_role_name(team, role)
4
+ t "simple_teams.#{team.teamable.class.to_s.underscore}.role_names.#{role}", :default => [t("simple_teams.role_names.#{role}")]
5
+ end
6
+
7
+ def team_based_role_description(team, role)
8
+ t "simple_teams.#{team.teamable.class.to_s.underscore}.role_descriptions.#{role}", :default => [t("simple_teams.role_descriptions.#{role}")]
9
+ end
3
10
  end
4
11
  end
@@ -1,6 +1,6 @@
1
1
  module SimpleTeams
2
2
  class ApplicationMailer < ActionMailer::Base
3
- default from: "from@example.com"
3
+ default from: SimpleTeams.from_address
4
4
  layout "mailer"
5
5
  end
6
6
  end
@@ -5,6 +5,7 @@ module SimpleTeams::MemberObject
5
5
  has_many :team_memberships, :class_name => "SimpleTeams::Membership", :foreign_key => :member_id, :dependent => :destroy
6
6
  has_many :teams, :through => :team_memberships, :class_name => "SimpleTeams::Team"
7
7
  has_many :team_members, :through => :teams, :source => :members, :class_name => SimpleTeams.member_class.to_s
8
+ has_many :notifications, as: :recipient, :class_name => "Noticed::Notification", dependent: :destroy
8
9
  end
9
10
 
10
11
  def member_of_team?(team)
@@ -14,11 +14,11 @@ module SimpleTeams
14
14
  end
15
15
 
16
16
  can [:update], Team do |team|
17
- %w"owner administrator".include? user.role_for_team(team)
17
+ %w"owner administrator".include? user.role_for_team(team)
18
18
  end
19
19
 
20
20
  can [:destroy], Team do |team|
21
- %w"owner".include? user.role_for_team(team)
21
+ %w"owner".include? user.role_for_team(team)
22
22
  end
23
23
 
24
24
  # Team Memberships/Invitations
@@ -0,0 +1,59 @@
1
+ module SimpleTeams
2
+ module InvitationNotifier
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ required_params :team_id, :invitation_id, :user_id, :team_name, :invitation_name, :user_name
7
+
8
+ notification_methods do
9
+ def message
10
+ raise NotImplemented
11
+ end
12
+
13
+ def subject
14
+ raise NotImplemented
15
+ end
16
+
17
+ def url
18
+ if team.present? and team.members.include? recipient
19
+ SimpleTeams::Engine.routes.url_helpers.team_path(team)
20
+ end
21
+ end
22
+
23
+ def link_text
24
+ "View Invitations"
25
+ end
26
+
27
+ # Objects
28
+ def team
29
+ Team.find_by(id: params[:team_id])
30
+ end
31
+
32
+ def user
33
+ User.find_by(id: params[:user_id])
34
+ end
35
+
36
+ def invitation
37
+ team.invitations.find_by(id: params[:invitation_id]) if team.present?
38
+ end
39
+
40
+ # Names (fallback)
41
+ def team_name
42
+ team.present? ? team.name : params[:team_name]
43
+ end
44
+
45
+ def invitation_name
46
+ invitation.present? ? invitation.email : params[:invitation_name]
47
+ end
48
+
49
+ def user_name
50
+ if recipient.id == params[:user_id]
51
+ "You"
52
+ else
53
+ user.present? ? user.full_name : params[:user_name]
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,63 @@
1
+ module SimpleTeams
2
+ module MembershipNotifier
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ required_params :team_id, :member_id, :user_id, :team_name, :member_name, :user_name
7
+
8
+ notification_methods do
9
+ def message
10
+ raise NotImplemented
11
+ end
12
+
13
+ def subject
14
+ raise NotImplemented
15
+ end
16
+
17
+ def url
18
+ if team.present? and team.members.include? recipient
19
+ SimpleTeams::Engine.routes.url_helpers.team_path(team)
20
+ end
21
+ end
22
+
23
+ def link_text
24
+ "View Permissions"
25
+ end
26
+
27
+ # Objects
28
+ def team
29
+ Team.find_by(id: params[:team_id])
30
+ end
31
+
32
+ def user
33
+ User.find_by(id: params[:user_id])
34
+ end
35
+
36
+ def member
37
+ team.members.find_by(id: params[:member_id]) if team.present?
38
+ end
39
+
40
+ # Names (fallback)
41
+ def team_name
42
+ team.present? ? team.name : params[:team_name]
43
+ end
44
+
45
+ def member_name
46
+ if recipient.id == params[:member_id]
47
+ "you"
48
+ else
49
+ member.present? ? member.full_name : params[:member_name]
50
+ end
51
+ end
52
+
53
+ def user_name
54
+ if recipient.id == params[:user_id]
55
+ "You"
56
+ else
57
+ user.present? ? user.full_name : params[:user_name]
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,6 @@
1
+ module SimpleTeams
2
+ class ApplicationNotifier < Noticed::Event
3
+ #deliver_by :email, mailer: "NotificationMailer", :method => "notification"
4
+
5
+ end
6
+ end
@@ -0,0 +1,52 @@
1
+ module SimpleTeams
2
+ class BulkInvitationsNotifier < SimpleTeams::ApplicationNotifier
3
+ required_params :team_id, :user_id, :team_name, :user_name, :invitation_names
4
+
5
+ notification_methods do
6
+ def message
7
+ "#{user_name} invited #{invitation_names.to_sentence} to #{team_name}."
8
+ end
9
+
10
+ def subject
11
+ "Users Invited"
12
+ end
13
+
14
+ def url
15
+ if team.present?
16
+ SimpleTeams::Engine.routes.url_helpers.team_path(team)
17
+ end
18
+ end
19
+
20
+ def link_text
21
+ "View Invitations"
22
+ end
23
+
24
+ # Objects
25
+ def team
26
+ Team.find_by(id: params[:team_id])
27
+ end
28
+
29
+ def user
30
+ User.find_by(id: params[:user_id])
31
+ end
32
+
33
+ # Names (fallback)
34
+ def team_name
35
+ team.present? ? team.name : params[:team_name]
36
+ end
37
+
38
+ def invitation_names
39
+ params[:invitation_names]
40
+ end
41
+
42
+ def user_name
43
+ if recipient.id == params[:user_id]
44
+ "You"
45
+ else
46
+ user.present? ? user.full_name : params[:user_name]
47
+ end
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,16 @@
1
+ module SimpleTeams
2
+ class Invitations::AcceptedNotifier < ApplicationNotifier
3
+ include SimpleTeams::InvitationNotifier
4
+
5
+ notification_methods do
6
+ def message
7
+ "#{user_name} accepted the invitation to #{team_name}."
8
+ end
9
+
10
+ def subject
11
+ "Invitation Accepted"
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module SimpleTeams
2
+ class Invitations::CreatedNotifier < ApplicationNotifier
3
+ include SimpleTeams::InvitationNotifier
4
+
5
+ notification_methods do
6
+ def message
7
+ "#{user_name} invited #{invitation_name} to #{team_name}."
8
+ end
9
+
10
+ def subject
11
+ "User Invited"
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module SimpleTeams
2
+ class Invitations::DestroyedNotifier < ApplicationNotifier
3
+ include SimpleTeams::InvitationNotifier
4
+
5
+ notification_methods do
6
+ def message
7
+ "#{user_name} deleted the invitation for #{invitation_name} to #{team_name}."
8
+ end
9
+
10
+ def subject
11
+ "Invitation Deleted"
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module SimpleTeams
2
+ class Invitations::UpdatedNotifier < ApplicationNotifier
3
+ include SimpleTeams::InvitationNotifier
4
+
5
+ notification_methods do
6
+ def message
7
+ "#{user_name} updated the invitation for #{invitation_name} to #{team_name}."
8
+ end
9
+
10
+ def subject
11
+ "Invitation Updated"
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module SimpleTeams
2
+ class Memberships::DestroyedNotifier < ApplicationNotifier
3
+ include SimpleTeams::MembershipNotifier
4
+
5
+ notification_methods do
6
+ def message
7
+ "#{user_name} removed #{member_name} from #{team_name}."
8
+ end
9
+
10
+ def subject
11
+ "Member Removed"
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module SimpleTeams
2
+ class Memberships::LeftNotifier < ApplicationNotifier
3
+ include SimpleTeams::MembershipNotifier
4
+
5
+ notification_methods do
6
+ def message
7
+ if recipient.id == params[:member_id]
8
+ "You left #{team_name}."
9
+ else
10
+ "#{member_name} left #{team_name}."
11
+ end
12
+ end
13
+
14
+ def subject
15
+ "Member Left"
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module SimpleTeams
2
+ class Memberships::UpdatedNotifier < ApplicationNotifier
3
+ include SimpleTeams::MembershipNotifier
4
+
5
+ notification_methods do
6
+ def message
7
+ if recipient.id == params[:member_id]
8
+ "#{user_name} updated your role for #{team_name}."
9
+ else
10
+ "#{user_name} updated the role of #{member_name} for #{team_name}."
11
+ end
12
+ end
13
+
14
+ def subject
15
+ "Member Updated"
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -32,7 +32,7 @@ module SimpleTeams
32
32
  end
33
33
 
34
34
  def invitation
35
- @invitation ||= Teams::Invitation.find_by(token: @invitation_token)
35
+ @invitation ||= Invitation.find_by(token: @invitation_token)
36
36
  end
37
37
 
38
38
  private
@@ -42,7 +42,7 @@ module SimpleTeams
42
42
 
43
43
  def generate_notification
44
44
  recipients = team.members.to_a << user
45
- SimpleTeams::Memberships::LeftNotification.with(
45
+ SimpleTeams::Memberships::LeftNotifier.with(
46
46
  :team_id => team.id,
47
47
  :member_id => user.id,
48
48
  :user_id => user.id,
@@ -0,0 +1,8 @@
1
+ <nav aria-label="breadcrumb">
2
+ <ol class="breadcrumb">
3
+ <li class="breadcrumb-item"><%= link_to @team.teamable.class.model_name.human(count: 2), main_app.url_for(@team.teamable.class) %></li>
4
+ <li class="breadcrumb-item"><%= link_to @team.teamable.name, main_app.url_for(@team.teamable) %></li>
5
+ <li class="breadcrumb-item"><%= link_to "Team Members", @team %></li>
6
+ <li class="breadcrumb-item active" aria-current="page"><%= current_page_name %></li>
7
+ </ol>
8
+ </nav>