add user_info

This commit is contained in:
chris authored and ihower committed 2011-04-13 18:22:50 +08:00
1 parent a06aa15721
commit 318c264cae
30 files changed
+347 -218

No files matched your search

@@ -1,25 +0,0 @@
<%= fields_for 'user[user_roles][attributes]', attribute, :index => nil do |f| %>
<%#= f.hidden_field :id unless attribute.new_record? %>
<% if attr["locale"] %>
<p>
<%#= f.hidden_field :key, :value => attr["key"] %>
<% if attr["markup"] == "text_field" %>
<% @site_valid_locales.each do |locale| %>
<%= f.label attr.i18n_variable[locale] %>
<%= text_field_tag "user[user_roles][attributes][i18n_user][#{locale}]", (attribute.i18n_user[locale] rescue nil) %>
<% end -%>
<% elsif attr["markup"] == "select" %>
<%= f.select "#{attr["key"]}_#{I18n.locale}", attr["options_#{I18n.locale}"].to_a %>
<% end -%>
</p>
<% else %>
<p>
<%= f.label attr["name"] %>
<% if attr["markup"] == "text_field" %>
<%= f.text_field "#{attr["key"]}" %>
<% elsif attr["markup"] == "select" %>
<%= f.select "#{attr["key"]}", attr["options"].to_a %>
<% end -%>
</p>
<% end -%>
<% end %>
+31 -6
View File
@@ -19,17 +19,42 @@
</p>
</div>
<% @user_role_models.each do |ua| %>
<%= render :partial => 'user_role',
:object => (@user.user_roles.detect {|u| u.key == ua.key } || @user.user_roles.build),
:locals => {:ua => ua} %>
<% end -%>
<% if @user_info_models %>
<fieldset>
<legend><%= t('panel.infos') %></legend>
<% @user_info_models.each do |ua| %>
<fieldset>
<%= render :partial => 'user_attribute',
:object => (@user.user_infos.detect {|u| u.key == ua.key } || @user.user_infos.build),
:locals => {:ua => ua, :type => 'info'} %>
</fieldset>
<% end -%>
</fieldset>
<% end %>
<%= hidden_field_tag :active_roles, @user.active_roles.size > 0 %>
<% if @user_role_models %>
<fieldset id="roles" <%= raw(' style="display: none;"') unless (@user.active_roles.size > 0 rescue nil) %>>
<legend><%= t('panel.roles') %></legend>
<% @user_role_models.each do |ua| %>
<fieldset id="role_<%= ua.key %>" <%= raw(' style="display: none;"') unless (@user.active_roles.include?(ua.key) rescue nil) %>>
<%= render :partial => 'user_attribute',
:object => (@user.user_roles.detect {|u| u.key == ua.key } || @user.user_roles.build),
:locals => {:ua => ua, :type => 'role'} %>
</fieldset>
<% end -%>
</fieldset>
<% end %>
<% content_for :page_specific_javascript do %>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#select_user_roles input').click(function(){
$("#role_"+this.value).toggle();
$('#role_'+this.value).toggle();
if($("#select_user_roles input:checked").length > 0)
{ $('#roles').show(); }
else
{ $('#roles').hide(); }
});
});
</script>
@@ -0,0 +1,17 @@
<fieldset>
<legend><%= am.i18n_variable[I18n.locale] %></legend>
<table>
<% am.attribute_models.each do |attr| %>
<tr>
<td><%= attr.i18n_variable[I18n.locale] %></td>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= show_user_attribute["#{attr.key}_#{I18n.locale}"] rescue nil %>
<% else %>
<%= show_user_attribute["#{attr.key}"] rescue nil %>
<% end %>
</td>
</tr>
<% end %>
</table>
</fieldset>
+34 -38
View File
@@ -1,42 +1,38 @@
<fieldset id="attribute_<%= ua.key %>"<%= raw(' style="display: none;"') unless (@user.active_attributes.include?(ua.key) rescue nil) %>>
<%= fields_for "user[user_#{type}s]", user_attribute, :index => nil do |f| %>
<legend><%= ua.i18n_variable[I18n.locale] %></legend>
<%= f.hidden_field :key, :value => ua.key %>
<%= f.hidden_field :id unless user_attribute.new_record? %>
<%= fields_for 'user[user_roles]', user_role, :index => nil do |f| %>
<legend><%= ua.i18n_variable[I18n.locale] %></legend>
<%= f.hidden_field :key, :value => ua.key %>
<%= f.hidden_field :id unless user_role.new_record? %>
<table>
<tr>
<th><%= t('admin.role') %></th>
<% @site_valid_locales.each do |locale| %>
<th style="color:<%= colorize_in_use_locale(locale) %>"><%= locale %></th>
<% end %>
</tr>
<% ua.attribute_models.each do |attr| %>
<tr>
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user[user_roles][][#{attr.key}_#{locale}]", (user_role["#{attr.key}_#{locale}"] rescue nil) %>
</td>
<% end -%>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= text_field_tag "user[user_roles][][#{attr.key}]", (user_role[attr.key] rescue nil) %>
<% elsif attr["markup"] == "select" %>
<%= select_tag "user[user_roles][][#{attr.key}]", options_for_select(attr["options"], user_role[attr.key]) %>
<% end -%>
</td>
<% end -%>
</tr>
<table>
<tr>
<th><%= t("admin.key") %></th>
<% @site_valid_locales.each do |locale| %>
<th style="color:<%= colorize_in_use_locale(locale) %>"><%= locale %></th>
<% end %>
</table>
</tr>
<% end %>
<% ua.attribute_models.each do |attr| %>
<tr>
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user[user_#{type}s][][#{attr.key}_#{locale}]", (user_attribute["#{attr.key}_#{locale}"] rescue nil) %>
</td>
<% end -%>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= text_field_tag "user[user_#{type}s][][#{attr.key}]", (user_attribute[attr.key] rescue nil) %>
<% elsif attr["markup"] == "select" %>
<%= select_tag "user[user_#{type}s][][#{attr.key}]", options_for_select(attr["options"], user_attribute[attr.key]) %>
<% end -%>
</td>
<% end -%>
</tr>
<% end %>
</table>
</fieldset>
<% end %>
+2 -2
View File
@@ -8,7 +8,7 @@
<table>
<tr>
<th><%= t('panel.attributes') %></th>
<th><%= t('panel.roles') %></th>
<th><%= t('panel.name') %></th>
<th><%= t('panel.email') %></th>
<th><%= t('panel.action') %></th>
@@ -16,7 +16,7 @@
<% @users.each do |user| %>
<tr>
<td><%= user.get_attributes %></td>
<td><%= user.get_roles %></td>
<td><%= user[:name] %></td>
<td><%= user.email %></td>
<td>
+19 -18
View File
@@ -10,23 +10,24 @@
<%= @user.email %>
<% @user.get_active_attribute_models.each do |am| %>
<% user_role = @user.get_role_from_model_key(am.key) %>
<% if @user_info_models %>
<fieldset>
<legend><%= am.i18n_variable[I18n.locale] %></legend>
<table>
<% am.attribute_models.each do |attr| %>
<tr>
<td><%= attr.i18n_variable[I18n.locale] %></td>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= user_role["#{attr.key}_#{I18n.locale}"] %>
<% else %>
<%= user_role["#{attr.key}"] %>
<% end %>
</td>
</tr>
<% end %>
</table>
<legend><%= t('panel.infos') %></legend>
<% @user_info_models.each do |am| %>
<%= render :partial => 'show_user_attribute',
:object => @user.get_info_from_model_key(am.key),
:locals => {:am => am} %>
<% end -%>
</fieldset>
<% end -%>
<% end %>
<% if @user.active_roles.size > 0 %>
<fieldset>
<legend><%= t('panel.roles') %></legend>
<% @user.get_active_role_models.each do |am| %>
<%= render :partial => 'show_user_attribute',
:object => @user.get_role_from_model_key(am.key),
:locals => {:am => am} %>
<% end -%>
</fieldset>
<% end %>