-
Notifications
You must be signed in to change notification settings - Fork 434
/
index.html.haml
46 lines (44 loc) · 2.13 KB
/
index.html.haml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
- @pagetitle = 'Your Canned Responses'
.card
.card-body
%h4 Create a new canned response
= form_for(@canned_response) do |f|
.mb-3
= f.label :title, 'Title:'
= f.text_field :title, class: 'form-control'
.mb-3
= f.label :content, 'Content:'
= f.text_area :content, class: 'form-control'
- if policy(Decision.new).create?
.mb-3
= f.label :decision_kind, "Choose 'cleared' or 'favored' if this is a decision's reason"
- kinds = CannedResponse.decision_kinds.keys.to_h { |k| [k.humanize, k] }
= f.select(:decision_kind, kinds, { include_blank: 'none', selected: nil }, class: 'form-select')
= f.submit 'Create', class: 'btn btn-primary'
.card.mt-2
.card-body
%h4 Your canned responses
- if @canned_responses.present?
.accordion.accordion-flush.border-bottom
- @canned_responses.each do |canned_response|
.accordion-item
%h2.accordion-header
= button_tag(class: 'accordion-button collapsed',
data: { 'bs-toggle': 'collapse', 'bs-target': "#canned-response-#{canned_response.id}-collapse" },
aria: { expanded: false, controls: "canned-response-#{canned_response.id}-collapse" }) do
= canned_response.title
.accordion-collapse.collapse{ id: "canned-response-#{canned_response.id}-collapse" }
.accordion-body
.d-flex.justify-content-between
%strong= canned_response.decision_kind.try(:humanize) || 'Generic'
.d-flex
= link_to(edit_canned_response_path(canned_response), class: 'btn py-0 px-1 btn-link') do
%i.fas.fa-edit
Edit
= button_to(canned_response_path(canned_response), method: :delete, class: 'btn py-0 px-1 text-danger',
'data-confirm': 'Do you really want to delete this canned response?') do
%i.fas.fa-trash
Delete
= canned_response.content
- else
%p.m-4 No canned responses yet