Skip to content

Commit 99ddc98

Browse files
committed
[DREAM-803] Show blankslate on empty filter
Applies the dynamic empty-state lifecycle to the project life cycle and project attributes settings lists, replacing the detached plain-text no-results notice. https://community.openproject.org/wp/DREAM-803
1 parent c37617c commit 99ddc98

3 files changed

Lines changed: 44 additions & 11 deletions

File tree

app/components/projects/settings/life_cycle/index_component.html.erb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
OpenProject::Common::BorderBoxListComponent.new(
2727
container: "project-life-cycle-administration",
2828
position: :relative,
29-
mb: 3
29+
mb: 3,
30+
empty_state_behavior: :dynamic
3031
)
3132
) do |list|
3233
list.with_header(title: I18n.t("projects.settings.life_cycle.section_header")) do |header|
@@ -75,15 +76,5 @@
7576
list.with_empty_state(title: t("projects.settings.life_cycle.non_defined"))
7677
end
7778
end
78-
flex.with_row do
79-
render Primer::Beta::Text.new(
80-
display: :none,
81-
data: {
82-
"projects--settings--border-box-filter-target": "noResultsText"
83-
}
84-
) do
85-
I18n.t("js.autocompleter.notFoundText")
86-
end
87-
end
8879
end
8980
%>

app/components/projects/settings/project_custom_field_sections/show_component.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
container: "project-custom-field-section-#{@project_custom_field_section.id}",
66
position: :relative,
77
mb: 3,
8+
empty_state_behavior: :dynamic,
89
classes: "op-project-custom-field-section",
910
test_selector: "project-custom-field-section-#{@project_custom_field_section.id}"
1011
)

spec/features/projects/project_custom_fields/settings/mapping_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,47 @@
364364
end
365365
end
366366

367+
it "shows each section's own blankslate when the filter matches nothing, and restores rows on clear" do
368+
visit project_settings_project_custom_fields_path(project)
369+
370+
fill_in "border-box-filter", with: "no such attribute exists"
371+
372+
[section_for_input_fields, section_for_select_fields, section_for_multi_select_fields].each do |section|
373+
within_custom_field_section_container(section) do
374+
expect(page).to have_css(
375+
"[data-empty-list-item='true']",
376+
text: I18n.t("settings.project_attributes.label_no_project_custom_fields")
377+
)
378+
end
379+
end
380+
381+
# Cuprite's Node#set clears a field's existing value without firing an
382+
# `input` event before it types the replacement characters, so setting
383+
# `with: ""` never reaches the border-box-filter Stimulus controller.
384+
# Backspacing through the native key-event path (like a real user
385+
# clearing the field) does fire `input` on every keystroke — but the
386+
# field must be (re-)focused first, since Node#set blurs it afterwards.
387+
filter_field = find_field("border-box-filter")
388+
filter_field.click
389+
clear_input_field_contents(filter_field)
390+
391+
within_custom_field_section_container(section_for_input_fields) do
392+
expect(page).to have_no_css("[data-empty-list-item]")
393+
expect(page).to have_content("Boolean field")
394+
expect(page).to have_content("String field")
395+
end
396+
397+
within_custom_field_section_container(section_for_select_fields) do
398+
expect(page).to have_no_css("[data-empty-list-item]")
399+
expect(page).to have_content("List field")
400+
end
401+
402+
within_custom_field_section_container(section_for_multi_select_fields) do
403+
expect(page).to have_no_css("[data-empty-list-item]")
404+
expect(page).to have_content("Multi list field")
405+
end
406+
end
407+
367408
it "shows the project custom field sections in the correct order" do
368409
visit project_settings_project_custom_fields_path(project)
369410

0 commit comments

Comments
 (0)