|
16 | 16 |
|
17 | 17 | <%# If this is a new condition then display the interactive controls. otherwise just display the logic %> |
18 | 18 | <% if condition.nil? %> |
19 | | - <div class="form-label bold">Add condition</div> |
20 | | - <div class="row mb-3"> |
21 | | - <div class="col-md-9 pe-2"> |
22 | | - <div class="form-label bold"><%= _('Option') %></div> |
23 | | - <%= select_tag(:question_option, options_from_collection_for_select(question.question_options.sort_by(&:number), "id", "text", |
24 | | - question.question_options.sort_by(&:number)[0]), {class: 'form-select regular', 'data-bs-style': 'dropdown-toggle bg-white px-4 py-3', name: name_start + "[question_option][]"}) %> |
25 | | - </div> |
26 | | - <div class="col-md-3 pe-2"> |
27 | | - <div class="form-label bold"><%= _('Action') %></div> |
28 | | - <%= select_tag(:action_type, options_for_select(action_type_arr, :remove), {name: name_start + "[action_type]", class: 'action-type form-select narrow', 'data-bs-style': 'dropdown-toggle bg-white px-4 py-3'}) %> |
29 | | - </div> |
30 | | - </div> |
31 | | - <div class="row d-flex mb-3"> |
32 | | - <div class="col-md-10 pe-2"> |
33 | | - <div class="form-label bold display-if-action-remove"><%= _('Target') %></div> |
34 | | - <div class="remove-dropdown"> |
35 | | - <%= select_tag(:remove_question_id, remove_question_group, {name: name_start + "[remove_question_id][]", class: 'form-select regular', multiple: true, 'data-bs-style': 'dropdown-toggle bg-white px-4 py-3'}) %> |
36 | | - </div> |
37 | | - <div class="webhook-replacement display-off my-auto text-center"> |
38 | | - <%= link_to _('Edit email'), '#' %> |
39 | | - </div> |
40 | | - <%= hidden_field_tag(name_start + "[number]", condition_no) %> |
41 | | - </div> |
42 | | - <div class="col-md-2 align-self-center"> |
43 | | - <a href="#anotherurl" class="delete-condition btn btn-primary"><%= _('Remove') %></a> |
44 | | - </div> |
45 | | - <%= render partial: 'org_admin/conditions/webhook_form', locals: {name_start: name_start, condition_no: condition_no} %> |
46 | | - </div> |
| 19 | + <%= render partial: 'org_admin/conditions/new_condition_form', |
| 20 | + locals: { action_type_arr: action_type_arr, |
| 21 | + condition_no: condition_no, |
| 22 | + question: question, |
| 23 | + name_start: name_start, |
| 24 | + remove_question_group: remove_question_group, |
| 25 | + view_email_content_info: view_email_content_info |
| 26 | + } |
| 27 | + %> |
| 28 | + |
47 | 29 | <% else %> |
48 | | - <% |
49 | | - qopt = condition[:question_option_id].any? ? QuestionOption.find_by(id: condition[:question_option_id].first): nil |
50 | | - rquesArray = condition[:remove_question_id].any? ? Question.where(id: condition[:remove_question_id]) : nil |
| 30 | + <%= render partial: 'org_admin/conditions/existing_condition_display', |
| 31 | + locals: { action_type_arr: action_type_arr, |
| 32 | + condition: condition, |
| 33 | + condition_no: condition_no, |
| 34 | + name_start: name_start, |
| 35 | + question: question, |
| 36 | + remove_question_group: remove_question_group, |
| 37 | + view_email_content_info: view_email_content_info |
| 38 | + } |
51 | 39 | %> |
52 | | - <div class="col-md-3 pe-2"> |
53 | | - <%= qopt[:text]&.slice(0, 25) %> |
54 | | - <%= hidden_field_tag(name_start + "[question_option][]", condition[:question_option_id]) %> |
55 | | - </div> |
56 | | - <div class="col-md-3 pe-2"> |
57 | | - <%= condition[:action_type] == 'remove' ? 'Remove' : 'Email' %> |
58 | | - <%= hidden_field_tag(name_start + "[action_type]", condition[:action_type]) %> |
59 | | - </div> |
60 | | - <div class="col-md-3 pe-2"> |
61 | | - <% if !rquesArray.nil? %> |
62 | | - <% rquesArray.each do |rques| %> |
63 | | - Question <%= rques[:number] %>: <%= rques.text.gsub(%r{</?p>}, '').slice(0, 50) %> |
64 | | - <%= '...' if rques.text.gsub(%r{</?p>}, '').length > 50 %> |
65 | | - <br> |
66 | | - <% end %> |
67 | | - <%= hidden_field_tag(name_start + "[remove_question_id][]", condition[:remove_question_id]) %> |
68 | | - <% else %> |
69 | | - <% |
70 | | - hook_tip = "Name: #{condition[:webhook_data]['name']}\nEmail: #{condition[:webhook_data]['email']}\n" |
71 | | - hook_tip += "Subject: #{condition[:webhook_data]['subject']}\nMessage: #{condition[:webhook_data]['message']}" |
72 | | - %> |
73 | | - <span title="<%= hook_tip %>"><%= condition[:webhook_data]['email'] %></span> |
74 | | - <br>(<%= view_email_content_info %>) |
75 | 40 |
|
76 | | - <%= hidden_field_tag(name_start + "[webhook-email]", condition[:webhook_data]['email']) %> |
77 | | - <%= hidden_field_tag(name_start + "[webhook-name]", condition[:webhook_data]['name']) %> |
78 | | - <%= hidden_field_tag(name_start + "[webhook-subject]", condition[:webhook_data]['subject']) %> |
79 | | - <%= hidden_field_tag(name_start + "[webhook-message]", condition[:webhook_data]['message']) %> |
80 | | - <% end %> |
81 | | - <%= hidden_field_tag(name_start + "[number]", condition_no) %> |
82 | | - </div> |
83 | | - <div class="col-md-3"> |
84 | | - <a href="#anotherurl" class="delete-condition"><%= _('Remove') %></a> |
85 | | - </div> |
86 | 41 | <% end %> |
87 | 42 | </div> |
0 commit comments