Skip to content

Commit be56c1d

Browse files
committed
Group canned responses by decision type
1 parent 2aa9cfb commit be56c1d

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,36 @@
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+
%h5= decision_type.humanize
12+
.d-flex.flex-wrap.gap-4.align-self-stretch
13+
- @canned_responses.filter { |cr| cr.decision_type == decision_type }.each do |canned_response|
14+
= render(CardComponent.new) do |component|
15+
- if canned_response.decision_type
16+
%p.card-text
17+
%b Decision's reason:
18+
%span.mb-2= canned_response.decision_type.humanize
19+
%p.card-text
20+
%b Content:
21+
.canned-response-card-text.mb-2
22+
= render partial: 'webui/shared/collapsible_text', locals: { text: canned_response.content, render_markdown: true }
1823

19-
- component.with_header do
20-
= canned_response.title
24+
- component.with_header do
25+
= canned_response.title
2126

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
27+
- component.with_delete_button do
28+
= link_to '#', title: 'Delete Canned Response',
29+
data: { 'bs-toggle': 'modal', 'bs-target': '#delete-canned-response-modal',
30+
canned_response_title: canned_response.title, action: canned_response_path(canned_response) } do
31+
%i.fas.fa-times-circle.text-danger
2732

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
33+
- component.with_action do
34+
= link_to(edit_canned_response_path(canned_response), title: 'Edit Canned Response', class: 'nav-link p-1') do
35+
%i.fas.fa-edit
36+
Edit
3237

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

0 commit comments

Comments
 (0)