-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
531 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the retros controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
class ApplicationController < ActionController::Base | ||
before_action :authenticate_user! | ||
helper_method :current_user_teams | ||
|
||
def current_user_teams | ||
current_user.teams | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class RetrosController < ApplicationController | ||
before_action :find_retro, only: [:show] | ||
|
||
def new | ||
end | ||
|
||
def create | ||
@retro = Retro.new(retro_params) | ||
if @retro.save | ||
redirect_to @retro | ||
else | ||
flash[:error] = 'Retro session could not be created.' | ||
redirect_to new_retro_path | ||
end | ||
end | ||
|
||
def show | ||
end | ||
|
||
private | ||
|
||
def retro_params | ||
params.require(:retro).permit(:team_id, :date) | ||
end | ||
|
||
def find_retro | ||
@retro = Retro.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,89 @@ | ||
class TeamsController < ApplicationController | ||
before_action :find_team, except: [:index] | ||
before_action :team_users, only: [:show, :edit] | ||
|
||
def index | ||
@teams = Team.all | ||
end | ||
|
||
def show | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
begin | ||
@team.update!(team_params) | ||
flash[:success] = 'Team was successfully updated.' | ||
redirect_to team_path | ||
rescue StandardError => e | ||
flash[:error] = 'Oops, please try again.' | ||
reload | ||
end | ||
end | ||
|
||
def destroy | ||
begin | ||
@team.destroy! | ||
flash[:success] = 'Team is gone forever.' | ||
redirect_to teams_path | ||
rescue StandardError => e | ||
flash[:error] = 'Oops, please try again.' | ||
reload | ||
end | ||
end | ||
|
||
def add_user | ||
company = @team.company | ||
|
||
begin | ||
user = company.users.find_by!(email: params[:user][:email]) | ||
raise UserAlreadyPresentError if user.already_present?(@team) | ||
|
||
@team.users << user | ||
flash[:success] = 'Say hi to your new team member!' | ||
rescue ActiveRecord::RecordNotFound => e | ||
flash[:error] = 'User could not been found in your company.' | ||
rescue UserAlreadyPresentError | ||
flash[:error] = "You can only have one #{user.name}." | ||
rescue StandardError => e | ||
flash[:error] = 'Oops, please try again.' | ||
end | ||
|
||
reload | ||
end | ||
|
||
def remove_user_from_team | ||
begin | ||
relation = UserTeam.find_by!(user_id: params[:user_id], team_id: @team.id) | ||
relation.destroy! | ||
flash[:success] = 'User was successfully removed. Farewell...' | ||
rescue ActiveRecord::RecordNotFound => e | ||
flash[:error] = 'User is not in the team anyway.' | ||
rescue StandardError => e | ||
flash[:error] = 'Oops, please try again.' | ||
end | ||
|
||
reload | ||
end | ||
|
||
private | ||
|
||
class UserAlreadyPresentError < StandardError; end | ||
|
||
def find_team | ||
@team = Team.find(params[:id]) | ||
end | ||
|
||
def team_users | ||
@team_users = @team.users | ||
end | ||
|
||
def team_params | ||
params.require(:team).permit(:name, :description) | ||
end | ||
|
||
def reload | ||
redirect_back(fallback_location: edit_team_path) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module RetrosHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Answer < ApplicationRecord | ||
belongs_to :user | ||
belongs_to :retro | ||
has_many :entries, dependent: :destroy | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Entry < ApplicationRecord | ||
belongs_to :answer | ||
validates :detail, presence: true, length: { minimum: 2, maximum: 255 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Outcome < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Retro < ApplicationRecord | ||
# date and time validation | ||
belongs_to :team | ||
has_many :outcomes, dependent: :destroy | ||
has_many :answers, dependent: :destroy | ||
|
||
def active? | ||
status == 'active' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class UserTeam < ApplicationRecord | ||
belongs_to :team | ||
belongs_to :user | ||
validates :user_id, presence: true | ||
validates :team_id, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,3 @@ | |
<br /> | ||
</div> | ||
</div> | ||
|
||
<!-- <%= link_to "Back", :back %> --> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<% flash.each do |message_type, message_content| %> | ||
<% if notice %> | ||
<div class="ui container"> | ||
<div class="ui success message"> | ||
<i class="close icon"></i> | ||
<div class="header"> | ||
<%= notice %> | ||
</div> | ||
</div> | ||
</div> | ||
<br/> | ||
<% elsif alert %> | ||
<div class="ui container"> | ||
<div class="ui error message"> | ||
<i class="close icon"></i> | ||
<%= alert %> | ||
</div> | ||
</div> | ||
<br/> | ||
<% else %> | ||
<div class="ui <%= message_type %> message transition"> | ||
<i class="close icon"></i> | ||
<div class="header"> | ||
<%= message_content %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="ui container"> | ||
<div class="column"> | ||
<%= form_for(:retro, url: retros_path, html: { method: :post, class: 'ui form'}) do |f| %> | ||
<div class="field"> | ||
<%= f.label :team %> | ||
<%= f.collection_select :team_id, current_user_teams, :id, :name %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :DateTime %> | ||
<%= f.datetime_select :date %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.button "Create", class: 'blue ui button' %> | ||
<%= link_to "Cancel", root_path, class: 'ui button'%> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="ui container"> | ||
<!-- will be replaced with answers --> | ||
<h1>Retro show</h1> | ||
<%= @retro.id %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<div class="ui container"> | ||
<h3 class="ui top attached header"> | ||
<i class="settings icon"></i> | ||
<div class="content"> | ||
Team Settings | ||
<div class="sub header">Manage your preferences</div> | ||
</div> | ||
</h3> | ||
<div class="ui attached segment"> | ||
<div class="ui two column very relaxed grid"> | ||
<div class="column"> | ||
<%= form_for(@team, url: team_path(@team.id), html: { method: :put, class: 'ui form'}) do |f| %> | ||
<div class="field"> | ||
<%= f.label :team_name %> | ||
<%= f.text_field :name %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.label :team_description %> | ||
<%= f.text_field :description %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= f.button "Save", class: 'blue ui button' %> | ||
<%= link_to "Cancel", @team, class: 'ui button'%> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class="column"> | ||
<div class="ui celled list"> | ||
<% @team_users.each do |user| %> | ||
<div class="item"> | ||
<div class="right floated content"> | ||
<div class="ui buttons"> | ||
<button class="ui tiny basic blue button">Edit Permissions</button> | ||
</div> | ||
<%= link_to "Remove", remove_user_team_path(@team.id, user.id), data: { confirm: "Are you sure?" }, method: :delete, class: 'ui tiny red button' %> | ||
</div> | ||
<div class="content"> | ||
<div class="header"> | ||
<% if user.name? %> | ||
<%= user.name %> | ||
<% else %> | ||
<%= user.email %> | ||
<% end %> | ||
</div> | ||
<em><%= user.title %></em> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="ui attached segment"> | ||
<%= form_for :user, url: add_user_team_path(@team.id), html: { method: :post, class: 'ui form'} do |f| %> | ||
<div class="field"> | ||
<%= f.label :user_email %> | ||
<%= f.email_field :email %> | ||
</div> | ||
|
||
<%= f.button "Add User", class: 'ui blue button' %> | ||
<% end %> | ||
</div> | ||
<br /> | ||
<%= link_to "Delete Team", team_path(@team), data: { confirm: "Are you sure?" }, method: :delete, class: 'negative ui button' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
<% @teams.each do |team| %> | ||
<ul> | ||
<li> <%= team.name %> </li> | ||
</ul> | ||
<% end %> | ||
<div class="ui container"> | ||
<h3 class="ui top attached header"> | ||
<i class="users icon"></i> | ||
<div class="content"> | ||
My Teams | ||
</div> | ||
</h3> | ||
<div class="ui attached segment"> | ||
<div class="ui middle aligned animated selection list"> | ||
<% current_user_teams.each do |team| %> | ||
<div class="item"> | ||
<div class="content"> | ||
<div class="header"> | ||
<%= link_to team.name, team %> | ||
</div> | ||
<div class="description"> | ||
<em><%= pluralize(team.users.count, 'member') %></em> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.