Orbit/app/views/panel/users/_form.html.erb

55 lines
1.8 KiB
Plaintext

<div id="select_user_attributes">
<% @user_attributes.each do |ua| %>
<%= check_box_tag "user[use_attributes][]", ua.key, @user.use_attributes.include?(ua.key) %> <%= ua.name %>
<% end -%>
<%= hidden_field_tag 'user[use_attributes][]','' %>
</div>
<div>
<p>
<%= f.label :email %>
<%= f.text_field :email %>
</p>
</div>
<% @user_attributes.each do |ua| %>
<div id="attribute_<%= ua.key %>"<%= raw(' style="display: none;"') unless @user.use_attributes.include?(ua.key) %>>
<h3><%= ua.name %></h3>
<% ua.attrs.each do |attr| %>
<% if attr["locale"] %>
<p>
<%= f.label attr["name_#{I18n.locale}"] %>
<% if attr["type"] == "text_field" %>
<% VALID_LOCALES.each do |locale| %>
<%= f.text_field "#{ua.key}_#{attr["key"]}_#{locale}" %>(<%= locale %>)
<% end -%>
<% elsif attr["type"] == "select" %>
<%= f.select "#{ua.key}_#{attr["key"]}_#{I18n.locale}", attr["options_#{I18n.locale}"].to_a %>
<% end -%>
</p>
<% else %>
<p>
<%= f.label attr["name"] %>
<% if attr["type"] == "text_field" %>
<%= f.text_field "#{ua.key}_#{attr["key"]}" %>
<% elsif attr["type"] == "select" %>
<%= f.select "#{ua.key}_#{attr["key"]}", attr["options"].to_a %>
<% end -%>
</p>
<% end -%>
<% end -%>
</div>
<% end -%>
<% content_for :page_specific_javascript do %>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#select_user_attributes input').click(function(){
$("#attribute_"+this.value).toggle();
});
});
</script>
<% end -%>