simple_teams 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +8 -0
  5. data/app/assets/config/simple_teams_manifest.js +1 -0
  6. data/app/assets/stylesheets/simple_teams/application.css +15 -0
  7. data/app/controllers/simple_teams/accept_invitations_controller.rb +57 -0
  8. data/app/controllers/simple_teams/admin/invitations_controller.rb +60 -0
  9. data/app/controllers/simple_teams/admin/memberships_controller.rb +60 -0
  10. data/app/controllers/simple_teams/admin/teams_controller.rb +60 -0
  11. data/app/controllers/simple_teams/application_controller.rb +13 -0
  12. data/app/controllers/simple_teams/invitations_controller.rb +96 -0
  13. data/app/controllers/simple_teams/leave_teams_controller.rb +25 -0
  14. data/app/controllers/simple_teams/memberships_controller.rb +61 -0
  15. data/app/controllers/simple_teams/related_members_controller.rb +33 -0
  16. data/app/controllers/simple_teams/teams_controller.rb +19 -0
  17. data/app/forms/simple_teams/invitation_form.rb +77 -0
  18. data/app/forms/simple_teams/invitation_forms/create.rb +24 -0
  19. data/app/forms/simple_teams/invitation_forms/create_bulk.rb +125 -0
  20. data/app/forms/simple_teams/invitation_forms/create_combo.rb +75 -0
  21. data/app/forms/simple_teams/invitation_forms/update.rb +29 -0
  22. data/app/forms/simple_teams/membership_form.rb +91 -0
  23. data/app/helpers/simple_teams/application_helper.rb +4 -0
  24. data/app/helpers/simple_teams/invitations_helper.rb +4 -0
  25. data/app/helpers/simple_teams/memberships_helper.rb +4 -0
  26. data/app/helpers/simple_teams/teams_helper.rb +4 -0
  27. data/app/jobs/simple_teams/application_job.rb +4 -0
  28. data/app/mailers/simple_teams/application_mailer.rb +6 -0
  29. data/app/mailers/simple_teams/mailer.rb +17 -0
  30. data/app/models/concerns/simple_teams/member_object.rb +22 -0
  31. data/app/models/concerns/simple_teams/team_object.rb +23 -0
  32. data/app/models/simple_teams/ability.rb +34 -0
  33. data/app/models/simple_teams/application_record.rb +5 -0
  34. data/app/models/simple_teams/invitation.rb +85 -0
  35. data/app/models/simple_teams/membership.rb +16 -0
  36. data/app/models/simple_teams/team.rb +23 -0
  37. data/app/notifications/application_notification.rb +4 -0
  38. data/app/notifications/simple_teams/bulk_invitations_notification.rb +51 -0
  39. data/app/notifications/simple_teams/invitation_notification.rb +54 -0
  40. data/app/notifications/simple_teams/invitations/accepted_notification.rb +13 -0
  41. data/app/notifications/simple_teams/invitations/created_notification.rb +13 -0
  42. data/app/notifications/simple_teams/invitations/destroyed_notification.rb +13 -0
  43. data/app/notifications/simple_teams/invitations/updated_notification.rb +13 -0
  44. data/app/notifications/simple_teams/membership_notification.rb +58 -0
  45. data/app/notifications/simple_teams/memberships/destroyed_notification.rb +13 -0
  46. data/app/notifications/simple_teams/memberships/left_notification.rb +17 -0
  47. data/app/notifications/simple_teams/memberships/updated_notification.rb +17 -0
  48. data/app/service_objects/simple_teams/accept_invitation_service.rb +61 -0
  49. data/app/service_objects/simple_teams/initialize_team_service.rb +25 -0
  50. data/app/service_objects/simple_teams/leave_team_service.rb +56 -0
  51. data/app/views/layouts/simple_teams/application.html.erb +20 -0
  52. data/app/views/simple_teams/_roles_field.html.erb +22 -0
  53. data/app/views/simple_teams/accept_invitations/invalid_token.html.erb +7 -0
  54. data/app/views/simple_teams/accept_invitations/new.html.erb +18 -0
  55. data/app/views/simple_teams/admin/invitations/_form.html.erb +62 -0
  56. data/app/views/simple_teams/admin/invitations/_invitation.html.erb +47 -0
  57. data/app/views/simple_teams/admin/invitations/edit.html.erb +10 -0
  58. data/app/views/simple_teams/admin/invitations/index.html.erb +14 -0
  59. data/app/views/simple_teams/admin/invitations/new.html.erb +9 -0
  60. data/app/views/simple_teams/admin/invitations/show.html.erb +10 -0
  61. data/app/views/simple_teams/admin/memberships/_form.html.erb +32 -0
  62. data/app/views/simple_teams/admin/memberships/_membership.html.erb +17 -0
  63. data/app/views/simple_teams/admin/memberships/edit.html.erb +10 -0
  64. data/app/views/simple_teams/admin/memberships/index.html.erb +14 -0
  65. data/app/views/simple_teams/admin/memberships/new.html.erb +9 -0
  66. data/app/views/simple_teams/admin/memberships/show.html.erb +10 -0
  67. data/app/views/simple_teams/admin/teams/_form.html.erb +22 -0
  68. data/app/views/simple_teams/admin/teams/_team.html.erb +7 -0
  69. data/app/views/simple_teams/admin/teams/edit.html.erb +10 -0
  70. data/app/views/simple_teams/admin/teams/index.html.erb +14 -0
  71. data/app/views/simple_teams/admin/teams/new.html.erb +9 -0
  72. data/app/views/simple_teams/admin/teams/show.html.erb +10 -0
  73. data/app/views/simple_teams/invitations/_bulk_form.html.erb +63 -0
  74. data/app/views/simple_teams/invitations/_form.html.erb +15 -0
  75. data/app/views/simple_teams/invitations/_invitation.html.erb +19 -0
  76. data/app/views/simple_teams/invitations/_invitation.json.jbuilder +2 -0
  77. data/app/views/simple_teams/invitations/edit.html.erb +12 -0
  78. data/app/views/simple_teams/invitations/new.html.erb +12 -0
  79. data/app/views/simple_teams/leave_teams/edit.html.erb +2 -0
  80. data/app/views/simple_teams/memberships/_form.html.erb +12 -0
  81. data/app/views/simple_teams/memberships/_membership.html.erb +23 -0
  82. data/app/views/simple_teams/memberships/edit.html.erb +12 -0
  83. data/app/views/simple_teams/related_members/index.json.jbuilder +5 -0
  84. data/app/views/simple_teams/related_members/select2.json.jbuilder +6 -0
  85. data/app/views/simple_teams/teams/_add_member_link.html.erb +3 -0
  86. data/app/views/simple_teams/teams/_members_table.html.erb +20 -0
  87. data/app/views/simple_teams/teams/show.html.erb +38 -0
  88. data/app/views/simple_teams/teams_mailer/invitation_notification.html.erb +9 -0
  89. data/config/locales/simple_teams.en.yml +18 -0
  90. data/config/routes.rb +21 -0
  91. data/db/migrate/20240311052758_create_simple_teams_teams.rb +9 -0
  92. data/db/migrate/20240311053006_create_simple_teams_memberships.rb +11 -0
  93. data/db/migrate/20240311053607_create_simple_teams_invitations.rb +17 -0
  94. data/lib/simple_teams/engine.rb +22 -0
  95. data/lib/simple_teams/version.rb +3 -0
  96. data/lib/simple_teams.rb +6 -0
  97. data/lib/tasks/simple_teams_tasks.rake +4 -0
  98. metadata +160 -0
