<%= form_for(user, as: :user, url: user.new_record? ? admin_users_path : admin_user_path(user.id), method: user.new_record? ? :post : :put, :html => {:class => 'new_user form-horizontal'}) do |f| %>

<%= user.new_record? ? "New User" : "Edit User" %>

<%=f.label :full_name, "Full Name *", :class=>"col-sm-2 control-label"%>
<%= f.text_field :full_name,:class=>"form-control",:placeholder=>"Full Name", :data => {:validation => "required"} %>
<%=f.label :email, "Email *", :class=>"col-sm-2 control-label"%>
<%= f.email_field :email, :class=>"form-control",:placeholder=>"Email ", :autocomplete => "off",disabled: user.email.present?, :data => {:validation => "required email check_user_exist email-valid", 'validation-url' => email_exist_admin_users_url,'id' => user.id} %>
<%=f.label :password, "Password *", :class=>"col-sm-2 control-label"%>
<% validation = {"validation" => "required password-length", "validation-optional" => "true"} -%> <% validation.delete("validation-optional") if user.new_record? -%> <%= f.password_field :password, :autocomplete => "off",:class=>"form-control",:placeholder=>"Password",:data => validation%>
<%=f.label :password_confirmation, "Confirm Password *", :class=>"col-sm-2 control-label"%>
<%= f.password_field :password_confirmation, autocomplete: "off",:class=>"form-control",:placeholder=>"Confirm Password", :data => {:validation => "confirmation", "validation-confirm" => "user[password]"} %>
<%= f.label :role_id, "Role *", :class=>"col-sm-2 control-label"%>
<%= f.select :role_id, Role.all.reject { |s| s.name.humanize == "Api" }.map {|r| [(Role::ROLES_NAME_MAPPING[r.name] || r.name.humanize), r.id]}, {}, :class=>"form-control", :data => {:validation => "required"} %>
<%=f.label :phone_number, "Phone *", :class=>"col-sm-2 control-label"%> <% validation = {"validation" => "required phone-only-integer international-code"}-%>
<%= text_field_tag :phone_number,user.phone_number.blank? ? '' : user.phone_number.split('-')[1].blank? ? user.phone_number : user.phone_number.split('-')[1],:class=>"form-control country-code",:placeholder=>"Phone Number *", :data => validation,'data-validation-help' =>"Note: Entered number must be free of spaces and special characters." %> <%= f.hidden_field :phone_number, :value => ''%> <%= hidden_field_tag :country_code, user.phone_number.blank? ? '' : user.phone_number.split('-')[0].blank? ? '' : user.phone_number.split('-')[0]%>
<%= label_tag "user_authorized_networks", "Permitted Networks", :class=>"col-sm-2 control-label"%>
Permission Network/Network Tags
Full Access <% full_tags = selected_full_tags(@user) || [] %> <%= render 'shared/resources_dropdown', field_id: 'user_authorized_networks_full', input_name: 'user[authorized_networks][full][]', placeholder: 'Type to add Network', label_text: '', custom_class: 'no-label auth-network-full', dropdown_width: '395px', resource_model: @user, config_type: "user", selected_values: full_tags, resource_types: 'network,network_tag', value_formatters: { 'network' => 'network:{id}', 'network_tag' => 'Tag:{name}' }, custom_groups: [ { label: 'All', value: 'all:all', rt: 'all', rid: 'all' } ] %>
Read Only <% limited_tags = selected_limited_tags(@user) || [] %> <%= render 'shared/resources_dropdown', field_id: 'user_authorized_networks_limited', input_name: 'user[authorized_networks][limited][]', placeholder: 'Type to add Network', label_text: '', custom_class: 'no-label auth-network-limited', dropdown_width: '395px', resource_model: @user, config_type: "user", selected_values: limited_tags, resource_types: 'network,network_tag', value_formatters: { 'network' => 'network:{id}', 'network_tag' => 'Tag:{name}' }, custom_groups: [ { label: 'All', value: 'all:all', rt: 'all', rid: 'all' } ] %>
<% if user.new_record? -%> <%= f.submit "Create",:class=>"btn btn-success" %> <% else -%> <%= f.submit "Update",:class=>"btn btn-success" %> <% end -%> <%= link_to "Cancel", admin_users_path, :class => "btn btn-primary" %>
<%end%>