From 1ce7f00084a8143714f8277a0ce2248288ce00ce Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 12 Oct 2012 18:09:02 +0800 Subject: [PATCH 01/13] new code for attribute fields and values for new member interface --- app/assets/stylesheets/member.css | 3 + app/assets/stylesheets/site-map.css | 4 +- app/controllers/admin/infos_controller.rb | 1 + .../admin/users_new_interface_controller.rb | 1 - app/helpers/application_helper.rb | 10 + app/helpers/attribute_field_helper.rb | 204 +++++++++++------- app/models/user/attribute_field.rb | 39 +++- app/models/user/attribute_value.rb | 14 +- .../attributes/_attribute_field.html.erb | 16 +- .../admin/users_new_interface/_info.html.erb | 2 - .../_temp_profile.html.erb | 2 - .../users_new_interface/_user_role.html.erb | 2 +- .../admin/users_new_interface/show.html.erb | 1 - app/views/layouts/admin.html.erb | 2 +- config/application.rb | 2 + config/list.yml | 35 ++- config/locales/zh_tw.yml | 6 +- 17 files changed, 226 insertions(+), 118 deletions(-) diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css index 1fe9350da..d342e54bc 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 3e5fb5115..711b10e2a 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 21306c6e5..5ffa6a069 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/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 9fe40933c..a2d2265ca 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -47,7 +47,6 @@ class Admin::UsersNewInterfaceController < ApplicationController @staff_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) if att_val.attribute_field.role.key=="staff_data"rescue false } - # binding.pry # @user.attribute_values.each{|att_val| # @teacher_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]}) # } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7be0e2d70..718fbbc5d 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_field_helper.rb b/app/helpers/attribute_field_helper.rb index 9d0999da4..9723241f9 100644 --- a/app/helpers/attribute_field_helper.rb +++ b/app/helpers/attribute_field_helper.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # require ActionView::Helpers::FormTagHelper module AttributeFieldHelper @@ -5,6 +6,7 @@ module AttributeFieldHelper 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 AttributeFieldHelper 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 + + if(add_more and value.is_a?(Array)) + values = value + result << 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 + result << text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}]"), value,markup_options) + end + + result << ('').html_safe + result << ''.html_safe + 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 << "" + 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.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 826627eb0..d7b21414c 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 49014e2ac..efef05c1f 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 5111f0155..58236e36f 100644 --- a/app/views/admin/attributes/_attribute_field.html.erb +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -11,10 +11,18 @@ diff --git a/app/views/admin/users_new_interface/_info.html.erb b/app/views/admin/users_new_interface/_info.html.erb index d821b2098..24b0d9760 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 @@
<% info.attribute_fields.each do |af|%> -
<%= af.block_helper(@user,@form_index)%> -
<% @form_index = @form_index +1 %> <% end %> diff --git a/app/views/admin/users_new_interface/_temp_profile.html.erb b/app/views/admin/users_new_interface/_temp_profile.html.erb index 7791030ee..7112f9948 100644 --- a/app/views/admin/users_new_interface/_temp_profile.html.erb +++ b/app/views/admin/users_new_interface/_temp_profile.html.erb @@ -1,9 +1,7 @@ <%= temp_profile.title %> <% temp_profile.attribute_fields.each do |af|%> -
<%= af.block_helper(@user,@form_index)%> -
<% @form_index = @form_index +1 %> <% end %> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_user_role.html.erb b/app/views/admin/users_new_interface/_user_role.html.erb index 05ef4bb12..fd47de601 100644 --- a/app/views/admin/users_new_interface/_user_role.html.erb +++ b/app/views/admin/users_new_interface/_user_role.html.erb @@ -8,7 +8,7 @@ <% items.each do |item| %> <%= item[:name] %> - <%= item[:value] %> + <%= show_attribute_value(item[:value]) %> <% end -%> diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index 03aff8d48..41fb84a37 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -18,7 +18,6 @@
- <% #binding.pry%> <%= render :partial=> 'plugin_summary'%> <%= render :partial=> 'plugin_summary'%> <%= render :partial=> 'plugin_summary'%> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 3c2df3761..78673abfa 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -31,7 +31,7 @@ <%= yield %>
<%= yield :tertiary %>
- + diff --git a/config/application.rb b/config/application.rb index 9faef5d4a..f5e0a0784 100644 --- a/config/application.rb +++ b/config/application.rb @@ -68,3 +68,5 @@ module Orbit end Orbit_Apps = [] VALID_LOCALES = ["en", "zh_tw"] + + diff --git a/config/list.yml b/config/list.yml index 7e8d75670..7d1c2ad4f 100644 --- a/config/list.yml +++ b/config/list.yml @@ -3,15 +3,34 @@ forbidden_item_names: - panel - appfront +#NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] + markups: - - text_field - - select - - date - - text_area #NC - - radio_button #NC - - checkbox #NC - - date_durnation #NC - - text_field_ext #NC for addr for phone + text_field: + muti_lang_input_supprt: true + ext_support: true + select: + muti_lang_input_supprt: false + ext_support: false + date: + muti_lang_input_supprt: false + ext_support: false + text_area: + muti_lang_input_supprt: true + ext_support: false + radio_button: + muti_lang_input_supprt: false + ext_support: false + checkbox: + muti_lang_input_supprt: false + ext_support: false + date_durnation: + muti_lang_input_supprt: false + ext_support: false + address: + muti_lang_input_supprt: true + ext_support: true + public_r_tags: - ad_banner diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index b56dd33b6..ff07a5f65 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -24,6 +24,9 @@ zh_tw: help: 協助 hide: 隱藏 homepage: 首頁 + langs: + zh_tw: 中文 + en: 英文 login: 登入 logout: 登出 nccu: 政大 @@ -558,6 +561,7 @@ zh_tw: update: "更新%{model}" submit: "儲存%{model}" modal: + save_and_close: "儲存並關閉" close: "關閉" preview: "預覽" sys: @@ -568,4 +572,4 @@ zh_tw: module_page_lang_not_support: "很抱歉,本頁沒有開放中文版本" object_disable: change_to_true: "設為停用" - change_to_false: "重新啓用" + change_to_false: "重新啓用" \ No newline at end of file From 9027562450d9d0e7de4040d7e2e5d5d2dd21bba4 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 12 Oct 2012 18:09:02 +0800 Subject: [PATCH 02/13] new code for attribute fields and values for new member interface --- app/assets/stylesheets/member.css | 3 + app/assets/stylesheets/site-map.css | 4 +- app/controllers/admin/infos_controller.rb | 1 + app/helpers/application_helper.rb | 10 + app/helpers/attribute_fields_helper.rb | 204 +++++++++++------- app/models/user/attribute_field.rb | 39 +++- app/models/user/attribute_value.rb | 14 +- .../attributes/_attribute_field.html.erb | 16 +- .../admin/users_new_interface/_info.html.erb | 2 - .../_temp_profile.html.erb | 2 - .../users_new_interface/_user_role.html.erb | 2 +- .../admin/users_new_interface/show.html.erb | 5 + app/views/layouts/admin.html.erb | 2 +- config/application.rb | 2 + config/list.yml | 35 ++- config/locales/zh_tw.yml | 6 +- 16 files changed, 231 insertions(+), 116 deletions(-) diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css index 1fe9350da..d342e54bc 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 3e5fb5115..711b10e2a 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 21306c6e5..5ffa6a069 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 7be0e2d70..718fbbc5d 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 dfc30ddd7..6dceccc2e 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 + + if(add_more and value.is_a?(Array)) + values = value + result << 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 + result << text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}]"), value,markup_options) + end + + result << ('').html_safe + result << ''.html_safe + 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 << "" + 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.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 826627eb0..d7b21414c 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 49014e2ac..efef05c1f 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 5111f0155..58236e36f 100644 --- a/app/views/admin/attributes/_attribute_field.html.erb +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -11,10 +11,18 @@ diff --git a/app/views/admin/users_new_interface/_info.html.erb b/app/views/admin/users_new_interface/_info.html.erb index d821b2098..24b0d9760 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 @@
<% info.attribute_fields.each do |af|%> -
<%= af.block_helper(@user,@form_index)%> -
<% @form_index = @form_index +1 %> <% end %> diff --git a/app/views/admin/users_new_interface/_temp_profile.html.erb b/app/views/admin/users_new_interface/_temp_profile.html.erb index 7791030ee..7112f9948 100644 --- a/app/views/admin/users_new_interface/_temp_profile.html.erb +++ b/app/views/admin/users_new_interface/_temp_profile.html.erb @@ -1,9 +1,7 @@ <%= temp_profile.title %> <% temp_profile.attribute_fields.each do |af|%> -
<%= af.block_helper(@user,@form_index)%> -
<% @form_index = @form_index +1 %> <% end %> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_user_role.html.erb b/app/views/admin/users_new_interface/_user_role.html.erb index 05ef4bb12..fd47de601 100644 --- a/app/views/admin/users_new_interface/_user_role.html.erb +++ b/app/views/admin/users_new_interface/_user_role.html.erb @@ -8,7 +8,7 @@ <% items.each do |item| %> <%= item[:name] %> - <%= item[:value] %> + <%= show_attribute_value(item[:value]) %> <% end -%> diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index 0299c34fc..085e8a04a 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -20,6 +20,11 @@
<%=render :partial=> @right_partial%> +
+ <%= render :partial=> 'plugin_summary'%> + <%= render :partial=> 'plugin_summary'%> + <%= render :partial=> 'plugin_summary'%> +
diff --git a/config/application.rb b/config/application.rb index d6d9b6b41..ccc4a65ec 100644 --- a/config/application.rb +++ b/config/application.rb @@ -71,3 +71,5 @@ module Orbit end Orbit_Apps = [] VALID_LOCALES = ["en", "zh_tw"] + + diff --git a/config/list.yml b/config/list.yml index 7e8d75670..7d1c2ad4f 100644 --- a/config/list.yml +++ b/config/list.yml @@ -3,15 +3,34 @@ forbidden_item_names: - panel - appfront +#NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] + markups: - - text_field - - select - - date - - text_area #NC - - radio_button #NC - - checkbox #NC - - date_durnation #NC - - text_field_ext #NC for addr for phone + text_field: + muti_lang_input_supprt: true + ext_support: true + select: + muti_lang_input_supprt: false + ext_support: false + date: + muti_lang_input_supprt: false + ext_support: false + text_area: + muti_lang_input_supprt: true + ext_support: false + radio_button: + muti_lang_input_supprt: false + ext_support: false + checkbox: + muti_lang_input_supprt: false + ext_support: false + date_durnation: + muti_lang_input_supprt: false + ext_support: false + address: + muti_lang_input_supprt: true + ext_support: true + public_r_tags: - ad_banner diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index b56dd33b6..ff07a5f65 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -24,6 +24,9 @@ zh_tw: help: 協助 hide: 隱藏 homepage: 首頁 + langs: + zh_tw: 中文 + en: 英文 login: 登入 logout: 登出 nccu: 政大 @@ -558,6 +561,7 @@ zh_tw: update: "更新%{model}" submit: "儲存%{model}" modal: + save_and_close: "儲存並關閉" close: "關閉" preview: "預覽" sys: @@ -568,4 +572,4 @@ zh_tw: module_page_lang_not_support: "很抱歉,本頁沒有開放中文版本" object_disable: change_to_true: "設為停用" - change_to_false: "重新啓用" + change_to_false: "重新啓用" \ No newline at end of file From 7901de7b31852dc54e37cc87363de1a81d0bf91b Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 15 Oct 2012 13:54:29 +0800 Subject: [PATCH 03/13] can add member --- .../admin/users_new_interface_controller.rb | 10 ++++++- app/models/user/attribute_field.rb | 2 +- app/models/user/user.rb | 4 ++- .../admin/users_new_interface/_form.html.erb | 2 +- .../admin/users_new_interface/_role.html.erb | 12 +++++++++ .../admin/users_new_interface/_roles.html.erb | 1 + .../users_new_interface/_user_basic.html.erb | 26 +++++++++++++++++++ .../admin/users_new_interface/new.html.erb | 26 +++++++++++++++++++ .../admin/users_new_interface/show.html.erb | 3 +-- config/locales/devise.zh_tw.yml | 1 + config/locales/zh_tw.yml | 5 ++++ 11 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 app/views/admin/users_new_interface/_role.html.erb create mode 100644 app/views/admin/users_new_interface/_roles.html.erb create mode 100644 app/views/admin/users_new_interface/_user_basic.html.erb create mode 100644 app/views/admin/users_new_interface/new.html.erb diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index d4fb76876..932663ace 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -75,16 +75,24 @@ class Admin::UsersNewInterfaceController < ApplicationController def new @user = User.new + @form_index = 0 get_info_and_roles end def create puts params.to_yaml - @user = User.new(params[:user]) + attribute_valuesp_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' + attribute_values = params[:user].delete(attribute_valuesp_key) + # binding.pry + @user = User.new(params["user"]) + attribute_values.to_hash.each{|key,value| + @user.attribute_values.build(value) + } if @user.save flash[:notice] = t('admin.create_success_user') redirect_to :action => :index else + @form_index = 0 render :action => :new end end diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index d7b21414c..79d0b4d80 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -2,7 +2,7 @@ class AttributeField include Mongoid::Document include Mongoid::Timestamps - include AttributeFieldHelper + include ::AttributeFieldsHelper field :key field :markup diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 59032224a..0de352907 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -10,7 +10,7 @@ class User field :admin, :type => Boolean, :default => true field :active_role field :nccu_ldap_uid - + field :email # field :cache_dept # has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy field :cache_dept,type: Hash @@ -37,6 +37,8 @@ class User before_save :check_status_record scope :remote_account, where(:nccu_id.ne => nil) + validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique") + def set_sub_role(sub_role_id,status_id) self.sub_roles << SubRole.find(sub_role_id) diff --git a/app/views/admin/users_new_interface/_form.html.erb b/app/views/admin/users_new_interface/_form.html.erb index c9816391e..99a8da048 100644 --- a/app/views/admin/users_new_interface/_form.html.erb +++ b/app/views/admin/users_new_interface/_form.html.erb @@ -16,4 +16,4 @@ <%= render :partial=>"infos"%> - +<%= render :partial=>"roles"%> diff --git a/app/views/admin/users_new_interface/_role.html.erb b/app/views/admin/users_new_interface/_role.html.erb new file mode 100644 index 000000000..4f3c461a3 --- /dev/null +++ b/app/views/admin/users_new_interface/_role.html.erb @@ -0,0 +1,12 @@ +
+

<%= role.title %>

+
+ + <% role.attribute_fields.each do |af|%> + <%= af.block_helper(@user,@form_index)%> + <% @form_index = @form_index +1 %> + <% end %> + + +
+
\ No newline at end of file diff --git a/app/views/admin/users_new_interface/_roles.html.erb b/app/views/admin/users_new_interface/_roles.html.erb new file mode 100644 index 000000000..794935e9d --- /dev/null +++ b/app/views/admin/users_new_interface/_roles.html.erb @@ -0,0 +1 @@ +<%=render :partial=>"role",:collection=>Role.all%> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_user_basic.html.erb b/app/views/admin/users_new_interface/_user_basic.html.erb new file mode 100644 index 000000000..3ce900b70 --- /dev/null +++ b/app/views/admin/users_new_interface/_user_basic.html.erb @@ -0,0 +1,26 @@ + <%#= devise_error_messages! %> + +
+

<%=t('admin.user_new_interface.sys_basic_form')%>

+
+
+ <%= f.label t('admin.user_new_interface.email'),:class=>"control-label" %>
+
+ <%= f.email_field :email %> +
+
+
+ <%= f.label t('admin.user_new_interface.password'),:class=>"control-label" %> +
+ <%= f.password_field :password %> +
+
+
+ <%= f.label t('admin.user_new_interface.password_confirmation'),:class=>"control-label" %> +
+
+ <%= f.password_field :password_confirmation %> +
+
+
+
\ No newline at end of file diff --git a/app/views/admin/users_new_interface/new.html.erb b/app/views/admin/users_new_interface/new.html.erb new file mode 100644 index 000000000..68420f499 --- /dev/null +++ b/app/views/admin/users_new_interface/new.html.erb @@ -0,0 +1,26 @@ +<% content_for :page_specific_css do -%> + <%= stylesheet_link_tag "member" %> + <%= stylesheet_link_tag "site-map" %> + <%= stylesheet_link_tag "isotope" %> +<% end -%> +<% content_for :page_specific_javascript do -%> + <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> + <%= javascript_include_tag "inc/modal-preview" %> + <%= javascript_include_tag "lib/contenteditable" %> +<% end -%> + + +<%= content_tag :div,:class=>"user-role site-map" do%> + <%= form_for @user, :url => admin_users_new_interface_index_path, :html => { :multipart => true },:method => :post do |f| %> + + <%= f.error_messages %> + <%= render :partial => 'user_basic', :locals => {:f => f}%> + <%= render :partial => 'form', :locals => { :f => f } %> +
+ <%#= link_back %> + <%#= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> + <%= f.submit%> +
+ <% end -%> + +<% end -%> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index 0299c34fc..e2840e15a 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -34,8 +34,7 @@

<%= @user.email %>

- <%= link_to "TempEdit".html_safe,temp_edit_admin_users_new_interface_path(@user),:class=>"btn btn-small"%> - + <%= link_to "#{t('admin.edit')}".html_safe,edit_admin_users_new_interface_path(@user),:class=>"btn btn-small"%>
diff --git a/config/locales/devise.zh_tw.yml b/config/locales/devise.zh_tw.yml index 4cb8c3170..d825f92e0 100644 --- a/config/locales/devise.zh_tw.yml +++ b/config/locales/devise.zh_tw.yml @@ -30,6 +30,7 @@ zh_tw: signed_up: '您已經成功的登錄,確認信件已送至您的 Email 信箱。' updated: '您已經成功的更新帳號資訊。' destroyed: '再會!您的帳號已被取消。有緣再會。' + email_not_unique: '已被註冊' unlocks: send_instructions: '您將在幾分鐘後收到一封電子郵件,內有將帳號解除鎖定的步驟說明。' unlocked: '您的帳號已被解鎖,現在您已成功登入。' diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index ff07a5f65..3fa4029fd 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -311,6 +311,11 @@ zh_tw: upload_design: 上傳設計 url: URL user: 用戶 + user_new_interface: + sys_basic_form: 系統基本資料表 + password: 密碼 + password_confirmation: 確認密碼 + email: 使用者帳號信箱 user_role: auth: all_member: 所有會員 From 31b583228deb987105187de0fdf05da776ef272b Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 15 Oct 2012 14:07:53 +0800 Subject: [PATCH 04/13] fixed html for add link. form html --- .../admin/users_new_interface/_user_basic.html.erb | 12 +++++++++--- app/views/layouts/_side_bar.html.erb | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/views/admin/users_new_interface/_user_basic.html.erb b/app/views/admin/users_new_interface/_user_basic.html.erb index 3ce900b70..52fd5f9ba 100644 --- a/app/views/admin/users_new_interface/_user_basic.html.erb +++ b/app/views/admin/users_new_interface/_user_basic.html.erb @@ -2,25 +2,31 @@

<%=t('admin.user_new_interface.sys_basic_form')%>

- + +
<%= f.label t('admin.user_new_interface.email'),:class=>"control-label" %>
<%= f.email_field :email %>
+
+ +
<%= f.label t('admin.user_new_interface.password'),:class=>"control-label" %>
<%= f.password_field :password %>
+
+ +
<%= f.label t('admin.user_new_interface.password_confirmation'),:class=>"control-label" %> -
<%= f.password_field :password_confirmation %> -
+
\ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 545c5fbb0..5d771119d 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -41,6 +41,7 @@ <%= 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.add_user') + 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, ), :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') %> From 84929f9b4c7a61deb89417e8d1f7c48d744c94af Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 15 Oct 2012 14:44:48 +0800 Subject: [PATCH 05/13] fix sub role attribute fields run: Role.any_in(:key=>['department_admin','administrator']).destroy_all for deleting old role data to complete this code. --- app/views/admin/users_new_interface/_role.html.erb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/views/admin/users_new_interface/_role.html.erb b/app/views/admin/users_new_interface/_role.html.erb index 4f3c461a3..40f4c9854 100644 --- a/app/views/admin/users_new_interface/_role.html.erb +++ b/app/views/admin/users_new_interface/_role.html.erb @@ -1,12 +1,20 @@