@@ -0,0 +1,9 @@
1
+ <h1>New membership</h1>
2
+
3
+ <%= render "form", membership: @membership %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back to memberships", memberships_path %>
9
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @membership %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this membership", edit_membership_path(@membership) %> |
7
+ <%= link_to "Back to memberships", memberships_path %>
8
+
9
+ <%= button_to "Destroy this membership", @membership, method: :delete %>
10
+ </div>
@@ -0,0 +1,22 @@
1
+ <%= form_with(model: team) do |form| %>
2
+ <% if team.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(team.errors.count, "error") %> prohibited this team from being saved:</h2>
5
+
6
+ <ul>
7
+ <% team.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= form.label :teamable_id, style: "display: block" %>
16
+ <%= form.text_field :teamable_id %>
17
+ </div>
18
+
19
+ <div>
20
+ <%= form.submit %>
21
+ </div>
22
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <div id="<%= dom_id team %>">
2
+ <p>
3
+ <strong>Teamable:</strong>
4
+ <%= team.teamable_id %>
5
+ </p>
6
+
7
+ </div>
@@ -0,0 +1,10 @@
1
+ <h1>Editing team</h1>
2
+
3
+ <%= render "form", team: @team %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Show this team", @team %> |
9
+ <%= link_to "Back to teams", teams_path %>
10
+ </div>
@@ -0,0 +1,14 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Teams</h1>
4
+
5
+ <div id="teams">
6
+ <% @teams.each do |team| %>
7
+ <%= render team %>
8
+ <p>
9
+ <%= link_to "Show this team", team %>
10
+ </p>
11
+ <% end %>
12
+ </div>
13
+
14
+ <%= link_to "New team", new_team_path %>
@@ -0,0 +1,9 @@
1
+ <h1>New team</h1>
2
+
3
+ <%= render "form", team: @team %>
4
+
5
+ <br>
6
+
7
+ <div>
8
+ <%= link_to "Back to teams", teams_path %>
9
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @team %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this team", edit_team_path(@team) %> |
7
+ <%= link_to "Back to teams", teams_path %>
8
+
9
+ <%= button_to "Destroy this team", @team, method: :delete %>
10
+ </div>
@@ -0,0 +1,63 @@
1
+ <%= simple_form_for(@service_object, :url => (%w"new create".include?(params[:action]) ? team_invitations_path(@team) : team_invitation_path(@team, @invitation)), :method => (%w"new create".include?(params[:action]) ? :post : :put) ) do |f| %>
2
+ <%= f.error_notification %>
3
+ <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
4
+
5
+ <div class="form-inputs">
6
+ <%= f.input :single_vs_multiple,
7
+ :as => :select,
8
+ :collection => [:single, :multiple, :accessible],
9
+ :include_blank => false,
10
+ :input_html => {
11
+ "data-togglefields" => "single-vs-multiple"
12
+ }
13
+ %>
14
+
15
+ <div data-togglefields-name="single-vs-multiple" data-togglefields-values='["single"]'>
16
+ <%= f.input :email,
17
+ :placeholder => "e.g. test@example.com",
18
+ :error => false,
19
+ :input_html => { "data-teams-invitations-field" => "single" }
20
+ %>
21
+ </div>
22
+
23
+ <div data-togglefields-name="single-vs-multiple" data-togglefields-values='["multiple"]'>
24
+ <%= f.input :select2_emails,
25
+ :as => :select,
26
+ collection: @service_object.emails,
27
+ :include_blank => false,
28
+ :error => false,
29
+ :input_html => {:multiple => true, "data-teams-invitations-field" => "multiple" }
30
+ %>
31
+ </div>
32
+
33
+ <div data-togglefields-name="single-vs-multiple" data-togglefields-values='["accessible"]'>
34
+ <%= f.input :accessible_emails,
35
+ :error => false,
36
+ :placeholder => "e.g. test1@example.com, test2@example.com",
37
+ :input_html => {"data-teams-invitations-field" => "accessible" },
38
+ :hint => "Enter email addresses separated by comma."
39
+ %>
40
+ </div>
41
+
42
+ <small class="form-text text-muted">
43
+ Begin typing to search for members of other projects that you belong to.
44
+ </small>
45
+
46
+ <% [:email, :select2_emails, :accessible_emails].each do |a| %>
47
+ <% if @service_object.errors[a].present? %>
48
+ <ul class="invalid-feedback d-block">
49
+ <% @service_object.errors[a].each do |error| %>
50
+ <li><%= error %></li>
51
+ <% end %>
52
+ </ul>
53
+ <% end %>
54
+ <% end %>
55
+
56
+ <%= render "simple_teams/roles_field", :f => f, :prefix => "invitation_forms_create_combo" %>
57
+ </div>
58
+
59
+ <div class="form-actions">
60
+ <%= f.button :submit, :class => "btn-primary" %>
61
+ <%= link_to "Cancel", team_path(@team), :class => "btn btn-danger" %>
62
+ </div>
63
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= simple_form_for(@service_object, :url => (%w"new create".include?(params[:action]) ? team_invitations_path(@team) : team_invitation_path(@team, @invitation)), :method => (%w"new create".include?(params[:action]) ? :post : :put) ) do |f| %>
2
+ <%= f.error_notification %>
3
+ <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
4
+
5
+ <div class="form-inputs">
6
+ <%= f.input :email %>
7
+
8
+ <%= render "simple_teams/roles_field", :f => f, :prefix => "invitation_forms_update" %>
9
+ </div>
10
+
11
+ <div class="form-actions">
12
+ <%= f.button :submit, :class => "btn-primary" %>
13
+ <%= link_to "Cancel", team_path(@team), :class => "btn btn-danger" %>
14
+ </div>
15
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <tr id="<%= dom_id invitation %>">
2
+ <td><%= invitation.email %></td>
3
+ <td><%= invitation.role.capitalize %></td>
4
+ <td>Invited</td>
5
+ <td><%= invitation.created_at.to_date %></td>
6
+ <td>
7
+ <% if can? :edit, invitation %>
8
+ <button class="btn btn-outline-dark btn-sm dropdown-toggle" type="button" id="<%= dom_id invitation %>-dropdown-menu" data-bs-toggle="dropdown" aria-expanded="false">
9
+ Actions
10
+ </button>
11
+ <ul class="dropdown-menu" aria-labelledby="<%= dom_id invitation %>-dropdown-menu">
12
+ <li><%= button_to "Resend", resend_team_invitation_path(team, invitation), :class => "dropdown-item" %></li>
13
+ <li class="dropdown-divider"></li>
14
+ <li><%= link_to "Edit", edit_team_invitation_path(team, invitation), :class => "dropdown-item" %></li>
15
+ <li><%= button_to "Delete", team_invitation_path(team, invitation), :method => :delete, :class => "btn btn-link dropdown-item", :form => { :data => { "turbo-confirm" => "Are you sure you want to delete this invitation?" } } %></li>
16
+ </ul>
17
+ <% end %>
18
+ </td>
19
+ </tr>
@@ -0,0 +1,2 @@
1
+ json.extract! invitation, :id, :email, :created_at, :updated_at
2
+ json.url team_invitation_url(team, invitation, format: :json)
@@ -0,0 +1,12 @@
1
+ <div class="centered-content-template">
2
+ <nav aria-label="breadcrumb">
3
+ <ol class="breadcrumb">
4
+ <li class="breadcrumb-item"><a href="<%= team_path(@team) %>"><%= @team.name %></a></li>
5
+ <li class="breadcrumb-item active" aria-current="page">Update Invitation</li>
6
+ </ol>
7
+ </nav>
8
+
9
+ <h1>Update Invitation</h1>
10
+
11
+ <%= render "form", invitation: @invitation %>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="centered-content-template">
2
+ <nav aria-label="breadcrumb">
3
+ <ol class="breadcrumb">
4
+ <li class="breadcrumb-item"><a href="<%= team_path(@team) %>"><%= @team.name %></a></li>
5
+ <li class="breadcrumb-item active" aria-current="page">Invite User</li>
6
+ </ol>
7
+ </nav>
8
+
9
+ <h1>Invite Users</h1>
10
+
11
+ <%= render "bulk_form", invitation: @invitation %>
12
+ </div>
@@ -0,0 +1,2 @@
1
+ <h1>Teams::LeaveTeams#edit</h1>
2
+ <p>Find me in app/views/teams/leave_teams/edit.html.erb</p>
@@ -0,0 +1,12 @@
1
+ <%= simple_form_for(@service_object, :url => team_membership_path(@team, @membership), :method => :put) do |f| %>
2
+ <%= f.error_notification %>
3
+
4
+ <div class="form-inputs">
5
+ <%= render "simple_teams/roles_field", :f => f, :prefix => "teams_membership_form" %>
6
+ </div>
7
+
8
+ <div class="form-actions">
9
+ <%= f.button :submit, :class => "btn-primary" %>
10
+ <%= link_to "Cancel", team_path(@team), :class => "btn btn-danger" %>
11
+ </div>
12
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <tr id="<%= dom_id membership %>">
2
+ <td><%= membership.member.full_name %><%= " (you)" if current_user.membership_for_team(team) == membership %></td>
3
+ <td><%= membership.role.capitalize %></td>
4
+ <td>Active</td>
5
+ <td><%= membership.created_at.to_date %></td>
6
+ <td>
7
+ <% unless defined?(hide_controls) and hide_controls %>
8
+ <% if can? :edit, membership %>
9
+ <button class="btn btn-outline-dark btn-sm dropdown-toggle" type="button" id="<%= dom_id membership %>-dropdown-menu" data-bs-toggle="dropdown" aria-expanded="false">
10
+ Actions
11
+ </button>
12
+ <ul class="dropdown-menu" aria-labelledby="<%= dom_id membership %>-dropdown-menu">
13
+ <%= link_to "Edit", edit_team_membership_path(team, membership), :class => "dropdown-item" %>
14
+ <% if membership == current_user.membership_for_team(team) %>
15
+ <%= button_to "Delete", team_leave_team_path(@team), :method => :delete, :class => "btn btn-link dropdown-item", :form => { :data => { "turbo-confirm" => "Are you sure you want to leave this #{ @team.teamable.class.model_name.human }? Removing your own membership will remove all access to this #{ @team.teamable.class.model_name.human }." } } %></li>
16
+ <% else %>
17
+ <%= button_to "Delete", team_membership_path(team, membership), :method => :delete, :class => "btn btn-link dropdown-item", :form => { :data => { "turbo-confirm" => "Are you sure you want to delete this member?" } } %>
18
+ <% end %>
19
+ </ul>
20
+ <% end %>
21
+ <% end %>
22
+ </td>
23
+ </tr>
@@ -0,0 +1,12 @@
1
+ <div class="centered-content-template">
2
+ <nav aria-label="breadcrumb">
3
+ <ol class="breadcrumb">
4
+ <li class="breadcrumb-item"><a href="<%= team_path(@team) %>"><%= @team.name %></a></li>
5
+ <li class="breadcrumb-item active" aria-current="page">Edit Member</li>
6
+ </ol>
7
+ </nav>
8
+
9
+ <h1>Edit Member: <%= @membership.member.full_name %></h1>
10
+
11
+ <%= render "form", membership: @membership %>
12
+ </div>
@@ -0,0 +1,5 @@
1
+ json.array! @members do |member|
2
+ json.id member.email
3
+ json.label "#{member.email}"
4
+ json.value "#{member.email}"
5
+ end
@@ -0,0 +1,6 @@
1
+ json.results do
2
+ json.array! @members do |member|
3
+ json.id member.email
4
+ json.text "#{member.email}"
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <div class="text-center">
2
+ <%= link_to text, new_team_invitation_path(@team), :class => "btn btn-primary" %>
3
+ </div>
@@ -0,0 +1,20 @@
1
+ <table class="table table-bordered mb-5">
2
+ <thead>
3
+ <tr>
4
+ <th class="col-3">Name</th>
5
+ <th class="col-3">Role</th>
6
+ <th class="col-3">Status</th>
7
+ <th class="col-2">Added</th>
8
+ <th class="col-1"></th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @memberships_and_invitations.each do |object| %>
13
+ <% if object.kind_of? SimpleTeams::Membership %>
14
+ <%= render "simple_teams/memberships/membership", :team => @team, :membership => object %>
15
+ <% elsif object.kind_of? SimpleTeams::Invitation %>
16
+ <%= render "simple_teams/invitations/invitation", :team => @team, :invitation => object %>
17
+ <% end %>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
@@ -0,0 +1,38 @@
1
+ <nav aria-label="breadcrumb">
2
+ <ol class="breadcrumb">
3
+ <li class="breadcrumb-item"><%= link_to "Teams", teams_path %></li>
4
+ <li class="breadcrumb-item active" aria-current="page"><%= @team.name %></li>
5
+ </ol>
6
+ </nav>
7
+
8
+ <div class="heading-with-dropdown-menu">
9
+ <h1><%= @team.name %></h1>
10
+
11
+ <div class="dropdown">
12
+ <% if can? :update, @team %>
13
+ <button class="btn btn-outline-dark btn-sm dropdown-toggle" type="button" id="<%= @team.id %>-dropdown-menu" data-bs-toggle="dropdown" aria-expanded="false">
14
+ Actions
15
+ </button>
16
+ <ul class="dropdown-menu" aria-labelledby="<%= @team.id %>-dropdown-menu">
17
+ <%= link_to "Invite User", new_team_invitation_path(@team), :class => "dropdown-item" %>
18
+
19
+ <li><hr class="dropdown-divider"></li>
20
+ <%= link_to "Edit", edit_team_path(@team), :class => "dropdown-item" %>
21
+
22
+ <% if current_user.membership_for_team(@team).present? %>
23
+ <li><hr class="dropdown-divider"></li>
24
+ <%= button_to "Leave", team_leave_team_path(@team), :method => :delete, :class => "btn btn-link dropdown-item", :form => { :data => { "turbo-confirm" => "Are you sure you want to leave this #{ @team.teamable.class.model_name.human }?" } } %>
25
+ <% end %>
26
+
27
+ <% if can? :destroy, @team %>
28
+ <li><hr class="dropdown-divider"></li>
29
+ <%= button_to "Delete", team_path(@team), :method => :delete, :class => "btn btn-link dropdown-item", :form => { :data => { "turbo-confirm" => "Are you sure you want to delete this #{ @team.teamable.class.model_name.human }?" } } %>
30
+ <% end %>
31
+ </ul>
32
+ <% end %>
33
+ </div>
34
+ </div>
35
+
36
+ <h2 class="mt-5">Members</h2>
37
+
38
+ <%= render "members_table" %>
@@ -0,0 +1,9 @@
1
+ <% if @invitation.inviter.present? %>
2
+ <p><%= @invitation.inviter.full_name %> has invited you to the "<%= @name %>" <%= @resource_name %>.</p>
3
+ <% else %>
4
+ <p>You have been invited to the "<%= @name %>" <%= @resource_name %>.</p>
5
+ <% end %>
6
+
7
+ <p>Use the link below to view this invitation:</p>
8
+
9
+ <p><%= link_to @invitation_url, @invitation_url %></p>
@@ -0,0 +1,18 @@
1
+ en:
2
+ simple_teams:
3
+ roles:
4
+ member: "Can view content"
5
+ administrator: "Can create and delete content, and invite and remove other members"
6
+ owner: "Same as administrator, but cannot be removed except by another owner"
7
+ simple_form:
8
+ labels:
9
+ invitation_forms_create_combo:
10
+ single_vs_multiple: "Single or multiple users"
11
+ select2_emails: "Email addresses"
12
+ accessible_emails: "Email addresses"
13
+ options:
14
+ invitation_forms_create_combo:
15
+ single_vs_multiple:
16
+ single: "Single user"
17
+ multiple: "Multiple users"
18
+ accessible: "Multiple users (accessible form)"
data/config/routes.rb ADDED
@@ -0,0 +1,21 @@
1
+ SimpleTeams::Engine.routes.draw do
2
+
3
+ # Team Resources
4
+ resources :teams do
5
+ resources :memberships, :only => [:edit, :update, :destroy]
6
+ resources :invitations, :only => [:new, :create, :edit, :update, :destroy] do
7
+ post "resend", :on => :member
8
+ end
9
+ resource :leave_team, :only => [:destroy]
10
+ end
11
+
12
+ # Autocomplete
13
+ resources :related_members, :only => [:index] do
14
+ get "select2", :on => :collection
15
+ end
16
+
17
+ # Team Invitations
18
+ get "accept_team_invitation/:id", :as => "accept_team_invitation", to: "teams/accept_invitations#new"
19
+ post "accept_team_invitation/:id", to: "teams/accept_invitations#create"
20
+
21
+ end
@@ -0,0 +1,9 @@
1
+ class CreateSimpleTeamsTeams < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :simple_teams_teams do |t|
4
+ t.references :teamable, polymorphic: true, null: false
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class CreateSimpleTeamsMemberships < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :simple_teams_memberships do |t|
4
+ t.references :team, null: false, foreign_key: { to_table: :simple_teams_teams }
5
+ t.references :member, null: false, foreign_key: { to_table: :users }
6
+ t.integer :role, null: false, default: 0
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ class CreateSimpleTeamsInvitations < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :simple_teams_invitations do |t|
4
+ t.references :team, null: false, foreign_key: { to_table: :simple_teams_teams }
5
+ t.references :inviter, null: false, foreign_key: { to_table: :users }
6
+ t.references :membership, foreign_key: { to_table: :simple_teams_memberships }
7
+ t.string :email, null: false
8
+ t.integer :role, null: false, default: 0
9
+ t.string :token, null: false
10
+ t.integer :status, default: 0
11
+ t.datetime :sent_at
12
+ t.datetime :expires_at
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ module SimpleTeams
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace SimpleTeams
4
+ end
5
+
6
+ mattr_accessor :member_class
7
+ mattr_accessor :parent_controller
8
+ mattr_accessor :layout
9
+
10
+ def self.member_class
11
+ (@@member_class || "User").constantize
12
+ end
13
+
14
+ def self.parent_controller
15
+ (@@parent_controller || "ApplicationController").constantize
16
+ end
17
+
18
+ def self.layout
19
+ (@@layout || "simple_teams/application")
20
+ end
21
+
22
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleTeams
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "simple_teams/version"
2
+ require "simple_teams/engine"
3
+
4
+ module SimpleTeams
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :simple_teams do
3
+ # # Task goes here
4
+ # end