Skip to content

Commit c518365

Browse files
authored
DT-244 show ID in row - filter by id (#301)
* DT-244 show ID in row - filter by id * Add replace to remove string 'story' from ID value * Update label tag * Add spec case to fill search input and filter elements * DT-244 Spec clause to ensure only 1 row render
1 parent 4a78dd4 commit c518365

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

app/assets/javascripts/project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const filterStories = () => {
105105
const storyTitle = element
106106
.querySelector("td:first-child")
107107
.innerText.toLowerCase();
108-
if (storyTitle.includes(searchTerm)) {
108+
if (storyTitle.includes(searchTerm) || element.id.replace(/\D/g, '').includes(searchTerm)) {
109109
cl.remove("hidden");
110110
} else {
111111
cl.add("hidden");

app/views/projects/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h1 class="dashboard-title"><%= render partial: "shared/project_title", locals: {allow_edit: true, project: @project} %></h1>
44

55
<div class="search-field">
6-
<%= label_tag 'title_contains', "Filter by title" %>
6+
<%= label_tag 'title_contains', "Filter by title or ID" %>
77
<%= search_field_tag 'title_contains', nil, onkeyup: "filterStories()" %>
88
</div>
99
</div>
@@ -28,7 +28,7 @@
2828
<tr class="project-table__row project-table__row--story" id="<%= dom_id(story)%>" >
2929
<td class="project-table__cell">
3030
<input type="checkbox" name="stories[]" value="<%= story.id %>">
31-
<%= link_to story.title, [story.project, story] %>
31+
<%= link_to "#{story.id} - #{story.title}", [story.project, story] %>
3232
<button class="copy-link btn-clipboard" data-clipboard-text="<%= project_story_url(@project, story) %>" title='Copy story'><i class="fa fa-link"></i><span class= "popup">Copied to clipboard</span></button>
3333
</td>
3434
<td class="project-table__cell"><%= story.estimate_for(current_user)&.best_case_points %></td>

spec/features/stories_manage_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,25 @@
318318

319319
expect(page).not_to have_selector(".project-table.sorting")
320320
end
321+
322+
it "filter stories by title or ID", js: true do
323+
story4 = FactoryBot.create(:story, project: project, title: "Deprecation warning XYZ")
324+
story5 = FactoryBot.create(:story, project: project, title: "Dangerous query method")
325+
326+
visit project_path(id: project.id)
327+
328+
fill_in "title_contains", with: "XYZ"
329+
330+
within("#stories") do
331+
expect(find("td:nth-child(1)")).to have_text story4.title
332+
expect(all("#stories > tr").count).to eq(1)
333+
end
334+
335+
fill_in "title_contains", with: story5.id
336+
337+
within("#stories") do
338+
expect(find("td:nth-child(1)")).to have_text story5.title
339+
expect(all("#stories > tr").count).to eq(1)
340+
end
341+
end
321342
end

0 commit comments

Comments
 (0)