Skip to content

Commit 0b8607c

Browse files
authored
Merge pull request #18963 from ncounter/group-canned-responses
Group canned responses by decision type
2 parents fcb2c6c + 29bf2b6 commit 0b8607c

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

src/api/app/views/webui/users/canned_responses/index.html.haml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,35 @@
44
.card-body#canned-responses
55
%h4 Your canned responses
66
- if @canned_responses.present?
7-
.d-flex.flex-wrap.gap-4.align-self-stretch.pt-4
8-
- @canned_responses.each do |canned_response|
9-
= render(CardComponent.new) do |component|
10-
- if canned_response.decision_type
11-
%p.card-text
12-
%b Decision's reason:
13-
%span.mb-2= canned_response.decision_type.humanize
14-
%p.card-text
15-
%b Content:
16-
.canned-response-card-text.mb-2
17-
= render partial: 'webui/shared/collapsible_text', locals: { text: canned_response.content, render_markdown: true }
7+
%ul.list-group.list-group-flush
8+
- canned_responses_decision_types = @canned_responses.pluck(:decision_type).uniq
9+
- canned_responses_decision_types.each do |decision_type|
10+
%li.list-group-item.py-4
11+
- if decision_type
12+
%h5= decision_type.humanize
13+
- else
14+
.pb-2
15+
Decision's reason:
16+
%em Undefined
17+
.d-flex.flex-wrap.gap-4.align-self-stretch
18+
- @canned_responses.filter { |cr| cr.decision_type == decision_type }.each do |canned_response|
19+
= render(CardComponent.new) do |component|
20+
.canned-response-card-text.mb-2
21+
= render partial: 'webui/shared/collapsible_text', locals: { text: canned_response.content, render_markdown: true }
1822

19-
- component.with_header do
20-
= canned_response.title
23+
- component.with_header do
24+
= canned_response.title
2125

22-
- component.with_delete_button do
23-
= link_to '#', title: 'Delete Canned Response',
24-
data: { 'bs-toggle': 'modal', 'bs-target': '#delete-canned-response-modal',
25-
canned_response_title: canned_response.title, action: canned_response_path(canned_response) } do
26-
%i.fas.fa-times-circle.text-danger
26+
- component.with_delete_button do
27+
= link_to '#', title: 'Delete Canned Response',
28+
data: { 'bs-toggle': 'modal', 'bs-target': '#delete-canned-response-modal',
29+
canned_response_title: canned_response.title, action: canned_response_path(canned_response) } do
30+
%i.fas.fa-times-circle.text-danger
2731

28-
- component.with_action do
29-
= link_to(edit_canned_response_path(canned_response), title: 'Edit Canned Response', class: 'nav-link p-1') do
30-
%i.fas.fa-edit
31-
Edit
32+
- component.with_action do
33+
= link_to(edit_canned_response_path(canned_response), title: 'Edit Canned Response', class: 'nav-link p-1') do
34+
%i.fas.fa-edit
35+
Edit
3236

3337
.modal.fade#delete-canned-response-modal{ tabindex: -1, role: 'dialog',
3438
aria: { labelledby: 'delete-canned-response-modal-label', hidden: true } }

src/api/spec/features/webui/canned_responses_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
within('#canned-responses') do
2323
expect(page).to have_css('.card-header', text: 'wow')
2424
expect(page).to have_css('.card-body', text: 'a canned response')
25+
expect(page).to have_css('.list-group-item.py-4', text: "Decision's reason: Undefined")
2526
end
2627
end
2728
end
@@ -89,8 +90,8 @@
8990
it do
9091
within('#canned-responses') do
9192
expect(page).to have_css('.card-header', text: 'wow')
92-
expect(page).to have_css('.card-body', text: "Decision's reason:")
93-
expect(page).to have_css('.card-body', text: 'Favored')
93+
expect(page).to have_css('.card-body', text: 'a decision-related canned response')
94+
expect(page).to have_css('.list-group-item.py-4 h5', text: 'Favored')
9495
end
9596
end
9697
end

0 commit comments

Comments
 (0)