Changes for sub_roles

Issues: update doesn't create new i18n_variables, role form has bugs
This commit is contained in:
chris2tof committed 2011-12-18 10:07:42 +08:00
1 parent d23cf152da
commit d27d7a623c
62 files changed
+508 -1142

No files matched your search

@@ -0,0 +1,35 @@
<tr id="<%= "attribute_#{attribute_field.id}" if !attribute_field.new_record? %>" class="list_item">
<td><%= attribute_field.new_record? ? (f.text_field :key) : attribute_field.key %></td>
<td class='select_mulitlingual' style='text-align:center'>
<%= f.check_box :locale %>
</td>
<%= f.fields_for :i18n_variable, (attribute_field.i18n_variable.nil? ? attribute_field.build_i18n_variable : attribute_field.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:130px" %></td>
<% end %>
<%= f.hidden_field :id %>
<% end %>
<td class='select_type'>
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
<div <%= attribute_field[:markup].eql?('select') ? nil : "style='display:none'"%>>
<%= t('admin.options') %>:
<%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %>
</div>
</td>
<td>
<span class="action">
<% if attribute_field.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<% else %>
<%= f.hidden_field :id %>
<% if attribute_field.is_built_in? %>
<a href="#" class="switch" id="<%= attribute_field.id %>"></a>
<%= f.hidden_field :disabled, :value => attribute_field.is_disabled? , :class => 'built_in_state' %>
<% else %>
<a href="#" class="remove_existing_record"><%= t(:delete) %></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
<% end %>
</span>
</td>
</tr>
@@ -1,36 +0,0 @@
<%= fields_for "user_#{@attribute_type}_model[attribute_models][]", attribute_model, :index => nil do |f| %>
<tr class="list_item">
<td><%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %></td>
<td class='select_mulitlingual' style='text-align:center'>
<%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %>
<%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %>
</td>
<% @site_valid_locales.each do |locale| %>
<td><%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %></td>
<% end %>
<td class='select_type'>
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
<div <%= attribute_model[:markup].eql?('select') ? nil : "style='display:none'"%>>
<%= t('admin.options') %>:
<%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %>
</div>
</td>
<td>
<span class="action">
<% if attribute_model.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<% else %>
<% if attribute_model.is_built_in? %>
<a href="#" class="change_built_in switch" id="<%= attribute_model.id %>"></a>
<%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %>
<% else %>
<a href="#" class="remove_existing_record delete"><%= t(:delete) %></a>
<%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %>
<% end %>
<%= f.hidden_field :id %>
<%= f.hidden_field :key %>
<% end %>
</span>
</td>
</tr>
<% end %>
-57
View File
@@ -1,57 +0,0 @@
<div id="UserRole_block" class="roles_block">
<h2><%= t("admin.user_#{@attribute_type}") %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td style="color:<%= colorize_in_use_locale(locale) %>"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user_#{@attribute_type}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
</td>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
<div id="attributes_block" class="roles_block">
<h2>Attributes</h2>
<div class="info_input">
<table id='attributes' border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td style="color:<%= colorize_in_use_locale(locale) %>"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5"><a href="#" class="add"><%= t(:add) %></a></td>
</tr>
</tfoot>
<tbody>
<%= render :partial => 'admin/attributes/attribute_model', :collection => @attribute.attribute_models %>
</tbody>
</table>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "attribute_form" %>
<% end -%>
+6 -8
View File
@@ -2,15 +2,13 @@
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="porfile">
<%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %>
<div id="profile">
<%= form_for @attribute, :url => eval("admin_#{@attribute_type}_path(@attribute)") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %>
<div id="update" class='buttom clear'>
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %>
</div>
<div id="back" class='buttom clear'>
<%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => false } %>
<div class='button_bar'>
<%= link_back %>
<%= link_to t('update'), "#", :onclick=>"$('#edit_#{@attribute_type}_#{@attribute.id}').submit()" %>
</div>
<% end -%>
<% end %>
</div>
+25 -20
View File
@@ -3,32 +3,37 @@
<% end %>
<div class="main_list">
<div id="add_new" class="buttom clear">
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %>
<div class="button_bar up">
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
</div>
<ul>
<li class="list_head clear">
<span class="<%= @attribute_type %>s"><%= t("admin.#{@attribute_type}") %></span>
<span class="action"><%= t('admin.action') %></span>
</li>
<table>
<thead>
<tr>
<td class="<%= @attribute_type %>s"><%= t("admin.#{@attribute_type}") %></td>
<td class="action"><%= t('admin.action') %></td>
</tr>
</thead>
<tbody>
<% @attributes.each do |attribute| %>
<li id="attribute_<%= attribute.id %>" class="list_item <%= "#{attribute.is_disabled? ? 'disable' : ''}" %> clear">
<span class="<%= @attribute_type %>s <%= attribute.i18n_variable[:key].downcase %>"><%= attribute.i18n_variable[I18n.locale] %></span>
<span class="action">
<tr id="attribute_<%= attribute.id %>" class="have <%= "#{attribute.is_disabled? ? 'disable' : ''}" %>">
<td class="<%= @attribute_type %>s <%= attribute.key.downcase %>"><%= attribute.i18n_variable[I18n.locale] %></span>
<td class="action">
<%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %>
<% if attribute.is_built_in? %>
<%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% else %>
<%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% if !attribute.is_built_in? %>
<%= link_to t(:delete), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
<% end %>
</span>
</li>
</td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<% end %>
</ul>
<div id="add_new" class="buttom clear">
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %>
</tbody>
</table>
<div class="button_bar">
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
</div>
</div>
+6 -12
View File
@@ -2,19 +2,13 @@
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="porfile">
<%= form_for @attribute, :url => eval("admin_infos_path") do |f| %>
<div id="profile">
<%= form_for @attribute, :url => eval("admin_#{@attribute_type}s_path") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/infos/form", :locals => { :f => f, :is_new => true } %>
<div id="create" class='buttom clear'>
<%= link_to t('create'), "#", :onclick=>"$('#new_attribute').submit()" %>
</div>
<div id="back" class='buttom clear'>
<%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => true } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('create'), "#", :onclick=>"$('#new_#{@attribute_type}').submit()" %>
</div>
<% end -%>
</div>
</div>
@@ -0,0 +1,3 @@
<%= f.fields_for :attribute_fields, attribute_field do |f| %>
<%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
+70
View File
@@ -0,0 +1,70 @@
<div class="attributes_block <%= @class %>">
<h2><%= t("admin.#{@attribute_type}") %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "#{@attribute_type}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
</td>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
<div class="attributes_block <%= @class %>">
<h2>Attributes</h2>
<div class="info_input">
<table id='attributes' border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<%= hidden_field_tag 'attribute_field_count', @attribute.attribute_fields.count %>
<a href="#" class="add"><%= t(:add) %></a>
</td>
</tr>
</tfoot>
<tbody>
<% @attribute.attribute_fields.each do |attribute_field| %>
<%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
</tbody>
</table>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "attribute_form" %>
<script>
$('.attributes_block a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_attribute_fields", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$('#attributes').append(("<%= escape_javascript(add_attribute 'admin/attributes/attribute_field', f, :attribute_fields) %>").replace(old_id, new_id));
});
</script>
<% end %>
-16
View File
@@ -1,16 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="porfile">
<%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %>
<div id="update" class='buttom clear'>
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %>
</div>
<div id="back" class='buttom clear'>
<%= link_back %>
</div>
<% end -%>
</div>
+1 -5
View File
@@ -1,7 +1,3 @@
<%= flash_messages %>
<%= parse_page_edit(@item).html_safe %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "page_edit" %>
<% end -%>
<%= parse_page_edit(@item).html_safe %>
@@ -0,0 +1,3 @@
<%= f.fields_for :attribute_fields, attribute_field do |f| %>
<%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
+50
View File
@@ -0,0 +1,50 @@
<div class="attributes_block <%= @class %>">
<h2><%= t("admin.#{@attribute_type}") %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "#{@attribute_type}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
</td>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
<div id='sub_roles' class="attributes_block <%= @class %>">
<h2>Sub roles</h2>
<% @attribute.sub_roles.each do |sub_role| %>
<%= render :partial => 'form_sub', :object => sub_role, :locals => {:f => f} %>
<% end %>
</div>
</div>
<div id='add_sub_role' class="info_input attributes_block">
<%= hidden_field_tag 'attribute_field_count', @attribute.sub_roles.count %>
<a href="#" class="add"><%= t(:add) %></a>
</div>
<% content_for :page_specific_javascript do %>
<script>
$('#add_sub_role a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_sub_roles", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$('#sub_role_temp_id').attr('value', new_id);
$('#sub_roles').append(("<%= escape_javascript(add_attribute 'admin/roles/sub_role', f, :sub_roles) %>").replace(old_id, new_id));
});
</script>
<% end %>
+3
View File
@@ -0,0 +1,3 @@
<%= f.fields_for :sub_roles, form_sub do |f| %>
<%= render :partial => 'sub_role', :object => form_sub, :locals => {:f => f} %>
<% end %>
+70
View File
@@ -0,0 +1,70 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<%= f.text_field "i18n_variable[#{locale}]", :value => (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
</td>
<% end %>
</tr>
</tbody>
</table>
<div class="attributes_block <%= @class %>">
<h2>Attributes</h2>
<div class="info_input">
<table class="sub_role_attributes" border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %>
<a href="#" class="add"><%= t(:add) %></a>
<%= hidden_field_tag 'sub_role_temp_id', 'new_sub_roles' %>
</td>
</tr>
</tfoot>
<tbody>
<% sub_role.attribute_fields.each do |attribute_field| %>
<%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "attribute_form" %>
<script>
$('.attributes_block a.add').live('click', function(){
var new_parent_id = $(this).next().attr('value');
var old_parent_id = new RegExp("new_sub_roles", "g");
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_attribute_fields", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).next().attr('value', parseInt(new_parent_id) + 1);
$(this).parents('.sub_role_attributes').append(("<%= escape_javascript(add_attribute 'admin/attributes/attribute_field', f, :attribute_fields) %>").replace(old_id, new_id).replace(old_parent_id, new_parent_id));
});
</script>
<% end %>
@@ -1,36 +0,0 @@
<%= fields_for "user_#{@attribute}_model[attribute_models][]", attribute_model, :index => nil do |f| %>
<tr class="list_item">
<td><%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %></td>
<td class='select_mulitlingual' style='text-align:center'>
<%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %>
<%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %>
</td>
<% @site_valid_locales.each do |locale| %>
<td><%= text_field_tag "user_#{@attribute}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %></td>
<% end %>
<td class='select_type'>
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
<div <%= attribute_model[:markup].eql?('select') ? nil : "style='display:none'"%>>
<%= t('admin.options') %>:
<%= text_field_tag "user_#{@attribute}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %>
</div>
</td>
<td>
<span class="action">
<% if attribute_model.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<% else %>
<% if attribute_model.is_built_in? %>
<a href="#" class="change_built_in switch" id="<%= attribute_model.id %>"></a>
<%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %>
<% else %>
<a href="#" class="remove_existing_record delete"><%= t(:delete) %></a>
<%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %>
<% end %>
<%= f.hidden_field :id %>
<%= f.hidden_field :key %>
<% end %>
</span>
</td>
</tr>
<% end %>
@@ -1,57 +0,0 @@
<div id="UserRole_block" class="roles_block <%= @class %>">
<h2><%= t("admin.user_#{@attribute}") %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
</td>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
<div id="attributes_block" class="roles_block <%= @class %>">
<h2>Attributes</h2>
<div class="info_input">
<table id='attributes' border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5"><a href="#" class="add"><%= t(:add) %></a></td>
</tr>
</tfoot>
<tbody>
<%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %>
</tbody>
</table>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "user_attribute_model_form" %>
<% end -%>
@@ -1,31 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%= @title || APP_CONFIG['orbit'] %></title>
<link rel="shortcut icon" href="/favicon.ico">
<%= stylesheet_link_tag "admin" %>
<%= javascript_include_tag "admin" %>
<%= yield :page_specific_css %>
<%= yield :page_specific_javascript %>
<%= csrf_meta_tag %>
</head>
<body>
<div id="panel_banner_link" >
<div id="orbit"><%= render 'layouts/drop_down_menu' %></div>
<div class="hmenu">
<div class="lang"><%= render 'layouts/lang_menu' %></div>
<%= render 'devise/menu/login_items' %>
</div>
</div>
<div id="content">
<div id="sidebar"><%= yield :secondary %></div>
<div class="main">
<%= yield %>
</div>
<div class="tertiary"><%= yield :tertiary %></div>
<div id="panel_footer"><p><%= APP_CONFIG['ruling_digital'] %></p></div>
</div>
</body>
</html>
@@ -1,14 +0,0 @@
<% content_for :secondary do %>
<%= render 'side_bar' %>
<% end %>
<div id="porfile">
<%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %>
</div>
<% end -%>
</div>
@@ -1,41 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div class="main_list">
<div class="button_bar up">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %>
</div>
<table>
<thead>
<tr>
<td class="<%= @attribute %>s"><%= t("admin.#{@attribute}") %></td>
<td class="action"><%= t('admin.action') %></td>
</tr>
</thead>
<tbody>
<% @user_attribute_models.each do |user_attribute_model| %>
<tr id="attribute_<%= user_attribute_model.id %>" class="have <%= "#{user_attribute_model.is_disabled? ? 'disable' : ''}" %>">
<td class="<%= @attribute %>s <%= user_attribute_model.i18n_variable[:key].downcase %>"><%= user_attribute_model.i18n_variable[I18n.locale] %></td>
<td class="action">
<%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %>
<% if user_attribute_model.is_built_in? %>
<%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% else %>
<%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
<% end %>
</td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<% end %>
</tbody>
</table>
<div class="button_bar">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %>
</div>
</div>
@@ -1,18 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="porfile">
<%= form_for @user_attribute_model, :url => eval("admin_user_#{@attribute}_models_path") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/user_attribute_models/form", :locals => { :f => f, :is_new => true } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('create'), "#", :onclick=>"$('#new_user_attribute_model').submit()" %>
</div>
<% end -%>
</div>
@@ -1,3 +0,0 @@
$("#enable_<%= @user_attribute_model.id %>").toggle();
$("#disable_<%= @user_attribute_model.id %>").toggle();
$("#attribute_<%= @user_attribute_model.id %>").toggleClass('disable');
@@ -1,34 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div class="main_list">
<div id="add_new" class="buttom clear">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %>
</div>
<ul>
<li class="list_head clear">
<span class="<%= @attribute %>s"><%= t("admin.#{@attribute}") %></span>
<span class="action"><%= t('admin.action') %></span>
</li>
<% @user_attribute_models.each do |user_attribute_model| %>
<li id="attribute_<%= user_attribute_model.id %>" class="list_item <%= "#{user_attribute_model.is_disabled? ? 'disable' : ''}" %> clear">
<span class="<%= @attribute %>s <%= user_attribute_model.i18n_variable[:key].downcase %>"><%= user_attribute_model.i18n_variable[I18n.locale] %></span>
<span class="action">
<%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %>
<% if user_attribute_model.is_built_in? %>
<%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% else %>
<%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
<% end %>
</span>
</li>
<% end %>
</ul>
<div id="add_new" class="buttom clear">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %>
</div>
</div>
@@ -1,16 +0,0 @@
<h1>New user attribute: <%= @user_attribute.key %></h1>
<% form_for @user_attribute, :url => admin_user_attributes_path do |f| %>
<p>
<%= f.label :key, "Key" %>
<%= f.text_field :key %>
</p>
<%= render :partial => "form", :locals => { :f => f } %>
<p>
<%= f.submit %>
</p>
<% end -%>
+10 -10
View File
@@ -16,27 +16,27 @@
</label>
<label>
<span><%= t('admin.role') %>:</span>
<%= f.select :active_role, @user_role_models.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.key ]}, :selected => (@user.active_role || 'student') %>
<%= f.select :active_role, @roles.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.key ]}, :selected => (@user.active_role || 'student') %>
</label>
</div>
<% @user_info_models.each do |ua| %>
<div id="basic_block" class="roles_block <%= @class %>">
<% @infos.each do |ua| %>
<div id="basic_block" class="attributes_block <%= @class %>">
<h2><%= ua.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'user_attribute',
:object => (@user.user_infos.detect {|u| u.key == ua.key } || @user.user_infos.build),
<%= render :partial => 'attribute',
:object => (@user.infos.detect {|u| u.key == ua.key } || @user.infos.build),
:locals => {:ua => ua, :type => 'info'} %>
</div>
<% end -%>
<div id='role_models'>
<% @user_role_models.each do |ua| %>
<div id="<%= ua.key %>_block" class="roles_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.active_role.eql?(ua.key) rescue nil) || (ua.key.eql?('student') && @user.new_record?)) %>>
<div id='roles'>
<% @roles.each do |ua| %>
<div id="<%= ua.key %>_block" class="attributes_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.active_role.eql?(ua.key) rescue nil) || (ua.key.eql?('student') && @user.new_record?)) %>>
<h2><%= ua.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'user_attribute',
:object => (@user.user_roles.detect {|u| u.key == ua.key } || @user.user_roles.build),
<%= render :partial => 'attribute',
:object => (@user.roles.detect {|u| u.key == ua.key } || @user.roles.build),
:locals => {:ua => ua, :type => 'role'} %>
</div>
<% end -%>
@@ -0,0 +1,26 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</thead>
<tbody>
<% a.get_enabled_attribute_fields.each do |attr| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= show_attribute(@user, attr.id, locale) %>
<% else %>
<%= show_attribute(@user, attr.id) %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
@@ -1,27 +0,0 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</thead>
<tbody>
<% am.get_enabled_attribute_models.each do |attr| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= show_user_attribute(object, attr.key, locale) %>
<% else %>
<%= show_user_attribute(object, attr.key) %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
+10 -10
View File
@@ -1,6 +1,6 @@
<%= fields_for "user[user_#{type}s]", user_attribute, :index => nil do |f| %>
<%= fields_for "user[#{type}s]", attribute, :index => nil do |f| %>
<%= f.hidden_field :key, :value => ua.key %>
<%= f.hidden_field :id unless user_attribute.new_record? %>
<%= f.hidden_field :id unless attribute.new_record? %>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
@@ -13,25 +13,25 @@
</tr>
</thead>
<tbody>
<% ua.get_enabled_attribute_models.each do |attr| %>
<% value = user_attribute.attribute_values.detect{|v| v.key == attr.key } %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][id]", value.id rescue nil %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][key]", attr.key %>
<% ua.get_enabled_attribute_fields.each do |attr| %>
<% value = attribute.attribute_values.detect{|v| v.key == attr.key } %>
<%= hidden_field_tag "user[#{type}s][][attribute_values][][id]", value.id rescue nil %>
<%= hidden_field_tag "user[#{type}s][][attribute_values][][key]", attr.key %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", nil %>
<%= hidden_field_tag "user[#{type}s][][attribute_values][][non_locale]", nil %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user[user_#{type}s][][attribute_values][][#{locale}]", (value[locale] rescue nil) %>
<%= text_field_tag "user[#{type}s][][attribute_values][][#{locale}]", (value[locale] rescue nil) %>
</td>
<% end -%>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= text_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", (value['non_locale'] rescue nil) %>
<%= text_field_tag "user[#{type}s][][attribute_values][][non_locale]", (value['non_locale'] rescue nil) %>
<% elsif attr["markup"] == "select" %>
<%= select_tag "user[user_#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %>
<%= select_tag "user[#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
+1 -1
View File
@@ -2,7 +2,7 @@
<%= render 'side_bar' %>
<% end %>
<div id="porfile">
<div id="profile">
<%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>
+1 -2
View File
@@ -19,9 +19,8 @@
</thead>
<tbody>
<% @users.each do |user| %>
<% active_role = UserRoleModel.get_role_model_from_key(user.active_role) %>
<tr class="have">
<td class="roles <%= active_role.key.downcase rescue nil %>"><%= active_role.i18n_variable[I18n.locale] rescue nil %></td>
<td class="roles <%= user.role.key.downcase rescue nil %>"><%= user.role.i18n_variable[I18n.locale] rescue nil %></td>
<td class="name"><%= user.name ? user.name : 'bob' %></td>
<td class="email"><%= user.email %></td>
<td class="admin"><%= user.admin ? t(:yes_) : t(:no_) %></td>
+1 -1
View File
@@ -2,7 +2,7 @@
<%= render 'side_bar' %>
<% end %>
<div id="porfile">
<div id="profile">
<%= form_for @user, :url => admin_users_path, :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>
+8 -10
View File
@@ -2,7 +2,7 @@
<%= render 'side_bar' %>
<% end %>
<div id="porfile">
<div id="profile" class="clear">
<div id="person">
<% if @user.avatar? %>
@@ -11,20 +11,18 @@
<%= image_tag "person.png" %>
<% end %>
</div>
<% @user_info_models.each do |am| %>
<div id="basic_block" class="roles_block <%= @class %>">
<h2><%= am.i18n_variable[I18n.locale] %></h2>
<% @infos.each do |a| %>
<div id="basic_block" class="attributes_block <%= @class %>">
<h2><%= a.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'show_user_attribute', :locals => {:am => am, :object => @user.get_info_from_model_key(am.key)} %>
<%= render :partial => 'show_attribute', :locals => {:a => a} %>
</div>
<% end -%>
<div id="<%= @user.active_role %>_block" class="roles_block <%= @class %>">
<% active_role = UserRoleModel.get_role_model_from_key(@user.active_role) %>
<h2><%= active_role.i18n_variable[I18n.locale] %></h2>
<div id="<%= @user.role.key %>_block" class="attributes_block <%= @class %>">
<h2><%= @user.role.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'show_user_attribute', :locals => {:am => active_role, :object => @user.get_role_from_model_key(active_role.key)} %>
<%#= render :partial => 'show_attribute', :locals => {:a => active_role, :object => @user.get_role_from_key(active_role.key)} %>
</div>
<div class="button_bar">
<%= link_to t(:edit), edit_admin_user_path(@user) %>