diff --git a/admin_back_end.css.erb b/admin_back_end.css.erb deleted file mode 100644 index a0eff84e..00000000 --- a/admin_back_end.css.erb +++ /dev/null @@ -1,278 +0,0 @@ -html, body{ - height: 100%; - margin: 0; - padding: 0; -} -html{ - background: url(<%= asset_path "body.jpg" %>) no-repeat scroll 0 0 transparent; - background-size: cover; -} - -body{ - color: #000000; - font-family: Helvetica, '微軟正黑體'; -} - -#panel_banner_link{ - background: url(<%= asset_path "orbitbar1.png" %>) repeat-x scroll 0 0; - height: 50px; - left: 0; - position: fixed; - top: 0; - width: 100%; - z-index: 5; -} -.hmenu{ - height: 40px; - position: absolute; - right: 0; - top: 1px; - width: 250px; -} -#orbit{ - background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; - cursor:pointer; - height: 43px; - left: 10px; - position: relative; - width: 41px; -} -#orbit:hover{ - background-position:0 -43px; - box-shadow: 0 3px 3px #000000; -} -#orbit:hover #orblist{ - display:block; -} -#orblist{ - background: none repeat scroll 0 0 #FFFFFF; - border-radius: 0 3px 3px 3px; - box-shadow: 0 3px 3px #000000; - display: none; - margin: 0; - padding: 10px; - position: absolute; - top: 43px; - width: 130px; -} -#orblist li{ - border-bottom:1px solid #aaa; - list-style:none; -} -.orblink{ - color: #333333; - display: block; - font: 12px/100% arial,sans-serif; - padding: 5px; - text-decoration: none; -} -.orblink:hover{ - background:#eee; - color:#333; -} - -#log_out a{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; - border: medium none !important; - display: block !important; - height: 40px !important; - line-height: normal !important; - padding: 0 !important; - position: absolute; - right: 0px; - text-indent: -10000px; - top: 0px; - width: 43px !important; -} -#log_out a:hover{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; -} -.lang{ - color: #FFFFFF; - font-size: 15px; - line-height: 40px; - position: absolute; - right: 55px; - top: 0; -} - -.lang a{ - color:#fff; - text-decoration:none; -} - -.lang a:hover{ - text-decoration:underline; -} - -#content{ - height: 100%; -} -#sidebar { - background: url(<%= asset_path "75.png" %>) repeat scroll left top transparent; - box-shadow: 3px 0 4px #472A12; - border-right: 1px solid #121212; - height: 100%; - left: 0; - position: fixed; - top: 0; - width: 220px; -} -#search { - background: url(<%= asset_path "search_block_bg.jpg" %>) repeat-x scroll left top transparent; - height: 20px; - margin-top: 43px; - padding: 15px 12px; -} -#search input { - background: url(<%= asset_path "search_bg.png" %>) no-repeat scroll left top transparent; - border: medium none; - font-family: Helvetica; - height: 20px; - padding: 0 20px; - width: 154px; -} -h1 { - background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent; - border-bottom: 1px solid #1B1B1B; - border-top: 1px solid #424344; - color: #FFFFFF; - font-size: 12px; - font-weight: normal; - height: 21px; - line-height: 21px; - margin: 0; - padding-left: 10px; - text-shadow: 0 -1px 0 #000000; -} -.member_setup .list { - color:#fff; - font-size:12px; - background:url(<%= asset_path "line.png" %>) repeat-x left bottom; -} -.member_setup .list li { - background:url(<%= asset_path "sidebar_li.jpg" %>) repeat-x left top; - border-top:1px solid #424344; - border-bottom:1px solid #000000; -} -.member_setup .list li:hover { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.member_setup .list li a { - display: block; - padding: 7px 0 6px 12px; - color:#c4c4c4; -} -.member_setup .list li a span { - background:url(<%= asset_path "add_mamber.png" %>) left top no-repeat; - text-shadow: 0px 1px 0px #000; - line-height: 18px; - padding: 2px 0 1px 35px; -} -.member_setup .list li a:hover span { - background-position:left bottom; - color:#eeeeee; -} -.users .list .set_1 { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.users .list .set_1 a span { - background-position:left bottom; - color:#eeeeee; -} -.user_role_models .list .set_2 { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.user_role_models .list .set_2 a span { - background-position:left bottom; - color:#eeeeee; -} -.user_info_models .list .set_3 { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.user_info_models .list .set_3 a span { - background-position:left bottom; - color:#eeeeee; -} -.main { - height: 100%; - margin-left: 260px; - padding-right: 40px; - position: relative; -} -.main_list { - padding-top: 70px; -} -.main_list ul { - clear:both; -} -#porfile { - padding-top: 100px; -} -/*add_buttom*/ -.button_bar { - float: right; - -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); - background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); - background-color:#4f4f4f; - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; - display:inline-block; - padding:0; - margin:10px 0; -} -.button_bar a { - text-decoration:none; - text-shadow:0px -1px 0px #000000; - font-size:12px; - color:#EDEDED; - border-right:1px solid #555; - -moz-box-shadow:1px 0px 0px black; - -webkit-box-shadow:1px 0px 0px black; - box-shadow:1px 0px 0px black; - padding: 6px 10px 4px; - display: inline-block; - float: left; -} -.button_bar a:active { - padding: 7px 10px 3px; - text-shadow:0px 1px 0px #000000; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); - background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); -} -.button_bar a:last-child { - border-right:none; - -moz-box-shadow:none; - -webkit-box-shadow:none; - box-shadow:none; - -moz-border-radius:0px 5px 5px 0px; - -webkit-border-radius:0px 5px 5px 0px; - border-radius:0px 5px 5px 0px; -} -.button_bar a:first-child { - -moz-border-radius:5px 0px 0px 5px; - -webkit-border-radius:5px 0px 0px 5px; - border-radius:5px 0px 0px 5px; -} -.button_bar a.new { - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; -} -.button_bar a:hover { - color:#FFFFFF; -} \ No newline at end of file diff --git a/app/assets/javascripts/attribute_form.js.erb b/app/assets/javascripts/attribute_form.js.erb new file mode 100644 index 00000000..6109099f --- /dev/null +++ b/app/assets/javascripts/attribute_form.js.erb @@ -0,0 +1,25 @@ +$('.attributes_block a.delete').live('click', function(){ + $(this).parents('.list_item').remove(); +}); + +$('#attributes a.remove_existing_record').live('click', function(){ + $(this).next('.should_destroy').attr('value', 1); + $("#attribute_" + $(this).prev().attr('value')).hide(); +}); + +$('#attributes_block a.switch').live('click', function(){ + $(this).parent().toggleClass('disable'); + var $am = $(this).next('.built_in_state') + $am.attr('value', ($am.attr('value') == "false") ? "true" : "false"); +}); + +$('.select_type select').live('change', function(){ + if(this.value == 'select') + { + $(this).next().show(); + } + else + { + $(this).next().hide(); + } +}); \ No newline at end of file diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js index 71c4ef59..18f258ba 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js @@ -1,4 +1,7 @@ -$("div.editable").live("mouseenter mouseleave", - function (event) { - $(this).children('.edit_link').toggle(); - }); \ No newline at end of file +$("div.editable").live("mouseenter mouseleave", function (event) { + $(this).children('.edit_link').toggle(); +}); + +$("#page_design_id").live('change', function() { + $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); +}); \ No newline at end of file diff --git a/app/assets/javascripts/site_editor.js b/app/assets/javascripts/site_editor.js index 835884d0..98405564 100644 --- a/app/assets/javascripts/site_editor.js +++ b/app/assets/javascripts/site_editor.js @@ -6,4 +6,5 @@ // //= require jquery //= require jquery_ujs +//= require page_edit //= require side_bar_history \ No newline at end of file diff --git a/app/assets/javascripts/user_attribute_model_form.js b/app/assets/javascripts/user_attribute_model_form.js deleted file mode 100644 index 1e1e2ef5..00000000 --- a/app/assets/javascripts/user_attribute_model_form.js +++ /dev/null @@ -1,33 +0,0 @@ -$('#attributes_block a.delete').live('click', function(){ - $(this).parent().parent().parent().remove(); -}); - -$('#attributes_block a.add').click(function(){ - $('#attributes').append("<%= escape_javascript(render(:partial => 'admin/user_attribute_models/attribute_model', :object => @user_attribute_model.attribute_models.build)) %>"); -}); - -$('#attributes_block a.remove_existing_record').click(function(){ - $(this).next('.should_destroy').attr('value', 1); - $(this).parent().parent().hide(); -}); - -$('#attributes_block a.change_built_in').click(function(){ - $(this).parent().toggleClass('disable'); - var $am = $(this).next('.built_in_state') - $am.attr('value', ($am.attr('value') == "false") ? "true" : "false"); -}); - -$('.select_mulitlingual input').live('click', function(){ - $(this).next().attr('value', this.checked); -}); - -$('.select_type select').live('change', function(){ - if(this.value == 'select') - { - $(this).next().show(); - } - else - { - $(this).next().hide(); - } -}); \ No newline at end of file diff --git a/app/assets/javascripts/user_form.js b/app/assets/javascripts/user_form.js index 21a4b454..168f5437 100644 --- a/app/assets/javascripts/user_form.js +++ b/app/assets/javascripts/user_form.js @@ -1,6 +1,6 @@ $(document).ready(function(){ - $('#user_active_role').change(function(){ - $('#role_models .roles_block').hide(); + $('#active_role').change(function(){ + $('#roles .attributes_block').hide(); $('#'+this.value+'_block').toggle(); }); }); \ No newline at end of file diff --git a/app/assets/stylesheets/_form.html.erb b/app/assets/stylesheets/_form.html.erb deleted file mode 100644 index edbcae39..00000000 --- a/app/assets/stylesheets/_form.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -
-

<%= t("admin.user_#{@attribute}") %>

-
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - -
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %> - <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> -
-
-
- - -
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
-
-
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "user_attribute_model_form" %> -<% end -%> diff --git a/app/assets/stylesheets/admin_back_end.css.erb b/app/assets/stylesheets/admin_back_end.css.erb index 89f2c874..f7f3a222 100644 --- a/app/assets/stylesheets/admin_back_end.css.erb +++ b/app/assets/stylesheets/admin_back_end.css.erb @@ -222,7 +222,7 @@ h1 { .main_list ul { clear:both; } -#porfile { +#profile { padding-top: 100px; } /*add_buttom*/ @@ -336,10 +336,10 @@ h1 { padding: 0; width: 140px; } -#porfile .users{ +#profile .users{ margin-left: 180px; } -.roles_block { +.attributes_block { background: url(<%= asset_path "75.png" %>) repeat left top; min-width:710px; margin-bottom:50px; @@ -352,7 +352,7 @@ h1 { -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ } -.roles_block h2 { +.attributes_block h2 { color: #FFFFFF; font-weight: normal; margin: 0; diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index a00bd94e..bc86b662 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -11,16 +11,18 @@ class Admin::InfosController < ApplicationController end def show - #@attribute = Info.find(params[:id]) + end def new @attribute = Info.new + render :template => 'admin/attributes/new' end def edit @attribute = Info.find(params[:id]) @i18n_variable = @attribute.i18n_variable + render :template => 'admin/attributes/edit' end def create @@ -32,6 +34,10 @@ class Admin::InfosController < ApplicationController def update @attribute = Info.find(params[:id]) @attribute.update_attributes(params[:info]) + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/attributes/toggle_enable' } + end end def destroy @@ -40,10 +46,18 @@ class Admin::InfosController < ApplicationController redirect_to :action => :index end + def add_attribute_field + @attribute = Info.find(params[:id]) rescue nil + if !@attribute + @attribute = Info.new + end + end + protected def set_attribute @attribute_type = 'info' + @class = 'infos' end end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index f3a17dd7..65c86f36 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -11,16 +11,18 @@ class Admin::RolesController < ApplicationController end def show - #@attribute = Role.find(params[:id]) + end def new @attribute = Role.new + render :template => 'admin/attributes/new' end def edit @attribute = Role.find(params[:id]) @i18n_variable = @attribute.i18n_variable + render :template => 'admin/attributes/edit' end def create @@ -32,7 +34,6 @@ class Admin::RolesController < ApplicationController def update @attribute = Role.find(params[:id]) @attribute.update_attributes(params[:role]) - respond_to do |format| format.html { redirect_to :action => :index } format.js { render 'admin/attributes/toggle_enable' } @@ -49,6 +50,7 @@ class Admin::RolesController < ApplicationController def set_attribute @attribute_type = 'role' + @class = 'roles' end end diff --git a/app/controllers/admin/translations_controller.rb b/app/controllers/admin/translations_controller.rb index 590ad556..54da8762 100644 --- a/app/controllers/admin/translations_controller.rb +++ b/app/controllers/admin/translations_controller.rb @@ -68,11 +68,11 @@ class Admin::TranslationsController < ApplicationController result << var if var.document_class.eql?('language') result end - @user_role_model_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('UserRoleModel') + @role_i18n_variables = @i18n_variables.inject([]) do |result, var| + result << var if var.document_class.eql?('Role') result end - @user_info_model_i18n_variables = @i18n_variables.inject([]) do |result, var| + @info_i18n_variables = @i18n_variables.inject([]) do |result, var| result << var if var.document_class.eql?('UserInfoModel') result end diff --git a/app/controllers/admin/user_info_models_controller.rb b/app/controllers/admin/user_info_models_controller.rb deleted file mode 100644 index 60360463..00000000 --- a/app/controllers/admin/user_info_models_controller.rb +++ /dev/null @@ -1,59 +0,0 @@ -class Admin::UserInfoModelsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - before_filter :set_attribute, :only => [:index, :show, :new, :edit] - - def index - @user_attribute_models = UserInfoModel.all.entries - render :template => 'admin/user_attribute_models/index' - end - - def show - #@user_attribute_model = UserInfoModel.find(params[:id]) - end - - def new - @user_attribute_model = UserInfoModel.new - render :template => 'admin/user_attribute_models/new' - end - - def edit - @user_attribute_model = UserInfoModel.find(params[:id]) - @i18n_variable = @user_attribute_model.i18n_variable - render :template => 'admin/user_attribute_models/edit' - end - - def create - @user_attribute_model = UserInfoModel.new(params[:user_info_model]) - @user_attribute_model.save - redirect_to :action => :index - end - - def update - @user_attribute_model = UserInfoModel.find(params[:id]) - @user_attribute_model.update_attributes(params[:user_info_model]) - respond_to do |format| - format.html { redirect_to :action => :index } - format.js { render 'admin/user_attribute_models/toggle_enable' } - end - end - - def destroy - @user_attribute_model = UserInfoModel.find(params[:id]) - @user_attribute_model.destroy - - @user_attribute_model.destroy_i18n_variables - - redirect_to :action => :index - end - - protected - - def set_attribute - @attribute = 'info' - @class = 'infos' - end - -end diff --git a/app/controllers/admin/user_role_models_controller.rb b/app/controllers/admin/user_role_models_controller.rb deleted file mode 100644 index bfdf5428..00000000 --- a/app/controllers/admin/user_role_models_controller.rb +++ /dev/null @@ -1,60 +0,0 @@ -class Admin::UserRoleModelsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - before_filter :set_attribute, :only => [:index, :show, :new, :edit] - - def index - @user_attribute_models = UserRoleModel.all.entries - render :template => 'admin/user_attribute_models/index' - end - - def show - #@user_attribute_model = UserRoleModel.find(params[:id]) - end - - def new - @user_attribute_model = UserRoleModel.new - render :template => 'admin/user_attribute_models/new' - end - - def edit - @user_attribute_model = UserRoleModel.find(params[:id]) - @i18n_variable = @user_attribute_model.i18n_variable - render :template => 'admin/user_attribute_models/edit' - end - - def create - @user_attribute_model = UserRoleModel.new(params[:user_role_model]) - @user_attribute_model.save - redirect_to :action => :index - end - - def update - @user_attribute_model = UserRoleModel.find(params[:id]) - @user_attribute_model.update_attributes(params[:user_role_model]) - - respond_to do |format| - format.html { redirect_to :action => :index } - format.js { render 'admin/user_attribute_models/toggle_enable' } - end - end - - def destroy - @user_attribute_model = UserRoleModel.find(params[:id]) - @user_attribute_model.destroy - - @user_attribute_model.destroy_i18n_variables - - redirect_to :action => :index - end - - protected - - def set_attribute - @attribute = 'role' - @class = 'roles' - end - -end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 2a6c0a99..b8df3312 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -10,18 +10,18 @@ class Admin::UsersController < ApplicationController def show @user = User.find(params[:id]) - get_info_role_models + get_info_and_roles end def new @user = User.new - get_info_role_models + get_info_and_roles end def create @user = User.new(params[:user]) if @user.save - @user.user_infos.each do |info| + @user.infos.each do |info| info.save info.attribute_values.each(&:save) end @@ -38,7 +38,7 @@ class Admin::UsersController < ApplicationController def edit @user = User.find(params[:id]) - get_info_role_models + get_info_and_roles end def update @@ -55,7 +55,7 @@ class Admin::UsersController < ApplicationController flash[:notice] = t('admin.update_success_user') redirect_to :action => :index else - get_info_role_models + get_info_and_roles render :action => :edit end end @@ -66,7 +66,7 @@ class Admin::UsersController < ApplicationController else @user = User.find(params[:id]) @user.destroy - @user.user_attributes.each do |ua| + @user.attributes.each do |ua| ua.attribute_values.each(&:destroy) ua.destroy end @@ -77,9 +77,9 @@ class Admin::UsersController < ApplicationController protected - def get_info_role_models - @roles = Info.excludes('disabled' => true) - @infos = Role.excludes('disabled' => true) + def get_info_and_roles + @infos = Info.excludes('disabled' => true) + @roles = Role.excludes('disabled' => true) end def set_attribute diff --git a/app/helpers/admin/user_helper.rb b/app/helpers/admin/user_helper.rb index 6ebd056f..22da150e 100644 --- a/app/helpers/admin/user_helper.rb +++ b/app/helpers/admin/user_helper.rb @@ -1,7 +1,7 @@ module Admin::UserHelper - def show_user_attribute(object, key, locale = '') - attribute = object.attribute_values.detect {|av| av.key.to_s.eql?(key.to_s) || av[locale.to_s].eql?(locale.to_s) } rescue nil + def show_attribute(object, field_id, locale = '') + attribute = object.attribute_values.detect {|av| av.attribute_field_id.eql?(field_id) || av[locale.to_s].eql?(locale.to_s) } rescue nil if attribute if locale.to_s.blank? attribute['key'] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b8a9c49e..c8754b31 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,5 +48,12 @@ module ApplicationHelper message % item end end + + def add_attribute(partial, f, attribute) + new_object = f.object.send(attribute).build + fields = f.fields_for(attribute, new_object, :child_index => "new_#{attribute}") do |f| + render :partial => partial, :object => new_object, :locals => {:f => f} + end + end end diff --git a/app/models/design/design.rb b/app/models/design/design.rb index f1f676b6..f39a4816 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -36,7 +36,7 @@ class Design self.files = (attrs << 'images') end - # Update or create the attribute_model records + # Update or create the attribute records def files=(attrs) case attrs.last when 'layout' diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb index aee7c36c..c53adebb 100644 --- a/app/models/user/attribute.rb +++ b/app/models/user/attribute.rb @@ -7,7 +7,7 @@ class Attribute field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - embeds_many :attribute_fields + has_many :attribute_fields, :autosave => true, :dependent => :destroy has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :i18n_variable, :allow_destroy => true accepts_nested_attributes_for :attribute_fields, :allow_destroy => true diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 56bb02b7..8f3167e7 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -5,12 +5,12 @@ class AttributeField field :key field :markup - field :locale, :type => Boolean + field :locale, :type => Boolean, :default => true field :list_options, :type => Array field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - embedded_in :attribute + belongs_to :attribute has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :attribute_values validates_uniqueness_of :key diff --git a/app/models/user/role.rb b/app/models/user/role.rb index 90294f58..86f7266f 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -7,7 +7,7 @@ class Role field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - embeds_many :sub_roles + has_many :sub_roles, :autosave => true, :dependent => :destroy has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :users accepts_nested_attributes_for :i18n_variable, :allow_destroy => true diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb index 496055c2..63b8cf92 100644 --- a/app/models/user/sub_role.rb +++ b/app/models/user/sub_role.rb @@ -1,5 +1,6 @@ class SubRole < Attribute - + + belongs_to :role has_many :users # Get an sub_role from key diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 2eca43dd..a06233d1 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -16,14 +16,18 @@ class User accepts_nested_attributes_for :attribute_values, :allow_destroy => true def name - infos = self.user_infos.detect {|info| info.key.to_s.eql?('profile') } - if infos - first_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil - last_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil + info = Class::Info.first(:conditions => {:key => 'profile'}) + if info + first_name = get_attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil + last_name = get_attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil return "#{first_name} #{last_name}" else return nil end end + def get_attribute_values + @attribute_values ||= self.attribute_values.to_a + end + end diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb new file mode 100644 index 00000000..d8fb5ade --- /dev/null +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -0,0 +1,35 @@ +" class="list_item"> + <%= attribute_field.new_record? ? (f.text_field :key) : attribute_field.key %> + + <%= f.check_box :locale %> + + <%= 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| %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <%= f.hidden_field :id %> + <% end %> + + <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> +
> + <%= t('admin.options') %>: + <%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %> +
+ + + + <% if attribute_field.new_record? %> + <%= t(:delete) %> + <% else %> + <%= f.hidden_field :id %> + <% if attribute_field.is_built_in? %> + + <%= f.hidden_field :disabled, :value => attribute_field.is_disabled? , :class => 'built_in_state' %> + <% else %> + <%= t(:delete) %> + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + <% end %> + + + \ No newline at end of file diff --git a/app/views/admin/attributes/_attribute_model.html.erb b/app/views/admin/attributes/_attribute_model.html.erb deleted file mode 100644 index 89c1ef89..00000000 --- a/app/views/admin/attributes/_attribute_model.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -<%= fields_for "user_#{@attribute_type}_model[attribute_models][]", attribute_model, :index => nil do |f| %> - - <%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %> - - <%= 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 %> - - <% @site_valid_locales.each do |locale| %> - <%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %> - <% end %> - - <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> -
> - <%= t('admin.options') %>: - <%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %> -
- - - - <% if attribute_model.new_record? %> - <%= t(:delete) %> - <% else %> - <% if attribute_model.is_built_in? %> - - <%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %> - <% else %> - <%= t(:delete) %> - <%= 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 %> - - - -<% end %> \ No newline at end of file diff --git a/app/views/admin/attributes/_form.html.erb b/app/views/admin/attributes/_form.html.erb deleted file mode 100644 index 5d66152c..00000000 --- a/app/views/admin/attributes/_form.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -
-

<%= t("admin.user_#{@attribute_type}") %>

-
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - -
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> - <%= text_field_tag "user_#{@attribute_type}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> -
-
-
- - -
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <%= render :partial => 'admin/attributes/attribute_model', :collection => @attribute.attribute_models %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
-
-
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "attribute_form" %> -<% end -%> diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index e0f75789..d45382f6 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -2,15 +2,13 @@ <%= render 'admin/users/side_bar' %> <% end %> -
- <%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %> +
+ <%= 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 } %> -
- <%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %> -
-
+ <%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => false } %> +
<%= link_back %> + <%= link_to t('update'), "#", :onclick=>"$('#edit_#{@attribute_type}_#{@attribute.id}').submit()" %>
- <% end -%> + <% end %>
\ No newline at end of file diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb index efd8c775..71ec1699 100644 --- a/app/views/admin/attributes/index.html.erb +++ b/app/views/admin/attributes/index.html.erb @@ -3,32 +3,37 @@ <% end %>
-
- <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %> +
+ <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
-
    -
  • - <%= t("admin.#{@attribute_type}") %> - <%= t('admin.action') %> -
  • + + + + + + + + <% @attributes.each do |attribute| %> -
  • clear"> - <%= attribute.i18n_variable[I18n.locale] %> - +
  • "> + + + + + <% end %> - -
    - <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %> +
    +
    <%= t("admin.#{@attribute_type}") %><%= t('admin.action') %>
    <%= attribute.i18n_variable[I18n.locale] %> + <%= 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 %> - - - +
    +
    + <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb index 431814d1..2e96e8f9 100644 --- a/app/views/admin/attributes/new.html.erb +++ b/app/views/admin/attributes/new.html.erb @@ -2,19 +2,13 @@ <%= render 'admin/users/side_bar' %> <% end %> -
