From 6dff83339a0d7aeaf98e6980a289fd94eb959775 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 22 Nov 2012 17:49:44 +0800 Subject: [PATCH 1/2] disable data transform when switching attribute field type. new member stable --- app/assets/javascripts/inc/attribute_onoff.js | 4 + .../admin/users_new_interface_controller.rb | 4 +- app/helpers/attribute_fields_helper.rb | 58 +++++++--- app/helpers/attribute_values_helper.rb | 31 +++-- app/models/user/attribute_field.rb | 108 +++++++++--------- app/models/user/attribute_value.rb | 30 +++-- app/views/admin/attributes/edit.html.erb | 2 +- .../admin/infos/_attribute_field.html.erb | 4 +- .../admin/infos/_placeholder_block.html.erb | 4 +- .../admin/users_new_interface/_role.html.erb | 2 +- .../users_new_interface/_side_bar.html.erb | 4 +- config/mongoid.yml | 2 +- lib/tasks/data_migration.rake | 21 +++- 13 files changed, 176 insertions(+), 98 deletions(-) diff --git a/app/assets/javascripts/inc/attribute_onoff.js b/app/assets/javascripts/inc/attribute_onoff.js index efcbabd5..f1541a11 100644 --- a/app/assets/javascripts/inc/attribute_onoff.js +++ b/app/assets/javascripts/inc/attribute_onoff.js @@ -13,8 +13,10 @@ $(document).ready(function(){ $(this).parents(".map-block").find(".form-horizontal").toggleClass("hide"); if($(this).parents(".map-block").hasClass("disabled")){ $(this).text("OFF"); + $(this).siblings(".subrole_disable_field").val("true"); }else{ $(this).text("ON"); + $(this).siblings(".subrole_disable_field").val("false"); } } if($(this).parents("legend").length==1) { @@ -22,8 +24,10 @@ $(document).ready(function(){ $(this).parents("legend").next("div").toggleClass("hide"); if($(this).parents("legend").next("div").hasClass("hide")){ $(this).text("OFF"); + $(this).siblings(".subrole_disable_field").val("true"); }else{ $(this).text("ON"); + $(this).siblings(".subrole_disable_field").val("false"); } checkSwitch(); } diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 69c22ed6..2daa30ff 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -5,8 +5,8 @@ class Admin::UsersNewInterfaceController < OrbitBackendController # before_filter :set_attribute, :only => [:index, :show, :new, :edit] before_filter :force_order_for_visitor,:only=>[:index,:show] - before_filter :force_order_for_user,:except => [:index,:show] - before_filter :for_app_sub_manager,:except => [:index,:show] + before_filter :authenticate_user!,:except => [:index,:show] + before_filter :set_attribute,:except => [:index,:show] def index get_tags diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb index ded899ad..270a5516 100644 --- a/app/helpers/attribute_fields_helper.rb +++ b/app/helpers/attribute_fields_helper.rb @@ -55,7 +55,19 @@ module AttributeFieldsHelper end def render_date - control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} + if date_is_range? + fill_from = @attribute_value.get_date(:from) rescue nil + fill_to = @attribute_value.get_date(:to) rescue nil + control_group_wrapper do + buf = date_select(get_field_name_base+'[from]',nil,@markup_options.merge(:default=>fill_from),:class=>"input-small") + buf << ' ~ ' + buf << date_select(get_field_name_base+'[to]',nil,@markup_options.merge(:default=>fill_to),:class=>"input-small") + buf + end + else + @prefiled_value = @attribute_value.get_date + control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} + end end def render_date_durnation #Need re-write low priority @@ -66,7 +78,7 @@ module AttributeFieldsHelper @prefiled_value ||=[] control_group_wrapper do self[:option_list].collect do |key,value| - label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label")) + label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>" radio inline")) end.join end end @@ -87,13 +99,23 @@ module AttributeFieldsHelper end def render_text_field - control_group_wrapper do |key,value| + a = control_group_wrapper do |key,value| add_more_blank = can_add_more ? "[]" : "" key_field = can_muti_lang_input? ? "[#{key}]" : "" place_holder= @panel_setting["placeholder"][key] rescue '' text_field_tag([get_field_name_base,add_more_blank,key_field].join, value,@markup_options.merge(:placeholder=>place_holder)) end end + +def date_is_range? + is_range = "false" + data = get_data + if !data.nil? + is_range = data['is_range'] if data.has_key? "is_range" + end + is_range == "true" +end + protected def lang_panel_tabbable_wrapper(add_more_params,&block) @@ -117,17 +139,15 @@ protected content_tag(:div,yield(key,value),:class=>div_class) end# of VALID_LOCALES.collect for tabed input buff << link_to((content_tag :i,'',:class=>'icon-edit'),"##{get_pairing_tab_class({})}_m_window",:class=>'btn edit-btn',:type=>'button',:data=>{:toggle=>"modal"}) if self.markup == 'address' - buff << link_to((content_tag :i,'',:class=>'icon-trash'),"#") if self.add_more + buff << link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn removeInput") if self.add_more - - # buff << '' if self.add_more - buff.join("\n").html_safe + buff.join('').html_safe end tmp << content_tag(:ul,:class=> 'nav nav-pills') do VALID_LOCALES.each.collect do |key| # link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}" link_entry_ary = [".#{get_pairing_tab_class({})}",".#{key}"] - # link_entry_ary << ".add_more_item_#{add_more_counter}" if can_add_more + link_entry_ary << ".add_more_item_#{add_more_counter}" if can_add_more link_entry = link_entry_ary.join content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil),:for=>key) end.join.html_safe # of VALID_LOCALES.collect for tabs @@ -151,16 +171,18 @@ protected if can_muti_lang_input? result << lang_panel_tabbable_wrapper(add_more_params,&block) result << gen_modal_dialog if self.markup == "address" - else + else #cross lang field - value = case can_add_more - when true - add_more_params[0] - else - @prefiled_value + case can_add_more + when true + value = add_more_params[0][:value] + result << content_tag(:div,:class=>"input-append"){yield(nil,value) + link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn removeInput") } + else + value = @prefiled_value + result << yield(nil,value) end - result << yield(nil,value) + end result.html_safe @@ -173,12 +195,12 @@ protected case self.markup when "text_field" if can_add_more - multipleInput_ary = %w{multipleInput editMore} + multipleInput_ary = %w{multipleInput} add_more_seri = "add_more_group_#{id}" multipleInputs = content_tag :div,:class=> multipleInput_ary.join(' ') ,:ext_class=>get_pairing_tab_class({}) do @attribute_value.add_more_counter.times.collect do |t| controls_wrapper(:value=>(@prefiled_value[t] rescue nil),:counter=>t,&block) - end.join("\n").html_safe # of add_more fields + end.join('').html_safe # of add_more fields end # of div multipleInput editMore result = label + multipleInputs + add_more_unt # result = label + 一堆的輸入框(要用 multipleInput editMore 包起來) + add_more btn + hidden_fields @@ -267,7 +289,7 @@ protected if self.markup == "address" return false else - locale and LIST[:markups][markup]["ext_support"] && add_more + add_more end end diff --git a/app/helpers/attribute_values_helper.rb b/app/helpers/attribute_values_helper.rb index f2ea0832..eede44fb 100644 --- a/app/helpers/attribute_values_helper.rb +++ b/app/helpers/attribute_values_helper.rb @@ -1,6 +1,14 @@ module AttributeValuesHelper - def show_west_calender - date = get_date + def show_west_calender(from_to=nil) + case from_to + when :to + date = get_date(:to) + when :from + date = get_date(:from) + when nil + date = get_date + end + case self.attribute_field["typeC"]["format"] when 'format1' # Y/M/D h:m date.strftime("%Y/%m/%d %H:%M") @@ -13,9 +21,16 @@ module AttributeValuesHelper end # of case west cal format end - def show_minguo_calendar + def show_minguo_calendar(from_to=nil) get_minguo - date = get_date + case from_to + when :to + date = get_date(:to) + when :from + date = get_date(:from) + when nil + date = get_date + end year_str = "" unless date.year == 1912 m_year = (date.year - 1912).abs.to_s + I18n.t("admin.infos.date.minguo_calendar.year") @@ -52,17 +67,17 @@ module AttributeValuesHelper end # of case end - def get_date_by_format + def get_date_by_format(from_to = nil) case I18n.locale when :zh_tw case when self.attribute_field["typeC"]["claendar"] == "west_claendar" - show_west_calender + show_west_calender(from_to) when self.attribute_field["typeC"]["claendar"] == "tw_claendar" - show_minguo_calendar + show_minguo_calendar(from_to) end #case self.attribute_field["typeC"]["claendar"] when :en - show_west_calender + show_west_calender(from_to) end end end \ No newline at end of file diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 9442deac..76ee9394 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -30,12 +30,7 @@ class AttributeField end def locale - default = true - if get_data["locale"].nil? - return default - else - (get_data["locale"] == "true" ? true : false) rescue default - end + get_data["cross_lang"] == "true" ? false : true end def self_defined_markup_options? @@ -107,56 +102,63 @@ protected end def add_more_convert(opt) - case opt - when :to_add_more - self.attribute_values.each do |av| - VALID_LOCALES.each do |loc| - splited_str = av[loc].split(",") rescue [] - av["val"] = [] if av["val"].nil? - splited_str.each_with_index{|value,index| av["val"][index] = av["val"][index].nil? ? {loc=>value} : av["val"][index].merge(loc=>value) } - end - av.unset_all_lang_values - av.save - end #of self.attribute_values.each - when :to_no_add_more - self.attribute_values.each do |av| - VALID_LOCALES.each do |loc| - if av["val"].kind_of? Array - av[loc] = av["val"].collect{|t| t[loc]}.join(",") - else - av[loc] = av["val"] - end - end - av.unset("val") - av.save - end #of self.attribute_values.each - end + # case opt + # when :to_add_more + # self.attribute_values.each do |av| + # VALID_LOCALES.each do |loc| + # splited_str = av[loc].split(",") rescue [] + # av["val"] = [] if av["val"].nil? + + # old_data = av["val"] + # av["val"] = [] + # splited_str.each_with_index do |value,index| + # av["val"][index] = {loc=>value} + # end + # av["val"] << old_data + # end + # av.unset_all_lang_values + # av.save + # end #of self.attribute_values.each + # when :to_no_add_more + # self.attribute_values.each do |av| + # VALID_LOCALES.each do |loc| + # binding.pry + # if av["val"].kind_of? Array + # av[loc] = av["val"].collect{|t| t[loc]}.join(",") + # else + # av[loc] = av["val"] + # end + # end + # av.unset("val") + # av.save + # end #of self.attribute_values.each + # end end def cross_lang_convert(opt) - case opt - when :to_cross_lang - self.attribute_values.each do |av| - if add_more - av["val"] = av["val"].collect{|t| t.invert.keys.join(",")} - else - av["val"] = VALID_LOCALES.collect{|t| av[t]}.join(",") - av.unset_all_lang_values - end - av.save - end #of self.attribute_values.each - when :to_no_cross_lang - default_locale = I18n.default_locale.to_s - self.attribute_values.each do |av| - if add_more - av["val"] = av["val"].collect{|t| {default_locale => t} } #unless av["val"].nil? - else - av[default_locale] = av["val"] - av.unset("val") - end - av.save - end #of self.attribute_values.each - end + # case opt + # when :to_cross_lang + # self.attribute_values.each do |av| + # if add_more + # av["val"] = av["val"].collect{|t| t.invert.keys.join(",")} + # else + # av["val"] = VALID_LOCALES.collect{|t| av[t]}.join(",") + # av.unset_all_lang_values + # end + # av.save + # end #of self.attribute_values.each + # when :to_no_cross_lang + # default_locale = I18n.default_locale.to_s + # self.attribute_values.each do |av| + # if add_more + # av["val"] = av["val"].collect{|t| {default_locale => t} } #unless av["val"].nil? + # else + # av[default_locale] = av["val"] + # av.unset("val") + # end + # av.save + # end #of self.attribute_values.each + # end end def check_add_more_convert(var) diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index 256fe072..38fcf081 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -49,7 +49,12 @@ class AttributeValue when "text_field" case self.attribute_field.add_more when true - add_more_index.nil? ? self.value.collect{|t| t[locale]}.join(",") : self.value(add_more_index)[locale] + if self.attribute_field.locale + add_more_index.nil? ? self.value.collect{|t| t[locale]}.join(",") : self.value(add_more_index)[locale] + else + add_more_index.nil? ? self.value.join(",") : self.value(add_more_index) + end + when false self.attribute_field.locale ? self[locale.to_s] : self.value end @@ -62,7 +67,11 @@ class AttributeValue self.attribute_field.locale ? self[locale.to_s] : self.value when "date" - get_date_by_format + if self.attribute_field.date_is_range? + get_date_by_format(:from) + ' ~ ' + get_date_by_format(:to) + else + get_date_by_format + end when "address" self.value[locale.to_s] @@ -83,6 +92,18 @@ class AttributeValue end end + def get_date(item = nil) + case item + when :from + data = self[:val]["from"] + when :to + data = self[:val]["to"] + when nil + data = self[:val] + end + Date.new(data["(1i)"].to_i,data["(2i)"].to_i,data["(3i)"].to_i) rescue nil + end + protected @@ -130,9 +151,4 @@ def unset_all_lang_values end end - - def get_date - Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil - end - end diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index 90f0c750..3ced1d2b 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -14,7 +14,7 @@ <% end %> - <%= render :partial=>"placeholder_block",:locals=>{:value=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.item_name"),:field_name=>"info[title_translations]"}%> + <%= render :partial=>"placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.item_name"),:field_name=>"info[title_translations]"}%> diff --git a/app/views/admin/infos/_attribute_field.html.erb b/app/views/admin/infos/_attribute_field.html.erb index f8c7a701..e5b2d0de 100644 --- a/app/views/admin/infos/_attribute_field.html.erb +++ b/app/views/admin/infos/_attribute_field.html.erb @@ -66,10 +66,10 @@
diff --git a/app/views/admin/infos/_placeholder_block.html.erb b/app/views/admin/infos/_placeholder_block.html.erb index 9417e055..9098d08d 100644 --- a/app/views/admin/infos/_placeholder_block.html.erb +++ b/app/views/admin/infos/_placeholder_block.html.erb @@ -7,8 +7,8 @@ <% @site_valid_locales.each do |locale| %> <% active = (locale == @site_valid_locales.first ? "active in" : "'") %> <%= content_tag :div,:class=>"tab-pane fade #{active}",:id=>"#{name_to_id(field_name)}_#{locale}" do%> - <% value = values[locale.to_s] rescue nil%> - <%= text_field(field_name, locale,:value=>value,:placeholder=>t("langs.#{locale}")) %> + <% locale_value = values[locale.to_s] rescue nil%> + <%= text_field(field_name, locale,:value=>locale_value,:placeholder=>t("langs.#{locale}")) %> <% end %> <% end %> diff --git a/app/views/admin/users_new_interface/_role.html.erb b/app/views/admin/users_new_interface/_role.html.erb index 405bfad8..f6cc81a9 100644 --- a/app/views/admin/users_new_interface/_role.html.erb +++ b/app/views/admin/users_new_interface/_role.html.erb @@ -6,10 +6,10 @@ <% role.sub_roles.each do |sub_role| %> <% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %> - <%= hidden_field_tag("user[disable_sub_role][id][#{sub_role.id}]",sub_role_disable,:for=>@form_index,:class=>"subrole_disable_field",:value=>sub_role_disable)%> <%#= hidden_field_tag("[user][new_attribute_values][sub_role][disable][#{sub_role.id}]",sub_role_disable)%> <%= sub_role.title %> + <%= hidden_field_tag("user[disable_sub_role][id][#{sub_role.id}]",sub_role_disable,:for=>@form_index,:class=>"subrole_disable_field",:value=>sub_role_disable)%>
<% sub_role.attribute_fields.each do |af|%> diff --git a/app/views/admin/users_new_interface/_side_bar.html.erb b/app/views/admin/users_new_interface/_side_bar.html.erb index 3f82987b..78236d37 100644 --- a/app/views/admin/users_new_interface/_side_bar.html.erb +++ b/app/views/admin/users_new_interface/_side_bar.html.erb @@ -3,8 +3,8 @@ <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('users_new_interface')) do -%> <%= content_tag :li, link_to((t('admin.new_admin.side_bar.all_user') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_users_new_interface_index_path), :class => active_for_action('users_new_interface', 'index') %> <%= content_tag :li, link_to((t('admin.new_admin.side_bar.add_user') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') %> - <%= content_tag :li, link_to((t('admin.new_admin.side_bar.user_roles') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, ), :class => active_for_action('users_new_interfacexx', 'index') %> - <%= content_tag :li, link_to((t('admin.new_admin.side_bar.user_info') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, ), :class => active_for_action('users_new_interfacexx', 'index') %> + <%= content_tag :li, link_to((t('admin.new_admin.side_bar.user_roles') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_infos_path ), :class => active_for_action('users_new_interfacexx', 'index') %> + <%= content_tag :li, link_to((t('admin.new_admin.side_bar.user_info') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_roles_path), :class => active_for_action('users_new_interfacexx', 'index') %> <% end -%> <% end -%> diff --git a/config/mongoid.yml b/config/mongoid.yml index 75c5ef80..a809bc06 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -2,7 +2,7 @@ defaults: &defaults host: localhost # slaves: # - host: slave1.local - port: 37017 + port: 27017 # - host: slave2.local # port: 27019 diff --git a/lib/tasks/data_migration.rake b/lib/tasks/data_migration.rake index 9c93c18a..c1745f34 100644 --- a/lib/tasks/data_migration.rake +++ b/lib/tasks/data_migration.rake @@ -2,7 +2,26 @@ require 'resque_scheduler/tasks' namespace :data_migration do - + task :migrate_user_infos_from_1121 => :environment do + AttributeField.all.each do |af| + + if af.has_attribute?('locale') + af.title_translations = case af[:locale] + when true + af[:locale_title] + when false + {af[:neutral_for] => af[:neutral_title]} + end + af.unset("locale") + af.unset("locale_title") + af.unset("neutral_for") + af.unset("neutral_title") + af.save + end + end + end + + task :add_order_to_announcement_tag_0703 => :environment do AnnouncementTag.first({conditions:{ key: 'students' }}).update_attributes(:order=>1) AnnouncementTag.first({conditions:{ key: 'alumni' }}).update_attributes(:order=>2) From cc7907f37a01f4a3c2be9123f2573d3cfa7f0319 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 22 Nov 2012 18:20:11 +0800 Subject: [PATCH 2/2] user roles starts --- .../admin/add_attribute_field.js.erb.bak} | 0 app/controllers/admin/roles_controller.rb | 5 +++-- app/views/admin/attributes/edit.html.erb | 4 ++-- .../infos/{_form.html.erb => _form.html.erb.bak} | 0 ...ield.html.erb => _attribute_field.html.erb.bak} | 0 .../roles/{_form.html.erb => _form.html.erb.bak} | 0 .../{_form_sub.html.erb => _form_sub.html.erb.bak} | 0 .../{_sub_role.html.erb => _sub_role.html.erb.bak} | 0 .../attribute_field}/_attribute_field.html.erb | 14 +++++++------- .../attribute_field}/_list_block.html.erb | 0 .../attribute_field}/_placeholder_block.html.erb | 0 config/mongoid.yml | 2 +- 12 files changed, 13 insertions(+), 12 deletions(-) rename app/{views/admin/infos/add_attribute_field.js.erb => assets/stylesheets/admin/add_attribute_field.js.erb.bak} (100%) rename app/views/admin/infos/{_form.html.erb => _form.html.erb.bak} (100%) rename app/views/admin/roles/{_attribute_field.html.erb => _attribute_field.html.erb.bak} (100%) rename app/views/admin/roles/{_form.html.erb => _form.html.erb.bak} (100%) rename app/views/admin/roles/{_form_sub.html.erb => _form_sub.html.erb.bak} (100%) rename app/views/admin/roles/{_sub_role.html.erb => _sub_role.html.erb.bak} (100%) rename app/views/{admin/infos => shared/attribute_field}/_attribute_field.html.erb (79%) rename app/views/{admin/infos => shared/attribute_field}/_list_block.html.erb (100%) rename app/views/{admin/infos => shared/attribute_field}/_placeholder_block.html.erb (100%) diff --git a/app/views/admin/infos/add_attribute_field.js.erb b/app/assets/stylesheets/admin/add_attribute_field.js.erb.bak similarity index 100% rename from app/views/admin/infos/add_attribute_field.js.erb rename to app/assets/stylesheets/admin/add_attribute_field.js.erb.bak diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index d02224a5..abae1ece 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -1,10 +1,11 @@ class Admin::RolesController < ApplicationController - layout "admin" + layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? before_filter :set_attribute, :only => [:index, :show, :new, :edit] - + helper Admin::AttributeValuesViewHelper + def index @attributes = Role.all.entries render :template => 'admin/attributes/index' diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index 3ced1d2b..f74890dc 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -14,14 +14,14 @@ <% end %>
- <%= render :partial=>"placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.item_name"),:field_name=>"info[title_translations]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.item_name"),:field_name=>"info[title_translations]"}%>

<%= t("admin.attributes")%>

- <%= render :partial=>"attribute_field",:collection=>@attribute.attribute_fields%> + <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields%>
diff --git a/app/views/admin/infos/_form.html.erb b/app/views/admin/infos/_form.html.erb.bak similarity index 100% rename from app/views/admin/infos/_form.html.erb rename to app/views/admin/infos/_form.html.erb.bak diff --git a/app/views/admin/roles/_attribute_field.html.erb b/app/views/admin/roles/_attribute_field.html.erb.bak similarity index 100% rename from app/views/admin/roles/_attribute_field.html.erb rename to app/views/admin/roles/_attribute_field.html.erb.bak diff --git a/app/views/admin/roles/_form.html.erb b/app/views/admin/roles/_form.html.erb.bak similarity index 100% rename from app/views/admin/roles/_form.html.erb rename to app/views/admin/roles/_form.html.erb.bak diff --git a/app/views/admin/roles/_form_sub.html.erb b/app/views/admin/roles/_form_sub.html.erb.bak similarity index 100% rename from app/views/admin/roles/_form_sub.html.erb rename to app/views/admin/roles/_form_sub.html.erb.bak diff --git a/app/views/admin/roles/_sub_role.html.erb b/app/views/admin/roles/_sub_role.html.erb.bak similarity index 100% rename from app/views/admin/roles/_sub_role.html.erb rename to app/views/admin/roles/_sub_role.html.erb.bak diff --git a/app/views/admin/infos/_attribute_field.html.erb b/app/views/shared/attribute_field/_attribute_field.html.erb similarity index 79% rename from app/views/admin/infos/_attribute_field.html.erb rename to app/views/shared/attribute_field/_attribute_field.html.erb index e5b2d0de..c18e0b9f 100644 --- a/app/views/admin/infos/_attribute_field.html.erb +++ b/app/views/shared/attribute_field/_attribute_field.html.erb @@ -13,7 +13,7 @@
- <%= render :partial=>"placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.name"),:field_name=>"info[attribute_fields][#{attribute_field_counter}][title_translations]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t("admin.infos.name"),:field_name=>"info[attribute_fields][#{attribute_field_counter}][title_translations]"}%>
@@ -42,16 +42,16 @@
- <%= render :partial=> "placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeA][placeholder]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeA][placeholder]"}%> <% end %> <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeB") do %> - <%= render :partial=> "placeholder_block",:locals=>{:label_ext=>t("admin.infos.initial"),:values=>attribute_field["typeB"]["initial"],:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeB][initial]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t("admin.infos.initial"),:values=>attribute_field["typeB"]["initial"],:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeB][initial]"}%> <% if attribute_field.self_defined_markup_options?%> - <%= render :partial=>"list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "info[attribute_fields][#{attribute_field_counter}][attribute][role][statuses]"} %> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "info[attribute_fields][#{attribute_field_counter}][attribute][role][statuses]"} %> <%else #normal list%> - <%= render :partial=>"list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "info[attribute_fields][#{attribute_field_counter}][typeB][option_list]"} %> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "info[attribute_fields][#{attribute_field_counter}][typeB][option_list]"} %> <% end #of self_defined_markup_options?%> <% end %> @@ -95,10 +95,10 @@ - <%= render :partial=> "placeholder_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %> <% end %> <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeE") do%> - <%= render :partial=>"list_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"info[attribute_fields][#{attribute_field_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%> <% end %> <%= hidden_field "info[attribute_fields][#{attribute_field_counter}]","id",:value=>attribute_field.id%> diff --git a/app/views/admin/infos/_list_block.html.erb b/app/views/shared/attribute_field/_list_block.html.erb similarity index 100% rename from app/views/admin/infos/_list_block.html.erb rename to app/views/shared/attribute_field/_list_block.html.erb diff --git a/app/views/admin/infos/_placeholder_block.html.erb b/app/views/shared/attribute_field/_placeholder_block.html.erb similarity index 100% rename from app/views/admin/infos/_placeholder_block.html.erb rename to app/views/shared/attribute_field/_placeholder_block.html.erb diff --git a/config/mongoid.yml b/config/mongoid.yml index a809bc06..75c5ef80 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -2,7 +2,7 @@ defaults: &defaults host: localhost # slaves: # - host: slave1.local - port: 27017 + port: 37017 # - host: slave2.local # port: 27019