Reduce duplicates.

Akinori MUSHA 10 anni fa
parent
commit
edb87b5d38
1 ha cambiato i file con 8 aggiunte e 32 eliminazioni
  1. 8 32
      app/views/agents/_action_menu.html.erb

+ 8 - 32
app/views/agents/_action_menu.html.erb

@@ -20,12 +20,10 @@
20 20
   </li>
21 21
 
22 22
   <li>
23
-    <% if agent.disabled? %>
24
-      <%= link_to '#', 'data-toggle' => 'modal', 'data-target' => "#confirm-enable-agent#{agent.id}" do %>
23
+    <%= link_to '#', 'data-toggle' => 'modal', 'data-target' => "#confirm-agent#{agent.id}" do %>
24
+      <% if agent.disabled? %>
25 25
         <i class="glyphicon glyphicon-play"></i> Enable agent
26
-      <% end %>
27
-    <% else %>
28
-      <%= link_to '#', 'data-toggle' => 'modal', 'data-target' => "#confirm-disable-agent#{agent.id}" do %>
26
+      <% else %>
29 27
         <i class="glyphicon glyphicon-pause"></i> Disable agent
30 28
       <% end %>
31 29
     <% end %>
@@ -54,8 +52,7 @@
54 52
   </li>
55 53
 </ul>
56 54
 
57
-<% if agent.disabled? %>
58
-<div id="confirm-enable-agent<%= agent.id %>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="confirmEnableAgentLabel" aria-hidden="true">
55
+<div id="confirm-agent<%= agent.id %>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="confirmAgentLabel" aria-hidden="true">
59 56
   <div class="modal-dialog modal-sm">
60 57
     <div class="modal-content">
61 58
       <div class="modal-header">
@@ -63,17 +60,17 @@
63 60
         <h4 class="modal-title">Confirm</h4>
64 61
       </div>
65 62
       <div class="modal-body">
66
-        <p>Enable &quot;<%= agent.name %>&quot;?</p>
63
+        <p><% if agent.disabled? %>Enable<% else %>Disable<% end %> &quot;<%= agent.name %>&quot;?</p>
67 64
       </div>
68 65
       <div class="modal-footer">
69 66
         <%= form_for(agent, as: :agent, url: agent_path(agent, return: returnTo), method: 'PUT') do |f| %>
70
-          <% if agent.can_receive_events? %>
67
+          <% if agent.disabled && agent.can_receive_events? %>
71 68
             <div class="form-group">
72 69
               <%= check_box_tag check_box_id = "agent#{agent.id}_drop_pending_events", 'true', false, name: :drop_pending_events %>
73 70
               <%= label_tag check_box_id, 'Drop pending events' %>
74 71
             </div>
75 72
           <% end %>
76
-          <%= f.hidden_field :disabled, value: 'false' %>
73
+          <%= f.hidden_field :disabled, value: (!agent.disabled).to_s %>
77 74
           <%= f.button 'No', class: 'btn btn-default', 'data-dismiss' => 'modal' %>
78 75
           <%= f.submit 'Yes', class: 'btn btn-primary' %>
79 76
         <% end %>
@@ -81,25 +78,4 @@
81 78
     </div>
82 79
   </div>
83 80
 </div>
84
-<% else %>
85
-<div id="confirm-disable-agent<%= agent.id %>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="confirmDisableAgentLabel" aria-hidden="true">
86
-  <div class="modal-dialog modal-sm">
87
-    <div class="modal-content">
88
-      <div class="modal-header">
89
-        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
90
-        <h4 class="modal-title">Confirm</h4>
91
-      </div>
92
-      <div class="modal-body">
93
-        <p>Disable &quot;<%= agent.name %>&quot;?</p>
94
-      </div>
95
-      <div class="modal-footer">
96
-        <%= form_for(agent, as: :agent, url: agent_path(agent, return: returnTo), method: 'PUT') do |f| %>
97
-          <%= f.hidden_field :disabled, value: 'true' %>
98
-          <%= f.button 'No', class: 'btn btn-default', 'data-dismiss' => 'modal' %>
99
-          <%= f.submit 'Yes', class: 'btn btn-primary' %>
100
-        <% end %>
101
-      </div>
102
-    </div>
103
-  </div>
104
-</div>
105
-<% end %>
81
+