- <%= form_for @attribute, :url => eval("admin_infos_path") do |f| %> +
+ <%= 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 } %> -
- <%= link_to t('create'), "#", :onclick=>"$('#new_attribute').submit()" %> -
-
+ <%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => true } %> +
<%= link_back %> + <%= link_to t('create'), "#", :onclick=>"$('#new_#{@attribute_type}').submit()" %>
<% end -%> -
- - - - +
\ No newline at end of file diff --git a/app/views/admin/infos/_attribute_field.html.erb b/app/views/admin/infos/_attribute_field.html.erb new file mode 100644 index 00000000..12ed7828 --- /dev/null +++ b/app/views/admin/infos/_attribute_field.html.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/admin/infos/_form.html.erb b/app/views/admin/infos/_form.html.erb new file mode 100644 index 00000000..75ded177 --- /dev/null +++ b/app/views/admin/infos/_form.html.erb @@ -0,0 +1,70 @@ +
+

<%= t("admin.#{@attribute_type}") %>

+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> + <%= text_field_tag "#{@attribute_type}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+
+ + +
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <% @attribute.attribute_fields.each do |attribute_field| %> + <%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %> + <% end %> + +
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
+ <%= hidden_field_tag 'attribute_field_count', @attribute.attribute_fields.count %> + <%= t(:add) %> +
+
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "attribute_form" %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/infos/edit.html.erb b/app/views/admin/infos/edit.html.erb deleted file mode 100644 index e0f75789..00000000 --- a/app/views/admin/infos/edit.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
- <%= 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 } %> -
- <%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %> -
-
- <%= link_back %> -
- <% end -%> -
\ No newline at end of file diff --git a/app/views/admin/pages/_show.html.erb b/app/views/admin/pages/_show.html.erb index a4b78e2f..1937fe92 100644 --- a/app/views/admin/pages/_show.html.erb +++ b/app/views/admin/pages/_show.html.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/admin/roles/_attribute_field.html.erb b/app/views/admin/roles/_attribute_field.html.erb new file mode 100644 index 00000000..12ed7828 --- /dev/null +++ b/app/views/admin/roles/_attribute_field.html.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/admin/roles/_form.html.erb b/app/views/admin/roles/_form.html.erb new file mode 100644 index 00000000..7026db95 --- /dev/null +++ b/app/views/admin/roles/_form.html.erb @@ -0,0 +1,50 @@ +
+

