-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ROAD 534] Add state to stories (#309)
* Add nokogiri for apple silicon * Add `approved` field to the stories table * Add `pending` method with specs * Add `update_story` controller action * Add frontend * Use path helper instead of url * Change button color with approval status * Use enums for story status * Use remote: true for status button and refactor routes * Add appropriate specs and modify existing ones to the new changes * Move story related css to appropriate file * Change back to headless firefox * Refactor routes * Apply suggestions from code review Co-authored-by: Juan Vásquez <[email protected]> * Add status grid-area in scss * Refactor label update logic * Move status field to last position * Remove Rejected as an option on story creation * Add specs to test status selection on story creation * Replace `row` for query selector --------- Co-authored-by: Ariel Juodziukynas <[email protected]> Co-authored-by: Juan Vásquez <[email protected]>
- Loading branch information
1 parent
eaecfb4
commit 76d3e74
Showing
20 changed files
with
261 additions
and
27 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
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
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,2 +1,18 @@ | ||
module StoriesHelper | ||
def status_label(story) | ||
"<span class='story-status-badge #{story.status}'>#{story.status}</span>".html_safe | ||
end | ||
|
||
def status_color(story) | ||
return "green" if @story.approved? | ||
return "magenta" if @story.rejected? | ||
|
||
"orange" | ||
end | ||
|
||
def options_for_status_select(story, action) | ||
return options_for_select({"Pending" => "pending", "Approved" => "approved"}, selected: story.status) if action == "new" | ||
|
||
options_for_select({"Pending" => "pending", "Approved" => "approved", "Rejected" => "rejected"}, selected: story.status) | ||
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
let row = document.getElementById("story_<%= estimate.story_id %>") | ||
row.children[1].innerText = "<%= j(estimate.best_case_points.to_s) %>" | ||
row.children[2].innerText = "<%= j(estimate.worst_case_points.to_s) %>" | ||
updateStatusLabel("<%= estimate.story.status %>", "<%= estimate.story_id %>") | ||
|
||
let totals_row = document.querySelector('.project-table tfoot tr') | ||
totals_row.children[1].innerText = "<%= j @project.best_estimate_sum_per_user(current_user) %>" | ||
totals_row.children[2].innerText = "<%= j @project.worst_estimate_sum_per_user(current_user) %>" | ||
document.getElementById("best_estimate_<%= estimate.story_id %>").innerText = "<%= j(estimate.best_case_points.to_s) %>" | ||
document.getElementById("worst_estimate_<%= estimate.story_id %>").innerText = "<%= j(estimate.worst_case_points.to_s) %>" | ||
|
||
document.querySelector('.project-table tfoot tr > .best_estimates_total').innerText = "<%= j @project.best_estimate_sum_per_user(current_user) %>" | ||
document.querySelector('.project-table tfoot tr > .worst_estimates_total').innerText = "<%= j @project.worst_estimate_sum_per_user(current_user) %>" |
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,11 +1,11 @@ | ||
(function(){ | ||
<% if @estimate.persisted? %> | ||
<%= render partial: 'update_row', locals: {estimate: @estimate} %> | ||
const addEstimate = row.querySelector('.add-estimate') | ||
const addEstimate = document.getElementById("story_<%= @estimate.story_id %>").querySelector('.add-estimate') | ||
addEstimate.insertAdjacentHTML('afterend', "<%= j(link_to 'Edit Estimate', edit_project_story_estimate_path(@project.id, @estimate.story, @estimate.id), class: "button edit-estimate", remote: true) %>") | ||
addEstimate.remove() | ||
closeModal() | ||
<% else %> | ||
updateModal("New estimate", "<%= j(render partial: 'modal_body') %>") | ||
<% 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
updateStatusButton("<%= status_color(@story) %>", "<%= @story.status %>"); | ||
updateStatusLabel("<%= @story.status %>", "<%= @story.id %>") |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddStatusToStories < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :stories, :status, :integer, default: 0 | ||
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
Oops, something went wrong.