<%if @noti_group.notification_type == "webhook" %>
<%else%>
<%end%> <% if can? :manage, NotificationGroup %>

Notification Group - <%= @noti_group.id.blank? ? "New" : "Edit"%>

<%= form_for(@noti_group, as: :notification_group, url:create_update_notification_group_alerts_path , method: :put, :html => {:class => 'notification_group form-horizontal'}) do |f| %> <%= f.hidden_field :id%>
<%= f.text_field :name ,:class => 'form-control',:data => {"validation" => 'required'},:style=> "width:130%"%>


<%= f.hidden_field :notification_type, value: "webhook" %>

Webhook Endpoints

<%=link_to " Add New".html_safe,"javascript:void(0);", {:class => "btn btn-warning add-nested-form pull-right"} %>


<%= label_tag :name,'Name' %>
<%= label_tag :url,'Webhook Endpoint' %>
<%= label_tag :enabled,'Enabled' %>
<%= label_tag :shared_key,'Shared Key' %>

<%=f.fields_for :webhook_endpoints, (@noti_group.webhook_endpoints.present? ? @noti_group.webhook_endpoints : @noti_group.webhook_endpoints.build) do |f|%>

<%= f.text_field :name, :data => {validation: 'required'},:class=>"form-control name", :placeholder=>"Name"%>
<%= f.text_field :url,:class=>"form-control url", :placeholder=>"URL" ,'data-validation-help' =>"eg..http://www.example.com",:data => {:validation => "url_ip" , 'validation-error-msg' => "Please Specify a valid URL" }%>
<%=f.select(:enabled, [["Yes",true],["No",false]],{},:class=>"form-control") %>
<%= f.password_field :shared_key, :value => f.object.shared_key, :autocomplete => "off",:class=>"form-control",:placeholder=>"Shared Key", :data => { validation: 'required length'}, 'data-validation-length'=> "8-63"%>
<%= f.hidden_field :id unless @noti_group.id.blank?%> <%= f.hidden_field :_destroy%> <%= link_to " X ","javascript:void(0);", {:class => "pull-right icon-delete remove-nested-form btn btn-danger"} %>

<% end %>

<%= f.submit @noti_group.id.blank? ? "Create" : "Update",:class=>"btn btn-success" %> <%= link_to "Cancel", notification_group_alerts_path, :class => "btn btn-primary"%>
<% end %>
<% end %> <%= render :partial => 'wbhk_notification_group_list'%>
<%if @noti_group.notification_type == "webhook" %>
<%else%>
<%end%> <% if can? :manage, NotificationGroup %>

Notification Group - <%= @noti_group.id.blank? ? "New" : "Edit"%>

<%= form_for(@noti_group, as: :notification_group, url:create_update_notification_group_alerts_path , method: :put, :html => {:class => 'notification_group form-horizontal'}) do |f| %> <%= f.hidden_field :id%> <%= hidden_field_tag :allow_sms ,@allow_sms%>
<%= f.text_field :name ,:class => 'form-control',:data => {"validation" => 'required'}%>
<%=f.label :type, "Type", :class=>"col-sm-4 control-label"%>
<%= f.select :notification_type, options_for_select([['Email','email'],['Mobile','mobile'],['Email and Mobile','both']],@noti_group.notification_type),{},{class: "form-control noti-type"}%>
<%=f.label :user, "Select Organisation Users", :class=>"col-sm-4 control-label"%>
<%= f.select 'user_ids', @user.map{|p| [p[1],p[0]]},{},{:multiple => true, :class=>"form-control custom-user", :placeholder=>"Type to select Users",:data => {"validation" => 'validation_custom_email'}} %>

<%= f.text_field :mobile ,:class => 'form-control custom-mobile external-field', :data => {"validation" => 'phone-format-only-integer'}%> <%if @allow_sms%> Note: Enter mobile number in the following format +91-1234567890 <%else%> Note: Please enable atleast one SMS group in gateway setting to enable this field <% end %>
<%= f.submit @noti_group.id.blank? ? "Create" : "Update",:class=>"btn btn-success" %> <%= link_to "Cancel", notification_group_alerts_path, :class => "btn btn-primary"%>
<% end %>
<% end %> <%= render :partial => 'notification_group_list'%>