<%= t("admin.#{@attribute_type}") %>

+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> + <%= text_field_tag "#{@attribute_type}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+
+ +
+

Sub roles

+ <% @attribute.sub_roles.each do |sub_role| %> + <%= render :partial => 'form_sub', :object => sub_role, :locals => {:f => f} %> + <% end %> +
+
+ +
+ <%= hidden_field_tag 'attribute_field_count', @attribute.sub_roles.count %> + <%= t(:add) %> +
+ +<% content_for :page_specific_javascript do %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/_form_sub.html.erb b/app/views/admin/roles/_form_sub.html.erb new file mode 100644 index 00000000..09dac402 --- /dev/null +++ b/app/views/admin/roles/_form_sub.html.erb @@ -0,0 +1,3 @@ +<%= f.fields_for :sub_roles, form_sub do |f| %> + <%= render :partial => 'sub_role', :object => form_sub, :locals => {:f => f} %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/_sub_role.html.erb b/app/views/admin/roles/_sub_role.html.erb new file mode 100644 index 00000000..04c85ff5 --- /dev/null +++ b/app/views/admin/roles/_sub_role.html.erb @@ -0,0 +1,70 @@ + +
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %> + <%= f.text_field "i18n_variable[#{locale}]", :value => (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <% sub_role.attribute_fields.each do |attribute_field| %> + <%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %> + <% end %> + +
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
+ <%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %> + <%= t(:add) %> + <%= hidden_field_tag 'sub_role_temp_id', 'new_sub_roles' %> +
+
+
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "attribute_form" %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/user_attribute_models/_attribute_model.html.erb b/app/views/admin/user_attribute_models/_attribute_model.html.erb deleted file mode 100644 index 819f584b..00000000 --- a/app/views/admin/user_attribute_models/_attribute_model.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -<%= fields_for "user_#{@attribute}_model[attribute_models][]", attribute_model, :index => nil do |f| %> - - <%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %> - - <%= 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 %> - - <% @site_valid_locales.each do |locale| %> - <%= text_field_tag "user_#{@attribute}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %> - <% end %> - - <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> -
> - <%= t('admin.options') %>: - <%= text_field_tag "user_#{@attribute}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %> -
- - - - <% if attribute_model.new_record? %> - <%= t(:delete) %> - <% else %> - <% if attribute_model.is_built_in? %> - - <%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %> - <% else %> - <%= t(:delete) %> - <%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %> - <% end %> - <%= f.hidden_field :id %> - <%= f.hidden_field :key %> - <% end %> - - - -<% end %> \ No newline at end of file diff --git a/app/views/admin/user_attribute_models/_form.html.erb b/app/views/admin/user_attribute_models/_form.html.erb deleted file mode 100644 index edbcae39..00000000 --- a/app/views/admin/user_attribute_models/_form.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -
-

<%= t("admin.user_#{@attribute}") %>

-
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - -
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %> - <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> -
-
-
- - -
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
-
-
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "user_attribute_model_form" %> -<% end -%> diff --git a/app/views/admin/user_attribute_models/admin.html.erb b/app/views/admin/user_attribute_models/admin.html.erb deleted file mode 100644 index a4bbbb43..00000000 --- a/app/views/admin/user_attribute_models/admin.html.erb +++ /dev/null @@ -1,31 +0,0 @@ - - - - - <%= @title || APP_CONFIG['orbit'] %> - - <%= stylesheet_link_tag "admin" %> - <%= javascript_include_tag "admin" %> - <%= yield :page_specific_css %> - <%= yield :page_specific_javascript %> - <%= csrf_meta_tag %> - - - - -
- -
- <%= yield %> -
-
<%= yield :tertiary %>
- -
- - diff --git a/app/views/admin/user_attribute_models/edit.html.erb b/app/views/admin/user_attribute_models/edit.html.erb deleted file mode 100644 index d0442fb8..00000000 --- a/app/views/admin/user_attribute_models/edit.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<% content_for :secondary do %> - <%= render 'side_bar' %> -<% end %> - -
- <%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %> - <%= f.error_messages %> - <%= render :partial => 'form', :locals => { :f => f } %> -
- <%= link_back %> - <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> -
- <% end -%> -
\ No newline at end of file diff --git a/app/views/admin/user_attribute_models/index.html.erb b/app/views/admin/user_attribute_models/index.html.erb deleted file mode 100644 index 87c5bb2c..00000000 --- a/app/views/admin/user_attribute_models/index.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %> -
- - - - - - - - - <% @user_attribute_models.each do |user_attribute_model| %> - "> - - - - - - - <% end %> - -
<%= t("admin.#{@attribute}") %><%= t('admin.action') %>
<%= user_attribute_model.i18n_variable[I18n.locale] %> - <%= 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 %> -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %> -
-
diff --git a/app/views/admin/user_attribute_models/new.html.erb b/app/views/admin/user_attribute_models/new.html.erb deleted file mode 100644 index 490561fa..00000000 --- a/app/views/admin/user_attribute_models/new.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
- <%= 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 } %> -
- <%= link_back %> - <%= link_to t('create'), "#", :onclick=>"$('#new_user_attribute_model').submit()" %> -
- <% end -%> -
- - - - diff --git a/app/views/admin/user_attribute_models/toggle_enable.js.erb b/app/views/admin/user_attribute_models/toggle_enable.js.erb deleted file mode 100644 index 153c24a8..00000000 --- a/app/views/admin/user_attribute_models/toggle_enable.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -$("#enable_<%= @user_attribute_model.id %>").toggle(); -$("#disable_<%= @user_attribute_model.id %>").toggle(); -$("#attribute_<%= @user_attribute_model.id %>").toggleClass('disable'); \ No newline at end of file diff --git a/app/views/admin/user_attributes/index.html.erb b/app/views/admin/user_attributes/index.html.erb deleted file mode 100644 index b5965a79..00000000 --- a/app/views/admin/user_attributes/index.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> -
-
    -
  • - <%= t("admin.#{@attribute}") %> - <%= t('admin.action') %> -
  • - <% @user_attribute_models.each do |user_attribute_model| %> -
  • clear"> - <%= user_attribute_model.i18n_variable[I18n.locale] %> - - - <%= 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 %> - - -
  • - <% end %> -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> -
-
diff --git a/app/views/admin/user_attributes/new.html.erb b/app/views/admin/user_attributes/new.html.erb deleted file mode 100644 index f04da0e5..00000000 --- a/app/views/admin/user_attributes/new.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -

New user attribute: <%= @user_attribute.key %>

- -<% form_for @user_attribute, :url => admin_user_attributes_path do |f| %> - -

- <%= f.label :key, "Key" %> - <%= f.text_field :key %> -

- - <%= render :partial => "form", :locals => { :f => f } %> - -

- <%= f.submit %> -

- -<% end -%> diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb index bbf39e4d..5c57284b 100644 --- a/app/views/admin/users/_form.html.erb +++ b/app/views/admin/users/_form.html.erb @@ -16,27 +16,27 @@
-<% @user_info_models.each do |ua| %> -
+<% @infos.each do |ua| %> +

<%= ua.i18n_variable[I18n.locale] %>


- <%= 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'} %>
<% end -%> -
- <% @user_role_models.each do |ua| %> -