add user_info
This commit is contained in:
parent
73b75ec0b6
commit
2ccc2c9b39
|
@ -69,8 +69,8 @@ class Admin::TranslationsController < ApplicationController
|
||||||
result << var if var.document_class.eql?('language')
|
result << var if var.document_class.eql?('language')
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
@user_attribute_model_i18n_variables = @i18n_variables.inject([]) do |result, var|
|
@user_role_model_i18n_variables = @i18n_variables.inject([]) do |result, var|
|
||||||
result << var if var.document_class.eql?('UserAttributeModel')
|
result << var if var.document_class.eql?('UserRoleModel')
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,46 +1,46 @@
|
||||||
class Admin::UserAttributeModelsController < ApplicationController
|
class Admin::UserRoleModelsController < ApplicationController
|
||||||
|
|
||||||
layout "admin"
|
layout "admin"
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :is_admin?
|
before_filter :is_admin?
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@user_attribute_models = UserAttributeModel.all.entries
|
@user_role_models = UserRoleModel.all.entries
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
@user_role_model = UserRoleModel.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@user_attribute_model = UserAttributeModel.new
|
@user_role_model = UserRoleModel.new
|
||||||
session[:last_page] = get_go_back || admin_user_attribute_models_url
|
session[:last_page] = get_go_back || admin_user_role_models_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
@user_role_model = UserRoleModel.find(params[:id])
|
||||||
@i18n_variable = @user_attribute_model.i18n_variable
|
@i18n_variable = @user_role_model.i18n_variable
|
||||||
session[:last_page] = get_go_back || admin_user_attribute_models_url
|
session[:last_page] = get_go_back || admin_user_role_models_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@user_attribute_model = UserAttributeModel.new(params[:user_attribute_model])
|
@user_role_model = UserRoleModel.new(params[:user_role_model])
|
||||||
@user_attribute_model.save
|
@user_role_model.save
|
||||||
redirect_to :action => :index
|
redirect_to :action => :index
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
@user_role_model = UserRoleModel.find(params[:id])
|
||||||
@user_attribute_model.update_attributes(params[:user_attribute_model])
|
@user_role_model.update_attributes(params[:user_role_model])
|
||||||
|
|
||||||
redirect_to :action => :index
|
redirect_to :action => :index
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
@user_role_model = UserRoleModel.find(params[:id])
|
||||||
@user_attribute_model.destroy
|
@user_role_model.destroy
|
||||||
|
|
||||||
@user_attribute_model.destroy_i18n_variables
|
@user_role_model.destroy_i18n_variables
|
||||||
|
|
||||||
redirect_to :action => :index
|
redirect_to :action => :index
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Panel::UsersController < ApplicationController
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@user = User.new
|
@user = User.new
|
||||||
@user_attribute_models = UserAttributeModel.all.entries
|
@user_role_models = UserRoleModel.all.entries
|
||||||
session[:last_page] = get_go_back || panel_users_url
|
session[:last_page] = get_go_back || panel_users_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class Panel::UsersController < ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@user_attribute_models = UserAttributeModel.all.entries
|
@user_role_models = UserRoleModel.all.entries
|
||||||
session[:last_page] = get_go_back || panel_users_url
|
session[:last_page] = get_go_back || panel_users_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class Panel::UsersController < ApplicationController
|
||||||
if @user.update_attributes(params[:user])
|
if @user.update_attributes(params[:user])
|
||||||
redirect_to :action => :index
|
redirect_to :action => :index
|
||||||
else
|
else
|
||||||
@user_attribute_models = UserAttributeModel.all.entries
|
@user_role_models = UserRoleModel.all.entries
|
||||||
render :action => :edit
|
render :action => :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
class AttributeAttrModel
|
|
||||||
|
|
||||||
include Mongoid::Document
|
|
||||||
|
|
||||||
field :key
|
|
||||||
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
|
|
||||||
field :markup
|
|
||||||
field :locale, :type => Boolean
|
|
||||||
field :list_options, :type => Array
|
|
||||||
|
|
||||||
embedded_in :user_attribute_model, :inverse_of => :attribute_attr_models
|
|
||||||
validates_uniqueness_of :key
|
|
||||||
|
|
||||||
# Destroy the i18n_variable
|
|
||||||
def destroy_i18n_variable
|
|
||||||
self.i18n_variable.destroy rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# Get the i18n_variable
|
|
||||||
def i18n_variable
|
|
||||||
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# Update or create the i18n_variable record
|
|
||||||
def i18n_variable=(attr)
|
|
||||||
if self.i18n_variable_id
|
|
||||||
self.i18n_variable.update_attributes(attr)
|
|
||||||
else
|
|
||||||
var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class, :parent_id => self.user_attribute_model.i18n_variable_id}))
|
|
||||||
var.save
|
|
||||||
self.i18n_variable_id = var.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Convert the string list_options into an array
|
|
||||||
def select_list_options=(var)
|
|
||||||
self.list_options = var.gsub(' ', '').split(',')
|
|
||||||
end
|
|
||||||
|
|
||||||
# Convert the array list_options into a string
|
|
||||||
def select_list_options
|
|
||||||
self.list_options.to_a.join(', ')
|
|
||||||
end
|
|
||||||
|
|
||||||
# Check if the attribute_attr is set to be destroyed
|
|
||||||
def should_destroy?
|
|
||||||
should_destroy.to_i == 1 rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -9,46 +9,47 @@ class User
|
||||||
field :admin, :type => Boolean, :default => true
|
field :admin, :type => Boolean, :default => true
|
||||||
field :active_attributes, :type => Array
|
field :active_attributes, :type => Array
|
||||||
|
|
||||||
embeds_many :user_attributes
|
embeds_one :user_info
|
||||||
|
embeds_many :user_roles
|
||||||
before_update :clean_active_attributes
|
before_update :clean_active_attributes
|
||||||
|
|
||||||
# Update or create the user_attribute records
|
# Update or create the user_role records
|
||||||
def user_attributes=(*attrs)
|
def user_roles=(*attrs)
|
||||||
attrs[0].each do |attributes|
|
attrs[0].each do |roles|
|
||||||
if attributes[:id].blank?
|
if roles[:id].blank?
|
||||||
user_attributes.build(attributes)
|
user_roles.build(roles)
|
||||||
else
|
else
|
||||||
user_attribute = user_attributes.detect {|a| a.id.to_s == attributes[:id].to_s }
|
user_role = user_roles.detect {|a| a.id.to_s == roles[:id].to_s }
|
||||||
user_attribute.update_attributes(attributes)
|
user_role.update_roles(roles)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get an user_attribute from model key
|
# Get an user_role from model key
|
||||||
def get_attribute_from_model_key(key)
|
def get_role_from_model_key(key)
|
||||||
self.user_attributes.detect {|a| a.key.to_s == key.to_s }
|
self.user_roles.detect {|a| a.key.to_s == key.to_s }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the active user_attribute_models
|
# Get the active user_role_models
|
||||||
def get_active_attribute_models
|
def get_active_role_models
|
||||||
self.active_attributes.map{ |attr| get_attribute_model(attr) } rescue []
|
self.active_roles.map{ |role| get_role_model(role) } rescue []
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get an user_attribute_model from key
|
# Get an user_role_model from key
|
||||||
def get_attribute_model(key)
|
def get_role_model(key)
|
||||||
UserAttributeModel.first(:conditions => {:key => key})
|
UserRoleModel.first(:conditions => {:key => key})
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the active attributes names or default to '-'
|
# Get the active roles names or default to '-'
|
||||||
def get_attributes
|
def get_roles
|
||||||
(self.active_attributes.nil? || self.active_attributes.empty?) ? '-' : self.active_attributes.map{|attr| I18nVariable.first(:conditions => {:key => attr})[I18n.locale] rescue attr}.join(' / ')
|
(self.active_roles.nil? || self.active_roles.empty?) ? '-' : self.active_roles.map{|role| I18nVariable.first(:conditions => {:key => role})[I18n.locale] rescue role}.join(' / ')
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
# Remove empty values
|
# Remove empty values
|
||||||
def clean_active_attributes
|
def clean_active_roles
|
||||||
self.active_attributes.delete('') if self.active_attributes
|
self.active_roles.delete('') if self.active_roles
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
class UserAttribute
|
|
||||||
|
|
||||||
include Mongoid::Document
|
|
||||||
|
|
||||||
field :key
|
|
||||||
|
|
||||||
embedded_in :user, :inverse_of => :user_attributes
|
|
||||||
|
|
||||||
end
|
|
|
@ -5,53 +5,28 @@ class UserAttributeModel
|
||||||
field :key
|
field :key
|
||||||
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
|
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
|
||||||
|
|
||||||
embeds_many :attribute_attr_models
|
embeds_many :attribute_models
|
||||||
|
|
||||||
after_update :destroy_attrs
|
after_update :destroy_attrs
|
||||||
|
|
||||||
# Update or create the attribute_attr_model records
|
# Update or create the attribute_model records
|
||||||
def attribute_attr_models=(*attrs)
|
def attribute_models=(*attrs)
|
||||||
attrs[0].each do |attributes|
|
attrs[0].each do |attributes|
|
||||||
if attributes[:id].blank?
|
if attributes[:id].blank?
|
||||||
attribute_attr_models.build(attributes)
|
attribute_models.build(attributes)
|
||||||
else
|
else
|
||||||
attribute_attr_model = attribute_attr_models.detect {|a| a.id.to_s == attributes[:id].to_s }
|
attribute_model = attribute_models.detect {|a| a.id.to_s == attributes[:id].to_s }
|
||||||
attribute_attr_model.update_attributes(attributes)
|
attribute_model.update_attributes(attributes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Destroy the i18n_variables
|
|
||||||
def destroy_i18n_variables
|
|
||||||
self.i18n_variable.destroy rescue nil
|
|
||||||
self.attribute_attr_models.each do |attr|
|
|
||||||
attr.destroy_i18n_variable
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Update or create the i18n_variable record
|
|
||||||
def i18n_variable=(attr)
|
|
||||||
if self.i18n_variable_id
|
|
||||||
self.i18n_variable.update_attributes(attr) rescue nil
|
|
||||||
else
|
|
||||||
var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class}))
|
|
||||||
var.save
|
|
||||||
self.i18n_variable_id = var.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Get the i18n_variable
|
|
||||||
def i18n_variable
|
|
||||||
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
# Destroy the attribute_attr_models if marked to destroy
|
# Destroy the i18n_variable for each attribute_models if marked to destroy
|
||||||
def destroy_attrs
|
def destroy_attrs
|
||||||
attribute_attr_models.each do |a|
|
attribute_models.each do |a|
|
||||||
if a.should_destroy?
|
if a.should_destroy?
|
||||||
a.destroy
|
|
||||||
a.destroy_i18n_variable
|
a.destroy_i18n_variable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<% @vars = @i18n_variables.inject([]) do |result, var|
|
<% @vars = @i18n_variables.inject([]) do |result, var|
|
||||||
result << var if var.parent_id.to_s.eql?(edit_user_attribute_model.id.to_s)
|
result << var if var.parent_id.to_s.eql?(edit_user_role_model.id.to_s)
|
||||||
result
|
result
|
||||||
end %>
|
end %>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<%= edit_user_attribute_model.key %>
|
<%= edit_user_role_model.key %>
|
||||||
<%#= render :partial => 'action_bar' %>
|
<%#= render :partial => 'action_bar' %>
|
||||||
</legend>
|
</legend>
|
||||||
<table>
|
<table>
|
||||||
|
@ -16,9 +16,9 @@ end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= edit_user_attribute_model.key %></td>
|
<td><%= edit_user_role_model.key %></td>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<td><%= text_field_tag "i18n_variables[#{edit_user_attribute_model.id}][#{locale}]", edit_user_attribute_model[locale] %></td>
|
<td><%= text_field_tag "i18n_variables[#{edit_user_role_model.id}][#{locale}]", edit_user_role_model[locale] %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<% @vars = @i18n_variables.inject([]) do |result, var|
|
<% @vars = @i18n_variables.inject([]) do |result, var|
|
||||||
result << var if var.parent_id.to_s.eql?(user_attribute_model.id.to_s)
|
result << var if var.parent_id.to_s.eql?(user_role_model.id.to_s)
|
||||||
result
|
result
|
||||||
end %>
|
end %>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<%= user_attribute_model.key %>
|
<%= user_role_model.key %>
|
||||||
<%#= render :partial => 'action_bar' %>
|
<%#= render :partial => 'action_bar' %>
|
||||||
</legend>
|
</legend>
|
||||||
<table>
|
<table>
|
||||||
|
@ -16,9 +16,9 @@ end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= user_attribute_model.key %></td>
|
<td><%= user_role_model.key %></td>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<td><%= user_attribute_model[locale] %></td>
|
<td><%= user_role_model[locale] %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @user_attribute_model_i18n_variables.size > 0 %>
|
<% if @user_role_role_i18n_variables.size > 0 %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<%= t('admin.user_attribute') %>
|
<%= t('admin.user_role') %>
|
||||||
<%#= render :partial => 'action_bar' %>
|
<%#= render :partial => 'action_bar' %>
|
||||||
</legend>
|
</legend>
|
||||||
<div><%= render :partial => 'edit_user_attribute_model', :collection => @user_attribute_model_i18n_variables %></div>
|
<div><%= render :partial => 'edit_user_role_model', :collection => @user_role_model_i18n_variables %></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,13 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @user_attribute_model_i18n_variables.size > 0 %>
|
<% if @user_role_model_i18n_variables.size > 0 %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<%= t('admin.user_attribute') %>
|
<%= t('admin.user_role') %>
|
||||||
<%#= render :partial => 'action_bar' %>
|
<%#= render :partial => 'action_bar' %>
|
||||||
</legend>
|
</legend>
|
||||||
<div><%= render :partial => 'user_attribute_model', :collection => @user_attribute_model_i18n_variables %></div>
|
<div><%= render :partial => 'user_role_model', :collection => @user_role_model_i18n_variables %></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
<%= fields_for 'user_attribute_model[attribute_attr_models][]', attribute_attr_model, :index => nil do |f| %>
|
<%= fields_for 'user_role_model[attribute_models][]', attribute_model, :index => nil do |f| %>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= attribute_attr_model.new_record? ? (f.text_field :key, {:style => "width:130px"}) : attribute_attr_model.key %></td>
|
<td><%= attribute_model.new_record? ? (f.text_field :key, {:style => "width:130px"}) : attribute_model.key %></td>
|
||||||
<td class='select_mulitlingual' style='text-align:center'>
|
<td class='select_mulitlingual' style='text-align:center'>
|
||||||
<%= check_box_tag "locale[]", value = '', attribute_attr_model.locale.nil? ? true : attribute_attr_model.locale %>
|
<%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %>
|
||||||
<%= hidden_field_tag "user_attribute_model[attribute_attr_models][][locale]", attribute_attr_model.locale.nil? ? true : attribute_attr_model.locale %>
|
<%= hidden_field_tag "user_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %>
|
||||||
</td>
|
</td>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<td><%= text_field_tag "user_attribute_model[attribute_attr_models][][i18n_variable][#{locale}]", (attribute_attr_model.i18n_variable[locale] rescue nil), :style => "width:130px" %></td>
|
<td><%= text_field_tag "user_role_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td class='select_type'>
|
<td class='select_type'>
|
||||||
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
|
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
|
||||||
<div <%= attribute_attr_model[:markup].eql?('select') ? nil : "style='display:none'"%>>
|
<div <%= attribute_model[:markup].eql?('select') ? nil : "style='display:none'"%>>
|
||||||
<%= t('admin.options') %>:
|
<%= t('admin.options') %>:
|
||||||
<%= text_field_tag "user_attribute_model[attribute_attr_models][][select_list_options]", attribute_attr_model.select_list_options, :style => "width:130px" %>
|
<%= text_field_tag "user_role_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% if attribute_attr_model.new_record? %>
|
<% if attribute_model.new_record? %>
|
||||||
<a href="#" class="remove">(<%= t(:delete) %>)</a>
|
<a href="#" class="remove">(<%= t(:delete) %>)</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="#" class="remove_existing_record">(<%= t(:delete) %>)</a>
|
<a href="#" class="remove_existing_record">(<%= t(:delete) %>)</a>
|
||||||
<%= hidden_field_tag "user_attribute_model[attribute_attr_models][][should_destroy]", nil , :class => 'should_destroy' %>
|
<%= hidden_field_tag "user_role_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %>
|
||||||
<%= f.hidden_field :id %>
|
<%= f.hidden_field :id %>
|
||||||
<%= f.hidden_field :key %>
|
<%= f.hidden_field :key %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -6,21 +6,21 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= is_new ? (f.text_field :key, {:style => "width:130px"}) : @user_attribute_model.key %></td>
|
<td><%= is_new ? (f.text_field :key, {:style => "width:130px"}) : @user_role_model.key %></td>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<td>
|
<td>
|
||||||
<%= text_field_tag "user_attribute_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:130px" %>
|
<%= text_field_tag "user_role_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:130px" %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<fieldset id='field_set_attribute_attrs'>
|
<fieldset id='field_set_attributes'>
|
||||||
<legend>
|
<legend>
|
||||||
<%= t('admin.attributes')%>
|
<%= t('admin.attributes')%>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<table id='attribute_attrs'>
|
<table id='attributes'>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t('admin.key') %></th>
|
<th><%= t('admin.key') %></th>
|
||||||
<th><%= t('admin.multilingual') %></th>
|
<th><%= t('admin.multilingual') %></th>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<th><%= t('admin.type')%></th>
|
<th><%= t('admin.type')%></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
<%= render :partial => 'attribute_attr_model', :collection => @user_attribute_model.attribute_attr_models %>
|
<%= render :partial => 'attribute_model', :collection => @user_role_model.attribute_models %>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<a href="#" class="add">(<%= t(:add) %>)</a>
|
<a href="#" class="add">(<%= t(:add) %>)</a>
|
||||||
|
@ -40,15 +40,15 @@
|
||||||
|
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
$('#field_set_attribute_attrs a.remove').live('click', function(){
|
$('#field_set_attributes a.remove').live('click', function(){
|
||||||
$(this).parent().parent().remove();
|
$(this).parent().parent().remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#field_set_attribute_attrs a.add').click(function(){
|
$('#field_set_attributes a.add').click(function(){
|
||||||
$('#attribute_attrs').append("<%= escape_javascript(render(:partial => 'attribute_attr_model', :object => @user_attribute_model.attribute_attr_models.build)) %>");
|
$('#attribute').append("<%= escape_javascript(render(:partial => 'attribute_model', :object => @user_role_model.attribute_models.build)) %>");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#field_set_attribute_attrs a.remove_existing_record').click(function(){
|
$('#field_set_attributes a.remove_existing_record').click(function(){
|
||||||
$(this).next('.should_destroy').attr('value', 1);
|
$(this).next('.should_destroy').attr('value', 1);
|
||||||
$(this).parent().parent().hide();
|
$(this).parent().parent().hide();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<h1><%= t('admin.editing_user_attribute') %>: <%= @user_attribute_model.key %></h1>
|
<h1><%= t('admin.editing_user_role') %>: <%= @user_role_model.key %></h1>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<%= t('admin.user_attribute')%>
|
<%= t('admin.user_role')%>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<%= form_for @user_attribute_model, :url => admin_user_attribute_model_path(@user_attribute_model) do |f| %>
|
<%= form_for @user_role_model, :url => admin_user_role_model_path(@user_role_model) do |f| %>
|
||||||
<%= f.error_messages %>
|
<%= f.error_messages %>
|
||||||
|
|
||||||
<%= render :partial => "form", :locals => { :f => f, :is_new => false } %>
|
<%= render :partial => "form", :locals => { :f => f, :is_new => false } %>
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
<% content_for :secondary do %>
|
<% content_for :secondary do %>
|
||||||
<ul class="list">
|
<ul class="list">
|
||||||
<li><%= link_to t('admin.new_user_attribute'), new_admin_user_attribute_model_path, :class => 'button positive' %></li>
|
<li><%= link_to t('admin.new_user_role'), new_admin_user_role_model_path, :class => 'button positive' %></li>
|
||||||
</ul>
|
</ul>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<h1><%= t('admin.list_user_attributes') %></h1>
|
<h1><%= t('admin.list_user_roles') %></h1>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t('admin.attribute') %></th>
|
<th><%= t('admin.role') %></th>
|
||||||
<th><%= t('admin.key') %></th>
|
<th><%= t('admin.key') %></th>
|
||||||
<th><%= t('admin.action') %></th>
|
<th><%= t('admin.action') %></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% @user_attribute_models.each do |user_attribute_model| %>
|
<% @user_role_models.each do |user_role_model| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= user_attribute_model.i18n_variable[I18n.locale] %></td>
|
<td><%= user_role_model.i18n_variable[I18n.locale] %></td>
|
||||||
<td><%= user_attribute_model.key %></td>
|
<td><%= user_role_model.key %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to t(:edit), edit_admin_user_attribute_model_path(user_attribute_model) %> |
|
<%= link_to t(:edit), edit_admin_user_role_model_path(user_role_model) %> |
|
||||||
<%= link_to t(:delete), admin_user_attribute_model_path(user_attribute_model), :confirm => t('sure?'), :method => :delete %>
|
<%= link_to t(:delete), admin_user_role_model_path(user_role_model), :confirm => t('sure?'), :method => :delete %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<h1><%= t('admin.new_user_attribute') %></h1>
|
<h1><%= t('admin.new_user_role') %></h1>
|
||||||
|
|
||||||
<fieldset id='field_set_attribute_attrs'>
|
<fieldset id='field_set_attributes'>
|
||||||
<legend>
|
<legend>
|
||||||
<%= t('admin.user_attribute')%>
|
<%= t('admin.user_role')%>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
<%= form_for @user_attribute_model, :url => admin_user_attribute_models_path do |f| %>
|
<%= form_for @user_role_model, :url => admin_user_role_models_path do |f| %>
|
||||||
<%= f.error_messages %>
|
<%= f.error_messages %>
|
||||||
|
|
||||||
<%= render :partial => "form", :locals => { :f => f, :is_new => true } %>
|
<%= render :partial => "form", :locals => { :f => f, :is_new => true } %>
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<li><%= link_to t('admin.item'), admin_items_path %></li>
|
<li><%= link_to t('admin.item'), admin_items_path %></li>
|
||||||
<li><%= link_to t('admin.layout'), admin_layouts_path %></li>
|
<li><%= link_to t('admin.layout'), admin_layouts_path %></li>
|
||||||
<li><%= link_to t('admin.asset'), admin_assets_path %></li>
|
<li><%= link_to t('admin.asset'), admin_assets_path %></li>
|
||||||
<li><%= link_to t('admin.user_attribute'), admin_user_attribute_models_path %></li>
|
<li><%= link_to t('admin.user_role'), admin_user_role_models_path %></li>
|
||||||
<li><%= link_to t('admin.translation'), admin_translations_path %></li>
|
<li><%= link_to t('admin.translation'), admin_translations_path %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<%= fields_for 'user[user_attributes][attribute_attrs]', attribute_attr, :index => nil do |f| %>
|
<%= fields_for 'user[user_roles][attributes]', attribute, :index => nil do |f| %>
|
||||||
<%#= f.hidden_field :id unless attribute_attr.new_record? %>
|
<%#= f.hidden_field :id unless attribute.new_record? %>
|
||||||
<% if attr["locale"] %>
|
<% if attr["locale"] %>
|
||||||
<p>
|
<p>
|
||||||
<%#= f.hidden_field :key, :value => attr["key"] %>
|
<%#= f.hidden_field :key, :value => attr["key"] %>
|
||||||
<% if attr["markup"] == "text_field" %>
|
<% if attr["markup"] == "text_field" %>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<%= f.label attr.i18n_variable[locale] %>
|
<%= f.label attr.i18n_variable[locale] %>
|
||||||
<%= text_field_tag "user[user_attributes][attribute_attrs][i18n_user][#{locale}]", (attribute_attr.i18n_user[locale] rescue nil) %>
|
<%= text_field_tag "user[user_roles][attributes][i18n_user][#{locale}]", (attribute.i18n_user[locale] rescue nil) %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% elsif attr["markup"] == "select" %>
|
<% elsif attr["markup"] == "select" %>
|
||||||
<%= f.select "#{attr["key"]}_#{I18n.locale}", attr["options_#{I18n.locale}"].to_a %>
|
<%= f.select "#{attr["key"]}_#{I18n.locale}", attr["options_#{I18n.locale}"].to_a %>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<div id="select_user_attributes">
|
<div id="select_user_roles">
|
||||||
<% @user_attribute_models.each do |ua| %>
|
<% @user_role_models.each do |ua| %>
|
||||||
<%= check_box_tag "user[active_attributes][]", ua.key, (@user.active_attributes.include?(ua.key) rescue false) %> <%= ua.i18n_variable[locale] %>
|
<%= check_box_tag "user[active_roles][]", ua.key, (@user.active_roles.include?(ua.key) rescue false) %> <%= ua.i18n_variable[locale] %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<%= hidden_field_tag 'user[active_attributes][]', '' %>
|
<%= hidden_field_tag 'user[active_roles][]', '' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -19,17 +19,17 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% @user_attribute_models.each do |ua| %>
|
<% @user_role_models.each do |ua| %>
|
||||||
<%= render :partial => 'user_attribute',
|
<%= render :partial => 'user_role',
|
||||||
:object => (@user.user_attributes.detect {|u| u.key == ua.key } || @user.user_attributes.build),
|
:object => (@user.user_roles.detect {|u| u.key == ua.key } || @user.user_roles.build),
|
||||||
:locals => {:ua => ua} %>
|
:locals => {:ua => ua} %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('#select_user_attributes input').click(function(){
|
$('#select_user_roles input').click(function(){
|
||||||
$("#attribute_"+this.value).toggle();
|
$("#role_"+this.value).toggle();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
<fieldset id="attribute_<%= ua.key %>"<%= raw(' style="display: none;"') unless (@user.active_attributes.include?(ua.key) rescue nil) %>>
|
<fieldset id="attribute_<%= ua.key %>"<%= raw(' style="display: none;"') unless (@user.active_attributes.include?(ua.key) rescue nil) %>>
|
||||||
|
|
||||||
<%= fields_for 'user[user_attributes]', user_attribute, :index => nil do |f| %>
|
<%= fields_for 'user[user_roles]', user_role, :index => nil do |f| %>
|
||||||
<legend><%= ua.i18n_variable[I18n.locale] %></legend>
|
<legend><%= ua.i18n_variable[I18n.locale] %></legend>
|
||||||
<%= f.hidden_field :key, :value => ua.key %>
|
<%= f.hidden_field :key, :value => ua.key %>
|
||||||
<%= f.hidden_field :id unless user_attribute.new_record? %>
|
<%= f.hidden_field :id unless user_role.new_record? %>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t('admin.attribute') %></th>
|
<th><%= t('admin.role') %></th>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<th style="color:<%= colorize_in_use_locale(locale) %>"><%= locale %></th>
|
<th style="color:<%= colorize_in_use_locale(locale) %>"><%= locale %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% ua.attribute_attr_models.each do |attr| %>
|
<% ua.attribute_models.each do |attr| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= attr.i18n_variable[I18n.locale] %></td>
|
<td><%= attr.i18n_variable[I18n.locale] %></td>
|
||||||
<% if attr["locale"] && attr["markup"] == 'text_field' %>
|
<% if attr["locale"] && attr["markup"] == 'text_field' %>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<td>
|
<td>
|
||||||
<%= text_field_tag "user[user_attributes][][#{attr.key}_#{locale}]", (user_attribute["#{attr.key}_#{locale}"] rescue nil) %>
|
<%= text_field_tag "user[user_roles][][#{attr.key}_#{locale}]", (user_role["#{attr.key}_#{locale}"] rescue nil) %>
|
||||||
</td>
|
</td>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td colspan=<%= @site_valid_locales.size %>>
|
<td colspan=<%= @site_valid_locales.size %>>
|
||||||
<% if attr["markup"] == "text_field" %>
|
<% if attr["markup"] == "text_field" %>
|
||||||
<%= text_field_tag "user[user_attributes][][#{attr.key}]", (user_attribute[attr.key] rescue nil) %>
|
<%= text_field_tag "user[user_roles][][#{attr.key}]", (user_role[attr.key] rescue nil) %>
|
||||||
<% elsif attr["markup"] == "select" %>
|
<% elsif attr["markup"] == "select" %>
|
||||||
<%= select_tag "user[user_attributes][][#{attr.key}]", options_for_select(attr["options"], user_attribute[attr.key]) %>
|
<%= select_tag "user[user_roles][][#{attr.key}]", options_for_select(attr["options"], user_role[attr.key]) %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</td>
|
</td>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -11,18 +11,18 @@
|
||||||
<%= @user.email %>
|
<%= @user.email %>
|
||||||
|
|
||||||
<% @user.get_active_attribute_models.each do |am| %>
|
<% @user.get_active_attribute_models.each do |am| %>
|
||||||
<% user_attribute = @user.get_attribute_from_model_key(am.key) %>
|
<% user_role = @user.get_role_from_model_key(am.key) %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><%= am.i18n_variable[I18n.locale] %></legend>
|
<legend><%= am.i18n_variable[I18n.locale] %></legend>
|
||||||
<table>
|
<table>
|
||||||
<% am.attribute_attr_models.each do |attr| %>
|
<% am.attribute_models.each do |attr| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= attr.i18n_variable[I18n.locale] %></td>
|
<td><%= attr.i18n_variable[I18n.locale] %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if attr["locale"] && attr["markup"] == 'text_field' %>
|
<% if attr["locale"] && attr["markup"] == 'text_field' %>
|
||||||
<%= user_attribute["#{attr.key}_#{I18n.locale}"] %>
|
<%= user_role["#{attr.key}_#{I18n.locale}"] %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= user_attribute["#{attr.key}"] %>
|
<%= user_role["#{attr.key}"] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue