diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css
index 1fe9350d..d342e54b 100644
--- a/app/assets/stylesheets/member.css
+++ b/app/assets/stylesheets/member.css
@@ -309,4 +309,7 @@
}
.user-role .staff h4 .gender {
border-color: #139E2F transparent transparent #139E2F;
+}
+.user-role .tab-content, .user-role .tabs-right > .nav-tabs {
+ float: left;
}
\ No newline at end of file
diff --git a/app/assets/stylesheets/site-map.css b/app/assets/stylesheets/site-map.css
index 3e5fb511..711b10e2 100644
--- a/app/assets/stylesheets/site-map.css
+++ b/app/assets/stylesheets/site-map.css
@@ -12,12 +12,12 @@
border-radius: 4px;
margin-bottom: 10px;
}
-.site-map .map-block ul {
+.site-map .map-block > ul {
margin: 0px;
list-style: none;
width: 220px \9;
}
-.site-map .map-block li {
+.site-map .map-block li.clear {
background-color: #F7F7F7;
padding: 5px 15px;
border-top: 1px solid #FFF;
diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb
index 21306c6e..5ffa6a06 100644
--- a/app/controllers/admin/infos_controller.rb
+++ b/app/controllers/admin/infos_controller.rb
@@ -32,6 +32,7 @@ class Admin::InfosController < ApplicationController
def update
@attribute = Info.find(params[:id])
+ # binding.pry
@attribute.update_attributes(params[:info])
respond_to do |format|
format.html { redirect_to :action => :index }
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 7be0e2d7..718fbbc5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2,6 +2,16 @@ module ApplicationHelper
FLASH_NOTICE_KEYS = [:error, :notice, :warning]
+ def show_attribute_value(value)
+ if value.kind_of? Hash
+ result = []
+ value.each{|t| result.push(t.last)}
+ result.join ","
+ else
+ value
+ end
+ end
+
def create_guest_user
u = User.create(:name => "guest", :email => "guest_#{Time.now.to_i}#{rand(99)}@example.com")
u.admin = false
diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb
index dfc30ddd..6dceccc2 100644
--- a/app/helpers/attribute_fields_helper.rb
+++ b/app/helpers/attribute_fields_helper.rb
@@ -1,3 +1,4 @@
+#encoding: utf-8
# require ActionView::Helpers::FormTagHelper
module AttributeFieldsHelper
@@ -5,6 +6,7 @@ module AttributeFieldsHelper
include ActionView::Helpers::FormOptionsHelper
include ActionView::Helpers::DateHelper
include ActionView::Helpers::TagHelper
+ include ActionView::Helpers::RenderingHelper
def block_helper(user,index)
@index = index
@@ -16,114 +18,124 @@ module AttributeFieldsHelper
return instance_eval("render_#{markup}") #rescue ""
end
- def render_text_area
- result = ""
- result << label
- if self.locale?
- @prefiled_value.each do |key,value|
- result << controls_wrapper{text_area_tag("#{get_field_name_base}[#{key.to_s}]", value, {})}
- end
- else
- value = @prefiled_value
- result << controls_wrapper{text_area_tag(get_field_name_base, value, {})}
- end
- result << end_block
- result.html_safe
+ def lang_tab(str,lang)
+ content_tag(:div,str,:class=>"tab-pane fade",:id=>(get_field_name_base+"tab_#{lang}"))
end
- def render_radio_button
- result = ""
- result << label
- markup_value.each do |key,value|
- result << controls_wrapper{label_tag(key,radio_button_tag(get_field_name_base+"[#{key}]", value[I18n.locale.to_s], (@prefiled_value==value ? true : false), {})+value[I18n.locale.to_s],:class=>"control-label")}
+ def render_address
+ control_group_wrapper do |key,value|
+ result = '
'.html_safe
+ result << gen_modal_dialog
end
- result << end_block
- result.html_safe
end
def render_checkbox
- # label+ "" + end_block
- # check_box_tag(name, value = "1", checked = false, options = {})
-
- result = ""
- result << label
- markup_value.each do |key,value|
- result << controls_wrapper{label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", value[I18n.locale.to_s], (@prefiled_value==value ? true : false), {})+value[I18n.locale.to_s],:class=>"control-label")}
- end
- result << end_block
- result.html_safe
-
- end
-
- def render_date_durnation
control_group_wrapper do
- if @new_attribute
- @prefiled_value = {}
- end
- label+controls_wrapper{date_select(get_field_name_base+"[value][from]",@prefiled_value["from"]) +date_select(get_field_name_base+"[value][end]",@prefiled_value["end"])} + end_block
+ markup_value.collect do |key,value|
+ label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", value[I18n.locale.to_s], (@prefiled_value==value ? true : false), {})+value[I18n.locale.to_s],markup_options.merge(:class=>"control-label"))
+ end.join rescue ""
end
end
- def render_text_field_ext
- result = ""
- result << label
- if self.locale?
- @prefiled_value.each do |key,value|
- result << controls_wrapper{text_field_tag("#{get_field_name_base}[#{key.to_s}]", value, {})}
- end
- else
- value = @prefiled_value
- result << controls_wrapper{text_field_tag(get_field_name_base, value, {})}
+ def render_date
+ control_group_wrapper{date_select(get_field_name_base+"[value]",@prefiled_value,markup_options,:class=>"input-small")}
+ end
+
+ def render_date_durnation #Need re-write low priority
+
+ end
+
+ def render_radio_button
+ control_group_wrapper do
+ markup_value.collect do |key,value|
+ label_tag(key,radio_button_tag(get_field_name_base, value[I18n.locale.to_s], (@prefiled_value==value ? true : false), {})+value[I18n.locale.to_s],markup_options.merge(:class=>"control-label"))
+ end.join rescue ""
end
- result << end_block
- result.html_safe
end
-
- def render_date
- label+controls_wrapper{date_select(get_field_name_base+"[value]",@prefiled_value)} + end_block
+ def render_select
+ control_group_wrapper{select_tag( get_field_name_base+"[value]",options_for_select(markup_value.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),markup_options)} rescue ""
end
- def render_select
- label+controls_wrapper{select_tag( get_field_name_base+"[value]",options_for_select(markup_value.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value))} + end_block
+ def render_text_area
+ control_group_wrapper{|key,value|text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}]"), value,markup_options)}
end
def render_text_field
- result = ""
- result << label
- if self.locale?
- @prefiled_value.each do |key,value|
- result << controls_wrapper{text_field_tag("#{get_field_name_base}[#{key.to_s}]", value, {})}
- end
- else
- value = @prefiled_value
- result << controls_wrapper{text_field_tag(get_field_name_base, value, {})}
+ control_group_wrapper do |key,value|
+ if(add_more and value.is_a?(Hash))
+ values = value
+ values.each_with_index.collect do |value,index|
+ text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,markup_options)
+ end.join.html_safe
+ else
+ text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}]"), value,markup_options)
end
- result << end_block
- result.html_safe
end
-
- def render_email
- label+controls_wrapper{email_field_tag(get_field_name_base, value, {})}+ end_block
- end
-
- def render_addr
- label+controls_wrapper{text_field_tag(get_field_name_base, value, {})} + end_block
- end
-
+end
protected
+ def lang_panel_control_wrapper(&block)
+ result = ''
+ result << '
'
+ result << controls_wrapper{yield}
+ result << '
'
+ result << '
'
+ result.html_safe
+ end
def controls_wrapper(&block)
result = ""
- result << yield
+ if can_muti_lang_input
+ result << "
"
+ result << "
"
+ VALID_LOCALES.collect do |key|
+ value = @prefiled_value[key.to_s] rescue nil
+ div_class = ["tab-pane" ,"fade"].join(" ")
+ div_class << (key == I18n.locale.to_s ? " active in" : '')
+ result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}")
+ end
+ result << "
"
+ result << "
"
+ VALID_LOCALES.each do |key|
+ result << content_tag(:li,link_to(I18n.t("langs."+key),"#tab"+id.to_s+"_#{key}",:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil))
+ end
+ result << "
"
+ result << "
"
+ # @prefiled_value.collect do |key,value|
+ # result << yield(key,value)
+ # end
+ else
+ result << yield
+ end
+ if can_add_more
+ result << '
'
+ result << ' Add'
+ result << ''
+ end
result << "
"
result.html_safe
end
- def control_group_wrapper(&block)
- result = ""
- result << yield
- result << "
"
+ def control_group_wrapper(&block)
+ div_class = can_muti_lang_input ? "control-group language-swich" : "control-group"
+ temp = label + controls_wrapper(&block)
+
+ result = content_tag(:div,temp,:class=>div_class)
+ result << end_block
+
result.html_safe
end
@@ -148,4 +160,36 @@ protected
label_tag(key,title,:class=>"control-label")
end
+ def can_muti_lang_input
+ locale and LIST[:markups][markup]["muti_lang_input_supprt"]
+ end
+
+ def can_add_more
+ locale and LIST[:markups][markup]["ext_support"] && add_more
+ end
+
+def render_anywhere(partial, assigns)
+ view = ActionView::Base.new(Rails::Configuration.new.view_path, assigns)
+ ActionView::Base.helper_modules.each { |helper| view.extend helper }
+ view.extend ApplicationHelper
+ view.render(:partial => partial)
+end
+
+def gen_modal_dialog
+ result = ''
+ result << ''
+ result << '
'
+ result << '
One fine body…
'
+ result << '
'
+ result << ''
+ result << '
'
+ result.html_safe
+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 826627eb..d7b21414 100644
--- a/app/models/user/attribute_field.rb
+++ b/app/models/user/attribute_field.rb
@@ -5,12 +5,15 @@ class AttributeField
include AttributeFieldHelper
field :key
- field :markup #[select,text_field,email,date,addr]
+ field :markup
field :markup_value ,:type => Hash
+ field :markup_options,:type => Hash
field :locale, :type => Boolean, :default => true
- field :list_options, :type => Array
+ # field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
+ field :add_more,:type => Boolean, :default => false
+
#field :title, localize: true
field :locale_title, localize: true
@@ -21,6 +24,20 @@ class AttributeField
has_many :attribute_values
# validates_uniqueness_of :key
+
+ def markup_options=(var)
+ self[:markup_options] = (eval(var) rescue {})
+ end
+
+ def markup_options
+ if self[:markup_options].nil?
+ return {}
+ else
+ Hash[self[:markup_options].map{|key,val|[key.to_sym,val]}] rescue {}
+ end
+
+ end
+
def role
self.attribute.role
end
@@ -46,7 +63,7 @@ class AttributeField
return self.neutral_title
end
end
-
+
def title=(var)
# binding.pry
if locale
@@ -56,15 +73,15 @@ class AttributeField
end
end
- # Convert the string list_options into an array
- def select_list_options=(var)
- self.list_options = var.gsub(' ', '').split(',')
- 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
+ # # Convert the array list_options into a string
+ # def select_list_options
+ # self.list_options.to_a.join(', ')
+ # end
def is_built_in?
self.built_in
diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb
index 49014e2a..efef05c1 100644
--- a/app/models/user/attribute_value.rb
+++ b/app/models/user/attribute_value.rb
@@ -11,7 +11,7 @@ class AttributeValue
before_save :check_key
- NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"]
+ # NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"]
def check_key
self.key = attribute_field.key
@@ -31,19 +31,25 @@ class AttributeValue
self.attribute_field.locale ? self[locale] : self[:value]
when "select"
self.attribute_field.markup_value[self[:value]][locale.to_s] || NoData
- when "email"
- self[:value]
+ when "text_area"
+ #self[:value]
when "date"
Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i)
when "addr"
self[:value]
+ when "radio_button"
+ self[:value]
+ when "checkbox"
+ self[:value]
+ when "date_durnation"
+ self[:value]
else
self.attribute_field.locale ? self[locale] : self[:value]
end
end
def get_values
- if self.attribute_field.locale && !(NO_MULTI_TAG.include? self.attribute_field.markup)
+ if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"]
return Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}]
else
return self[:value]
diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb
index 5111f015..58236e36 100644
--- a/app/views/admin/attributes/_attribute_field.html.erb
+++ b/app/views/admin/attributes/_attribute_field.html.erb
@@ -11,10 +11,18 @@
- - <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
- - <%= f.check_box :locale %><%= label_tag "Locale" %>
- - <%= attribute_field[:markup].eql?('select') ? nil : "style='display:none'"%>
- - <%= t('admin.options') %>: <%= f.text_field :markup_value%>
+ - markup<%= f.select :markup, LIST[:markups].keys, {}, {:style => "width:90px"} %>
+ - markup_value<%= f.text_field :markup_value,:size=>50 %>
+ - markup_options<%= f.text_field :markup_options,:size=>50 %>
+ - locale<%= f.check_box :locale,{},true,false %>
+ - built_in<%= f.check_box :built_in,{},true,false %>
+ - disabled<%= f.check_box :disabled,{},true,false %>
+ - add_more<%= f.check_box :add_more,{},true,false %>
+ - neutral_title<%= f.text_field :neutral_title,:size=>50 %>
+
diff --git a/app/views/admin/users_new_interface/_info.html.erb b/app/views/admin/users_new_interface/_info.html.erb
index d821b209..24b0d976 100644
--- a/app/views/admin/users_new_interface/_info.html.erb
+++ b/app/views/admin/users_new_interface/_info.html.erb
@@ -3,9 +3,7 @@
<%= yield :tertiary %>
-
+
|