🎯 Targets Configuration
Policy Type: <%= @waf_policy.policy_type.humanize %>
<% unless @waf_policy.new_record? %>
(Cannot change policy type after creation)
<% end %>
<% if @waf_policy.new_record? %>
<%= form.label :policy_type, "Policy Type", class: "block text-sm font-medium text-gray-700" %>
<%= form.select :policy_type,
options_for_select(@policy_types.map { |type| [type.humanize, type] }, @waf_policy.policy_type),
{ prompt: "Select policy type" },
{ class: "block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",
id: "policy-type-select", disabled: !@waf_policy.new_record? } %>
<% else %>
<%= form.label :policy_type, "Policy Type", class: "block text-sm font-medium text-gray-700" %>
<%= @waf_policy.policy_type.humanize %>
<%= form.hidden_field :policy_type %>
<% end %>
<% if @waf_policy.country_policy? %>
<%= form.label :targets, "Countries", class: "block text-sm font-medium text-gray-700 mb-2" %>
<%= select_tag "waf_policy[targets][]",
options_for_select(@waf_policy.targets.map { |code| [CountryHelper.display_with_flag(code), code] }, @waf_policy.targets),
{
multiple: true,
class: "hidden",
data: { "country-selector-target": "select" }
} %>
<% end %>
<% if @waf_policy.asn_policy? %>
<%= form.label :targets, "ASN Numbers", class: "block text-sm font-medium text-gray-700" %>
<%= text_field_tag "waf_policy[targets][]", @waf_policy.targets.join(', '),
class: "block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",
placeholder: "e.g., 12345, 67890" %>
Enter ASNs separated by commas
<% end %>
<% if @waf_policy.company_policy? %>
<%= form.label :targets, "Companies", class: "block text-sm font-medium text-gray-700" %>
<%= text_field_tag "waf_policy[targets][]", @waf_policy.targets.join(', '),
class: "block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",
placeholder: "e.g., AWS, Digital Ocean, Google Cloud" %>
Enter company names separated by commas
<% end %>
<% if @waf_policy.network_type_policy? %>
<%= form.label :targets, "Network Types", class: "block text-sm font-medium text-gray-700" %>
<% end %>