Skip to content
1 change: 1 addition & 0 deletions app/assets/stylesheets/3-atoms/_badges.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
white-space: nowrap;
vertical-align: baseline;
border-radius: 20px;
font-size: 15px;

&.archived {
background-color: rgba(29,78,216,0.2);
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/3-atoms/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
background-color: lighten(red, 10%);
}
}
&.disabled {
opacity: 0.5;
}
&#bulk_delete[aria-disabled=true] {
opacity: 0.5;
}
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
background: white;
box-shadow: 1px 1px 4px 2px rgba(0, 0, 0, 0.4);

a span{
padding-left: 5px;
}

a,
button,
input {
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/action_plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ class ActionPlansController < ApplicationController

def show
@project = Project.find(params[:project_id])

ensure_unarchived!
Comment thread
cleicar marked this conversation as resolved.

@project_stories = @project.stories.by_position
@children = Project.sub_projects_with_ordered_stories(@project.id)
end
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ def after_sign_in_path_for(resource)
projects_path
end

private

# we can enable this for everybody, it's hidden by default
def enable_rack_mini_profiler
Rack::MiniProfiler.authorize_request
end

def ensure_unarchived!
if @project.archived? || @project.parent&.archived?
flash[:error] = "You can't perform this action in an archived project."
redirect_to project_path(@project.id)
end
end
end
13 changes: 6 additions & 7 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class ProjectsController < ApplicationController
before_action :authenticate_user!
before_action :find_project, only: [:show, :edit, :update, :sort, :sort_stories, :destroy]
before_action :find_project, except: [:index, :new, :create]
before_action :ensure_unarchived!, only: [:edit, :new_sub_project, :action_plan, :update]

def index
status = params[:archived] == "true" ? "archived" : nil
Expand Down Expand Up @@ -29,7 +30,6 @@ def sort_stories
end

def toggle_archive
@project = Project.find(params[:id])
@project.toggle_archived!
end

Expand Down Expand Up @@ -91,20 +91,19 @@ def update
end

def new_sub_project
@project = Project.find(params[:project_id])
@sub = Project.new(parent_id: @project)
end

private

def find_project
@project = Project.find(params[:id])
end

def projects_params
params.require(:project).permit(:title, :status, :parent_id)
end

def find_project
@project = Project.find(params[:id] || params[:project_id])
end

def clone_params
params.require(:project).permit(:title, :parent_id)
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class StoriesController < ApplicationController
before_action :find_project, except: [:bulk_destroy, :render_markdown, :edit, :update, :destroy, :show, :move]
before_action :find_story, only: [:edit, :update, :destroy, :show, :move]
before_action :validate_url_product_id, only: [:edit, :update, :destroy, :show, :move]
before_action :ensure_unarchived!, except: [:show, :bulk_destroy, :render_markdown, :move]

include ApplicationHelper

CSV_HEADERS = %w[id title description position]
Expand Down
19 changes: 19 additions & 0 deletions app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@ def estimated(story)
@estimate_id = story.estimate_for(current_user)
@estimate_id.present?
end

def link_unless_archived(project, text, url, classes: nil, method: :get, remote: false, icon: nil, data_attr: nil)
link_text = text_content(icon, text)
if project.archived? || project.parent&.archived?
button_tag(link_text, disabled: true, class: "button #{classes} disabled", aria: {disabled: true})
else
link_to(link_text, url, class: "button #{classes}", title: text, method: method, remote: remote, data: data_attr)
end
end

private

def text_content(icon, text)
if icon
icon_tag = content_tag(:i, "", class: "fa fa-#{icon}").concat(content_tag(:span, text))
end

icon_tag || text
end
end
10 changes: 6 additions & 4 deletions app/views/layouts/_flash.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<% bootstrap_alert_names = {"success" => "success", "error" => "danger"}%>
<% if flash[:success] || flash[:error] %>
<% flash.each do |key, value| %>
<div class="alert alert-<%= bootstrap_alert_names[key] %>"><%= value %></div>
<div class="container">
<% if flash[:success] || flash[:error] %>
<% flash.each do |key, value| %>
<div class="alert alert-<%= bootstrap_alert_names[key] %>"><%= value %></div>
<% end %>
<% end %>
<% end %>
</div>
48 changes: 20 additions & 28 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<th class="project-table__cell">Best<br />Estimate</th>
<th class="project-table__cell">Worst<br />Estimate</th>
<th class="project-table__cell story_actions">
<%= link_to "Add a Story", new_project_story_path(@project.id), class: "button magenta" %>
<%= link_unless_archived(@project, "Add a Story", new_project_story_path(@project), classes: "magenta") %>
<button id="bulk_delete" class="button magenta" aria-disabled="true" disabled>Bulk Delete</button>
</th>
</tr>
Expand All @@ -35,23 +35,18 @@
<td class="project-table__cell"><%= story.estimate_for(current_user)&.worst_case_points %></td>
<td class="project-table__cell story_actions">
<% if estimated(story) %>
<%= link_to "Edit Estimate", edit_project_story_estimate_path(@project.id, story, @estimate_id), class: "button edit-estimate", remote: true %>
<%= link_unless_archived(@project, "Edit Estimate", edit_project_story_estimate_path(@project.id, story, @estimate_id), classes: "edit-estimate", remote: true) %>
<% else %>
<%= link_to "Add Estimate", new_project_story_estimate_path(@project.id, story), class: "button add-estimate", remote: true %>
<% end %>
<%= link_unless_archived(@project, "Add Estimate", new_project_story_estimate_path(@project.id, story), classes: "add-estimate", remote: true) %>
<% end %>

<div class="dropdown-wrapper more-actions">
<button class="button" title="More actions">
<i class="fa fa-ellipsis-v"></i>
</button>
<div class="dropdown">
<%= link_to edit_project_story_path(@project.id, story), class: "button edit", title: "Edit" do %>
<i class="fa fa-pencil-square-o"></i>
<span>Edit</span>
<% end %>
<%= link_to new_project_story_path(@project.id, story_id: story.id), class: "clone", title: "Clone" do %>
<i class="fa fa-files-o"></i>
<span>Clone</span>
<% end %>
<%= link_unless_archived(@project, "Edit", edit_project_story_path(@project, story), classes: "edit", icon: 'pencil-square-o') %>

<% if @siblings.any? %>
<div class="dropdown-wrapper move-story">
<button title="Move to">
Expand All @@ -65,10 +60,15 @@
</div>
</div>
<% end %>
<%= link_to project_story_path(@project.id, story), method: "delete", data: { confirm: 'Are you sure?', story_id: story.id }, class: "delete magenta", remote: true, title: "Delete" do %>
<i class="fa fa-trash-o"></i>
<span>Delete</span>

<%= link_unless_archived(@project, "Delete", project_story_path(@project.id, story, format: "json"), classes: "delete", icon: 'trash-o', method: :delete, remote: true, data_attr: { confirm: 'Are you sure?', story_id: story.id }) %>

<% link_to new_project_story_path(@project.id, story_id: story.id), class: "clone", title: "Clone" do %>
Comment thread
cleicar marked this conversation as resolved.
<i class="fa fa-files-o"></i>
<span>Clone</span>
<% end %>

<%= link_unless_archived(@project, "Clone", new_project_story_path(@project.id, story_id: story.id), classes: "clone", icon: 'files-o') %>
</div>
</div>
</td>
Expand Down Expand Up @@ -96,25 +96,17 @@
<% end %>
</div>



<%= render partial: "projects/import_export" %>

<div class="btn-group">
<%= button_to 'Delete Project', project_path(@project.id), method: "delete", data: { confirm: 'Are you sure?' }, class: "button magenta", id: "delete" %>

<% unless @project.parent_id %>
<%= link_to 'Add Sub-Project', project_new_sub_project_path(@project.id), id:"subproject", class: "button magenta" %>
<% end %>
<div class="btn-group actions">
<%= link_unless_archived(@project, "Edit or Delete Project", edit_project_path(@project), classes: "magenta") %>
<%= link_unless_archived(@project, "Add Sub-Project", project_new_sub_project_path(@project), classes: "magenta") unless @project.parent_id %>
<%= link_to 'Clone Project', new_clone_project_path(@project.id), class: "button magenta" %>
<% unless @project.parent_id %>
<%= link_to "#{@project.archived? ? 'Unarchive' : 'Archive'} Project", toggle_archive_project_path(@project.id), method: "patch", id: "toggle_archive", class: "button magenta", remote: true %>
<% end %>
<%= link_to "Generate Action Plan", project_action_plan_path(@project.id), class: "button" %>
<% if current_user.admin? %>
<%= link_to "View Report", project_report_path(@project.id), class: "button" %>
<% end %>
<%= link_to "View Report", project_report_path(@project.id), class: "button" if current_user.admin? %>
<%= link_to 'Return to Projects Page', projects_path, id:"back", class: "button" %>
</div>

<%= link_to 'Return to Projects Page', projects_path, id:"back", class: "button" %>
</div>
21 changes: 3 additions & 18 deletions app/views/projects/toggle_archive.js.erb
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
(function() {
toggleButtonText();
toggleProjectStatus();
window.location.reload();
})()

function toggleButtonText() {
let button_text = document.querySelector('#toggle_archive');

if (button_text.textContent == "Archive Project") {
button_text.textContent = "Unarchive Project"
button_text.textContent = "Unarchive Project";
} else {
button_text.textContent = "Archive Project"
}
}

function toggleProjectStatus() {
let statusBadge = document.querySelector(".status-badge");
let projectStatus = "<%= @project.status %>";

if (projectStatus === ""){
statusBadge.classList.add("hide")
statusBadge.textContent = ""
}
else{
statusBadge.classList.remove("hide")
statusBadge.classList.add(projectStatus)
statusBadge.textContent = projectStatus
button_text.textContent = "Archive Project";
}
}
2 changes: 1 addition & 1 deletion app/views/stories/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= render "shared/story", story: @story %>

<div class="btn-group">
<%= link_to 'Edit', edit_project_story_path(@project), id:"back", class: "button" %>
<%= link_unless_archived(@project, "Edit", edit_project_story_path(@project), classes: "magenta") %>
<%= link_to 'Back', project_path(@project), id:"back", class: "button" %>
<%= link_to "Delete", project_story_path(@project.id, @story), method: :delete, data: { confirm: "Are you sure?", story_id: @story.id }, class: "button red", remote: true , title: "Delete" %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/rack_mini_profiler.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Rack::MiniProfiler.config.start_hidden = true
Rack::MiniProfiler.config.toggle_shortcut = "Alt+Ctrl+P"
Rack::MiniProfiler.config.toggle_shortcut = "Alt+Ctrl+P"
Loading