<%= role.title %>

- - <% role.attribute_fields.each do |af|%> + + + <% role.sub_roles.each do |sub_role| %> +
+ <%= sub_role.title %> + + <% sub_role.attribute_fields.each do |af|%> <%= af.block_helper(@user,@form_index)%> <% @form_index = @form_index +1 %> <% end %> +
+ <% end %> +
\ No newline at end of file From e6e547e456f3fc2affa2cf952d50c426063127d7 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 15 Oct 2012 15:15:19 +0800 Subject: [PATCH 06/13] add i18n variables --- config/locales/devise.en.yml | 1 + config/locales/en.yml | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 800f6c7a4..cf578eac1 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -30,6 +30,7 @@ en: signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.' updated: 'You updated your account successfully.' destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' + email_not_unique: 'Your email address has been registed' unlocks: send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' unlocked: 'Your account was successfully unlocked. You are now signed in.' diff --git a/config/locales/en.yml b/config/locales/en.yml index b638ccb11..05715db90 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,6 +27,9 @@ en: help: Help hide: Hide homepage: Homepage + langs: + zh_tw: Traditional Chinese + en: English login: Login logout: Logout no_: "No" @@ -270,6 +273,11 @@ en: upload_design: Upload design url: URL user: User + user_new_interface: + sys_basic_form: User system info + password: Password + password_confirmation: Password Confirmation + email: User account user_role: auth: all_member: All Member From 0babd5f30255437a9e3e6efa1df65e5993e9e398 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 15 Oct 2012 15:30:48 +0800 Subject: [PATCH 07/13] Changes for side_bar --- app/assets/stylesheets/site_editor.css.erb | 2 + app/controllers/admin/plugins_controller.rb | 8 +- app/helpers/admin/plugins_helper.rb | 2 +- app/views/admin/designs/edit.html.erb | 2 +- app/views/admin/designs/index.html.erb | 2 +- app/views/admin/plugins/index.html.erb | 26 +- app/views/admin/sites/_side_bar.html.erb | 4 +- app/views/admin/sites/language.html.erb | 2 +- app/views/admin/sites/mail_setting.html.erb | 2 +- app/views/admin/sites/site_info.html.erb | 2 +- app/views/admin/sites/sitemap.html.erb | 2 +- app/views/admin/sites/system_info.html.erb | 2 +- app/views/admin/sites/ui_theme.html.erb | 2 +- .../users_new_interface/_side_bar.html.erb | 16 ++ .../admin/users_new_interface/edit.html.erb | 4 + .../admin/users_new_interface/index.html.erb | 34 +-- .../index_summary.html.erb | 4 + .../index_thumbnail.html.erb | 4 + .../admin/users_new_interface/new.html.erb | 4 + .../plugin_dashbroad.html.erb | 4 + .../admin/users_new_interface/show.html.erb | 23 +- .../users_new_interface/temp_edit.html.erb | 4 + app/views/layouts/_side_bar.html.erb | 229 ++---------------- app/views/layouts/_side_bar_content.html.erb | 121 +++++++++ app/views/layouts/new_admin.html.erb | 29 +-- config/routes.rb | 1 + .../personal_book/plugin/_profile.html.erb | 7 +- .../personal_diploma/plugin/_profile.html.erb | 7 +- .../plugin/_profile.html.erb | 6 +- .../personal_honor/plugin/_profile.html.erb | 6 +- .../personal_journal/plugin/_profile.html.erb | 8 +- .../personal_lab/plugin/_profile.html.erb | 6 +- .../personal_patent/plugin/_profile.html.erb | 6 +- .../personal_project/plugin/_profile.html.erb | 6 +- .../plugin/_profile.html.erb | 7 +- .../personal_seminar/plugin/_profile.html.erb | 6 +- 36 files changed, 311 insertions(+), 289 deletions(-) create mode 100644 app/views/admin/users_new_interface/_side_bar.html.erb create mode 100644 app/views/layouts/_side_bar_content.html.erb diff --git a/app/assets/stylesheets/site_editor.css.erb b/app/assets/stylesheets/site_editor.css.erb index e36d0b7bb..6506589e6 100644 --- a/app/assets/stylesheets/site_editor.css.erb +++ b/app/assets/stylesheets/site_editor.css.erb @@ -7,6 +7,8 @@ *= require message *= require bootstrap *= require style + *= require font-awesome + *= require orbit-bar *= require bootstrap-orbit *= require scroll_style *= require site_items diff --git a/app/controllers/admin/plugins_controller.rb b/app/controllers/admin/plugins_controller.rb index 15ed630ec..feeff300c 100644 --- a/app/controllers/admin/plugins_controller.rb +++ b/app/controllers/admin/plugins_controller.rb @@ -4,7 +4,13 @@ class Admin::PluginsController < ApplicationController def index - @plugins = ModuleApp.where(has_plugin: true).order_by(:title, :asc) + @plugins = OrbitApp::Module::Registration.all + + if(!params[:show_plugin_profile].nil?) + @right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' + else + @right_partial = "admin/users_new_interface/plugin_summary" + end end diff --git a/app/helpers/admin/plugins_helper.rb b/app/helpers/admin/plugins_helper.rb index 7d0bc5c36..a169e14d0 100644 --- a/app/helpers/admin/plugins_helper.rb +++ b/app/helpers/admin/plugins_helper.rb @@ -13,7 +13,7 @@ module Admin::PluginsHelper @plugins.each do |plugin| ret << "
  • " - ret << (link_to eval("#{plugin.title}") , eval("panel_#{plugin.title}_back_end_#{plugin.object}s_path")) + ret << (link_to eval("#{plugin.title}") , eval("panel_#{plugin.title}_back_end_#{plugin.object}s_path")) rescue nil ret << "
  • " end diff --git a/app/views/admin/designs/edit.html.erb b/app/views/admin/designs/edit.html.erb index 56adc0756..6ed2287e7 100644 --- a/app/views/admin/designs/edit.html.erb +++ b/app/views/admin/designs/edit.html.erb @@ -1,5 +1,5 @@ <% content_for :side_bar do %> - <%= render 'admin/sites/side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :side_bar_content => 'admin/sites/side_bar'} %> <% end %>

    <%= t('admin.editing_design') %>

    diff --git a/app/views/admin/designs/index.html.erb b/app/views/admin/designs/index.html.erb index ab672b09c..e1df6fa15 100644 --- a/app/views/admin/designs/index.html.erb +++ b/app/views/admin/designs/index.html.erb @@ -1,5 +1,5 @@ <% content_for :side_bar do %> - <%= render 'admin/sites/side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :side_bar_content => 'admin/sites/side_bar'} %> <% end %> <%= render 'filter' %> diff --git a/app/views/admin/plugins/index.html.erb b/app/views/admin/plugins/index.html.erb index a4233864b..01bc8bbc3 100644 --- a/app/views/admin/plugins/index.html.erb +++ b/app/views/admin/plugins/index.html.erb @@ -1,2 +1,26 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> -<%= render_plugin_list %> \ No newline at end of file + +
    +
    +
    +
    +
    + +
    +
    + <%= render :partial => @right_partial %> +
    \ No newline at end of file diff --git a/app/views/admin/sites/_side_bar.html.erb b/app/views/admin/sites/_side_bar.html.erb index bf214a0ed..fc5186048 100644 --- a/app/views/admin/sites/_side_bar.html.erb +++ b/app/views/admin/sites/_side_bar.html.erb @@ -1,5 +1,5 @@ <%= content_tag :li, :class => active_for_controllers('sites') do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-cog') + t('admin.site_settings'), admin_site_site_info_path(@site) %> + <%= link_to content_tag(:i, nil, :class => 'icons-cog') + content_tag(:span, t('admin.site_settings')), admin_site_site_info_path(@site) %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('sites')) do -%> <%= content_tag :li, link_to(t('admin.site_info'), admin_site_site_info_path(@site)), :class => active_for_action('sites', 'site_info') %> @@ -13,5 +13,5 @@ <% end -%> <%= content_tag :li, :class => active_for_controllers('designs') do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %> + <%= link_to content_tag(:i, nil, :class => 'icons-window-block') + content_tag(:span, t('admin.design')), admin_designs_path %> <% end -%> diff --git a/app/views/admin/sites/language.html.erb b/app/views/admin/sites/language.html.erb index 2b6265641..b63cd1834 100644 --- a/app/views/admin/sites/language.html.erb +++ b/app/views/admin/sites/language.html.erb @@ -1,5 +1,5 @@ <% content_for :side_bar do %> - <%= render 'side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> <% end %> language.html.erb \ No newline at end of file diff --git a/app/views/admin/sites/mail_setting.html.erb b/app/views/admin/sites/mail_setting.html.erb index 72ec67873..8863f0bb9 100644 --- a/app/views/admin/sites/mail_setting.html.erb +++ b/app/views/admin/sites/mail_setting.html.erb @@ -1,5 +1,5 @@ <% content_for :side_bar do %> - <%= render 'side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> <% end %>
    diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 7a198c041..6829cf743 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -1,7 +1,7 @@ <% # encoding: utf-8 %> <% content_for :side_bar do %> - <%= render 'side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> <% end %>
    diff --git a/app/views/admin/sites/sitemap.html.erb b/app/views/admin/sites/sitemap.html.erb index 453f73f0f..511e68b45 100644 --- a/app/views/admin/sites/sitemap.html.erb +++ b/app/views/admin/sites/sitemap.html.erb @@ -1,5 +1,5 @@ <% content_for :side_bar do %> - <%= render 'side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> <% end %> diff --git a/app/views/admin/sites/system_info.html.erb b/app/views/admin/sites/system_info.html.erb index dc9d45c95..d1b8cba88 100644 --- a/app/views/admin/sites/system_info.html.erb +++ b/app/views/admin/sites/system_info.html.erb @@ -1,5 +1,5 @@ <% content_for :side_bar do %> - <%= render 'side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> <% end %> system_info.html.erb \ No newline at end of file diff --git a/app/views/admin/sites/ui_theme.html.erb b/app/views/admin/sites/ui_theme.html.erb index 540405da8..6584825de 100644 --- a/app/views/admin/sites/ui_theme.html.erb +++ b/app/views/admin/sites/ui_theme.html.erb @@ -1,5 +1,5 @@ <% content_for :side_bar do %> - <%= render 'side_bar' %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.site_settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> <% end %> ui_theme.html.erb \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_side_bar.html.erb b/app/views/admin/users_new_interface/_side_bar.html.erb new file mode 100644 index 000000000..3f82987b0 --- /dev/null +++ b/app/views/admin/users_new_interface/_side_bar.html.erb @@ -0,0 +1,16 @@ +<%= content_tag :li, :class => active_for_controllers('users_new_interface') do -%> + <%= link_to content_tag(:i, nil, :class => 'icons-member')+ content_tag(:span, t('admin.new_admin.user')), admin_users_new_interface_index_path %> + <%= 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') %> + <% end -%> +<% end -%> + +<%= content_tag :li, :class => active_for_controllers('plugins') do -%> + <%= link_to content_tag(:i, nil, :class => 'icons-pie')+ content_tag(:span, t('admin.plugins')), admin_plugins_path %> + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('plugins')) do -%> + <%= content_tag :li, link_to((t('admin.all_plugins') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_plugins_path), :class => active_for_action('users_new_interface', 'index') %> + <% end -%> +<% end -%> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/edit.html.erb b/app/views/admin/users_new_interface/edit.html.erb index 0c295dfe2..d61886df1 100644 --- a/app/views/admin/users_new_interface/edit.html.erb +++ b/app/views/admin/users_new_interface/edit.html.erb @@ -1,3 +1,7 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + <% content_for :page_specific_css do -%> <%= stylesheet_link_tag "member" %> <%= stylesheet_link_tag "site-map" %> diff --git a/app/views/admin/users_new_interface/index.html.erb b/app/views/admin/users_new_interface/index.html.erb index d07a7668b..58f4f0aa4 100644 --- a/app/views/admin/users_new_interface/index.html.erb +++ b/app/views/admin/users_new_interface/index.html.erb @@ -1,20 +1,24 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + <%= render :partial => "js_and_css"%> <%= render :partial => "filter"%> - - - - - - - - - - - - - <%= render :partial => "user_for_listing",:collection=> @users%> - -
    + + + + + + + + + + + + + <%= render :partial => "user_for_listing",:collection=> @users%> + +
    <%= render :partial=> "index_paginator" %> diff --git a/app/views/admin/users_new_interface/index_summary.html.erb b/app/views/admin/users_new_interface/index_summary.html.erb index 993dece65..5de99bb37 100644 --- a/app/views/admin/users_new_interface/index_summary.html.erb +++ b/app/views/admin/users_new_interface/index_summary.html.erb @@ -1,3 +1,7 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + <%= render :partial => "js_and_css"%> <%= render :partial => "filter"%> diff --git a/app/views/admin/users_new_interface/index_thumbnail.html.erb b/app/views/admin/users_new_interface/index_thumbnail.html.erb index 7402f6c30..3f07dbe7f 100644 --- a/app/views/admin/users_new_interface/index_thumbnail.html.erb +++ b/app/views/admin/users_new_interface/index_thumbnail.html.erb @@ -1,3 +1,7 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + <%= render :partial => "js_and_css"%> <%= render :partial => "filter"%> diff --git a/app/views/admin/users_new_interface/new.html.erb b/app/views/admin/users_new_interface/new.html.erb index 68420f499..3e9bfc77f 100644 --- a/app/views/admin/users_new_interface/new.html.erb +++ b/app/views/admin/users_new_interface/new.html.erb @@ -1,3 +1,7 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + <% content_for :page_specific_css do -%> <%= stylesheet_link_tag "member" %> <%= stylesheet_link_tag "site-map" %> diff --git a/app/views/admin/users_new_interface/plugin_dashbroad.html.erb b/app/views/admin/users_new_interface/plugin_dashbroad.html.erb index 7cd090b5a..3dc728197 100644 --- a/app/views/admin/users_new_interface/plugin_dashbroad.html.erb +++ b/app/views/admin/users_new_interface/plugin_dashbroad.html.erb @@ -1,3 +1,7 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> +
    <% #binding.pry%> <%= render :partial=> 'plugin_summary'%> diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index cff591df2..7ac1caeaa 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -1,3 +1,7 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('admin.user'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-member', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + <%= render :partial => "js_and_css"%>
    @@ -6,25 +10,20 @@
    - <%=render :partial=> @right_partial%> -
    - <%= render :partial=> 'plugin_summary'%> - <%= render :partial=> 'plugin_summary'%> - <%= render :partial=> 'plugin_summary'%> -
    + <%=render :partial => @right_partial %>