removed I18n variable

This commit is contained in:
Saurabh Bhatia 2014-06-18 15:50:59 +08:00
parent 0774dc2779
commit 710d1a1106
13 changed files with 29 additions and 63 deletions

View File

@ -149,6 +149,9 @@ class Admin::MembersController < OrbitMemberController
# @custom_field_value = MemberProfileFieldValue.put_field_values(@member, m.last, nil, field_value) # @custom_field_value = MemberProfileFieldValue.put_field_values(@member, m.last, nil, field_value)
# end # end
end end
if user_params
@member.user.update_attributes(user_params)
end
format.html { redirect_to admin_members_path, notice: 'Successfully Updated the User' } format.html { redirect_to admin_members_path, notice: 'Successfully Updated the User' }
@ -286,11 +289,11 @@ class Admin::MembersController < OrbitMemberController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def member_profile_params def member_profile_params
params.require(:member_profile).permit! params.require(:member_profile).permit! rescue nil
end end
def user_params def user_params
params.require(:user).permit! params.require(:user).permit! rescue nil
end end

View File

@ -212,7 +212,7 @@ protected
link_entry_ary = ["##{get_pairing_tab_class({})}","_#{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 link_entry = link_entry_ary.join
link_to(I18nVariable.from_locale(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale.to_s ? "active" : nil)}",:for=>key) link_to("#{t(locale).to_s}",link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale.to_s ? "active" : nil)}",:for=>key)
end # of VALID_LOCALES.collect for tabs end # of VALID_LOCALES.collect for tabs
buff2 << link_to((content_tag :i,'',:class=>'icon-edit'),"##{get_pairing_tab_class({})}_m_window", :role=>"button",:class=>'btn',:data=>{:toggle=>"modal"}) if self.markup == 'address' buff2 << link_to((content_tag :i,'',:class=>'icon-edit'),"##{get_pairing_tab_class({})}_m_window", :role=>"button",:class=>'btn',:data=>{:toggle=>"modal"}) if self.markup == 'address'
@ -261,7 +261,7 @@ protected
link_entry_ary = ["##{get_pairing_tab_class({})}","_#{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 link_entry = link_entry_ary.join
link_to(I18nVariable.from_locale(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale.to_s ? "active" : nil)}",:for=>key) link_to("#{t(locale).to_s}",link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale.to_s ? "active" : nil)}",:for=>key)
end # of VALID_LOCALES.collect for tabs end # of VALID_LOCALES.collect for tabs
buff2 << link_to((content_tag :i,'',:class=>'icon-edit'),"#address-field", :role=>"button",:class=>'btn',:data=>{:toggle=>"modal"}) if self.markup == 'address' buff2 << link_to((content_tag :i,'',:class=>'icon-edit'),"#address-field", :role=>"button",:class=>'btn',:data=>{:toggle=>"modal"}) if self.markup == 'address'
@ -275,16 +275,6 @@ protected
tmp1 << tmp2 tmp1 << tmp2
end 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 = link_entry_ary.join
# content_tag(:li,link_to(I18nVariable.from_locale(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
# end # of content ul
end end
end end

View File

@ -1,24 +0,0 @@
class I18nVariable
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :document_class, type: String
field :parent_id, type: BSON::ObjectId
belongs_to :language_value, polymorphic: true
def method_missing(*field)
if field.size > 1
self.write_attribute(field[0].to_s.delete('=').to_sym, field[1])
else
self[field[0]]
end
end
def self.from_locale(locale)
I18nVariable.find_by(key: locale)[I18n.locale]
end
end

View File

@ -31,7 +31,7 @@ console.log(<%= @fname%>);
<% active = (locale == @site_in_use_locales.first ? "active" : "") %> <% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<div class="tab-pane fade <%= active %> in" id="${roleType+'_text_language_<%= locale %>_'+appendIndex}"> <div class="tab-pane fade <%= active %> in" id="${roleType+'_text_language_<%= locale %>_'+appendIndex}">
<input type="text" name="${'member_profile[<%= @fname %>]['+nameNumber+'][value][][<%= locale %>]'}" placeholder="<%= I18nVariable.from_locale(locale) %>" value=""> <input type="text" name="${'member_profile[<%= @fname %>]['+nameNumber+'][value][][<%= locale %>]'}" placeholder="<%= t(locale).to_s %>" value="">
</div> </div>
<% end %> <% end %>
@ -40,7 +40,7 @@ console.log(<%= @fname%>);
<div class="btn-group" data-toggle="buttons-radio"> <div class="btn-group" data-toggle="buttons-radio">
<% @site_valid_locales.collect do |locale| %> <% @site_valid_locales.collect do |locale| %>
<% active = (locale == @site_in_use_locales.first ? "active" : "") %> <% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<a class="btn <%= active %>" href="${'#'+roleType+'_text_language_<%= locale %>_'+appendIndex}" data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a> <a class="btn <%= active %>" href="${'#'+roleType+'_text_language_<%= locale %>_'+appendIndex}" data-toggle="tab"><%= t(locale).to_s %></a>
<% end %> <% end %>
<a href="#" class="btn remove-input"><i class="icon-trash"></i></a> <a href="#" class="btn remove-input"><i class="icon-trash"></i></a>
</div> </div>

View File

@ -78,7 +78,7 @@
</div> </div>
<div class="btn-group" data-toggle="buttons-radio"> <div class="btn-group" data-toggle="buttons-radio">
<% current_site.in_use_locales.each_with_index do |locale, i| %> <% current_site.in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#last_name_<%= locale %>" data-toggle="tab"><%= t(locale) %></a> <a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#last_name_<%= locale %>" data-toggle="tab"><%= t(locale).to_s %></a>
<% end %> <% end %>
<a href="#" class="btn remove-input"><i class="icon-trash"></i></a> <a href="#" class="btn remove-input"><i class="icon-trash"></i></a>
</div> </div>
@ -145,7 +145,7 @@
<ul class="nav nav-pills language-nav"> <ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %> <% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>"> <li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a> <a data-toggle="tab" href=".<%= locale %>"><%= t(locale).to_s %></a>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@ -13,13 +13,12 @@
<%= @member.name %> <%= @member.name %>
</div> </div>
</div> </div>
<%= form_for @user, :html => { :class=>"form-horizontal main-forms", :id=>"user-forms"} do |m| %> <%= form_for @user, html: { class: "form-horizontal main-forms", id: "user-forms"} do |m| %>
<!-- Chec Admin --> <!-- Chec Admin -->
<div class="control-group"> <div class="control-group">
<label class="control-label muted" for="">Administrator</label> <label class="control-label muted" for="">Administrator</label>
<div class="controls"> <div class="controls">
<label class="checkbox inline"> <label class="checkbox inline">
<%= m.check_box :workgroup_id,{},@workgroup.id%>
<%= t("admin") %> <%= t("admin") %>
</label> </label>
</div> </div>

View File

@ -13,22 +13,20 @@
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %> <%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload.js" %> <%= javascript_include_tag "lib/bootstrap-fileupload.js" %>
<%= javascript_include_tag "lib/member/role-forms.js" %> <%= javascript_include_tag "lib/member/role-forms.js" %>
<%= javascript_include_tag "lib/member/textarea-lang-btn.js" %>
<% end -%> <% end -%>
<%= form_for @member, :url => admin_member_path(@member), :html => { :multipart => true , :class=>"form-horizontal main-forms", :id=>"user-forms"} do |f| %> <%= form_for @member, url: admin_member_path(@member), html: { multipart: true , class: "form-horizontal main-forms", id: "user-forms"} do |f| %>
<fieldset> <fieldset>
<div id="basic-area" class="input-area"> <div id="basic-area" class="input-area">
<%= render :partial => 'user_basic_privilege', :locals => {:f => f}%> <%= render :partial => 'user_basic_privilege', :locals => {:f => f}%>
</div> </div>
<div class="form-actions"> <div class="form-actions">
<%= link_back('btn') %> <%= link_back('btn') %>
<%= hidden_field_tag 'edit_type', 'edit_privilege' %> <%= hidden_field_tag 'edit_type', 'edit_privilege' %>
<%= link_to t(:update_), "#", :class=>"btn btn-primary returnDecide", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> <%= f.submit t(:update_), class: 'btn btn-primary' %>
</div> </div>
</fieldset> </fieldset>

View File

@ -17,7 +17,7 @@
<% @site_in_use_locales.each_with_index do |locale, i| %> <% @site_in_use_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? "class=active" : '' %>> <li <%= ( i == 0 ) ? "class=active" : '' %>>
<a data-toggle="tab" href="#<%= locale %>"> <a data-toggle="tab" href="#<%= locale %>">
<%= I18nVariable.from_locale(locale) %> <%= t(locale).to_s %>
</a> </a>
</li> </li>
<% end %> <% end %>

View File

@ -24,14 +24,14 @@
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% active = (locale == @site_in_use_locales.first ? "active" : "") %> <% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<div class="tab-pane <%= active %> fade in" id="${_title_translations[0]+'_<%= locale%>'}"> <div class="tab-pane <%= active %> fade in" id="${_title_translations[0]+'_<%= locale%>'}">
<input type="text" data-type="lang_<%= locale%>" name="${_title_translations[1]+'[<%= locale%>]'}" placeholder="<%= I18nVariable.from_locale(locale) %>"> <input type="text" data-type="lang_<%= locale%>" name="${_title_translations[1]+'[<%= locale%>]'}" placeholder="<%= t(locale).to_s %>">
</div> </div>
<% end %> <% end %>
</div> </div>
<div class="btn-group" data-toggle="buttons-radio"> <div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% active = (locale == @site_in_use_locales.first ? "active" : "") %> <% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<a class="btn <%= active %>" href="${'#'+_title_translations[0]+'_<%= locale%>'}" data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a> <a class="btn <%= active %>" href="${'#'+_title_translations[0]+'_<%= locale%>'}" data-toggle="tab"><%= t(locale).to_s %></a>
<% end %> <% end %>
</div> </div>
</div> </div>
@ -94,7 +94,7 @@
<% active = (locale == @site_in_use_locales.first ? "active" : "") %> <% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<div class="tab-pane <%= active %> fade in" id="${_placeholder[0]+'_<%= locale %>'}"> <div class="tab-pane <%= active %> fade in" id="${_placeholder[0]+'_<%= locale %>'}">
<input type="text" data-type="lang_<%= locale %>" placeholder="<%= I18nVariable.from_locale(locale) %>" name="${_placeholder[1]+'[<%= locale %>]'}"> <input type="text" data-type="lang_<%= locale %>" placeholder="<%= t(locale).to_s %>" name="${_placeholder[1]+'[<%= locale %>]'}">
</div> </div>
<% end %> <% end %>
@ -105,7 +105,7 @@
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% active = (locale == @site_in_use_locales.first ? "active" : "") %> <% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<a class="btn <%= active %>" href="${'#'+_placeholder[0]+'_<%= locale %>'}" data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a> <a class="btn <%= active %>" href="${'#'+_placeholder[0]+'_<%= locale %>'}" data-toggle="tab"><%= t(locale).to_s %></a>
<% end %> <% end %>
</div> </div>
@ -162,7 +162,7 @@
"${_placeholder[0]+'_<%= locale %>'}" "${_placeholder[0]+'_<%= locale %>'}"
{{/if}} {{/if}}
> >
<input type="text" data-type="lang_<%= locale %>" placeholder="<%= I18nVariable.from_locale(locale) %>" name= <input type="text" data-type="lang_<%= locale %>" placeholder="<%= t(locale).to_s %>" name=
{{if templateType == 'typeB'}} {{if templateType == 'typeB'}}
"${_initial[1]+'[<%= locale %>]' }" "${_initial[1]+'[<%= locale %>]' }"
{{else}} {{else}}
@ -185,7 +185,7 @@
{{else}} {{else}}
"${'#'+_placeholder[0]+'_<%= locale %>'}" "${'#'+_placeholder[0]+'_<%= locale %>'}"
{{/if}} {{/if}}
data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a> data-toggle="tab"><%= t(locale).to_s %></a>
<% end %> <% end %>
@ -203,7 +203,7 @@
<%= content_tag :div,:class=>"input-append" do%> <%= content_tag :div,:class=>"input-append" do%>
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% last = (locale == @site_in_use_locales.last ? true : false) %> <% last = (locale == @site_in_use_locales.last ? true : false) %>
<input type="text" data-type="${_option_list[2]+'_<%= locale %>' }" id="${_option_list[0]+'_<%= locale %>'}" name="${_option_list[1]+'[<%= locale %>]'}" class="input-medium" placeholder="<%= I18nVariable.from_locale(locale) %>"> <input type="text" data-type="${_option_list[2]+'_<%= locale %>' }" id="${_option_list[0]+'_<%= locale %>'}" name="${_option_list[1]+'[<%= locale %>]'}" class="input-medium" placeholder="<%= t(locale).to_s %>">
<% if last %> <% if last %>
<a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a> <a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a>
<% end %> <% end %>
@ -259,7 +259,7 @@
<%= content_tag :div,:class=>"input-append" do%> <%= content_tag :div,:class=>"input-append" do%>
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% last = (locale == @site_in_use_locales.last ? true : false) %> <% last = (locale == @site_in_use_locales.last ? true : false) %>
<input type="text" data-type="${_option_list[2]+'_<%= locale %>' }" id="${_option_list[0]+'_<%= locale %>'}" name="${_option_list[1]+'[<%= locale %>]'}" class="input-medium" placeholder="<%= I18nVariable.from_locale(locale) %>"> <input type="text" data-type="${_option_list[2]+'_<%= locale %>' }" id="${_option_list[0]+'_<%= locale %>'}" name="${_option_list[1]+'[<%= locale %>]'}" class="input-medium" placeholder="<%= t(locale).to_s %>">
<% if last %> <% if last %>
<a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a> <a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a>
<% end %> <% end %>

View File

@ -10,7 +10,7 @@
<% site.valid_locales.each do |locale|%> <% site.valid_locales.each do |locale|%>
<% active = (locale == I18n.locale.to_s ? ["active"] : [] ) %> <% active = (locale == I18n.locale.to_s ? ["active"] : [] ) %>
<%= content_tag :li,:class=>active,:for=>locale do%> <%= content_tag :li,:class=>active,:for=>locale do%>
<%= link_to I18nVariable.from_locale(locale),".#{btn_class}.address_modal.#{locale}",:data=>{:toggle=>"tab"}%> <%= link_to t(locale).to_s,".#{btn_class}.address_modal.#{locale}",:data=>{:toggle=>"tab"}%>
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>

View File

@ -11,7 +11,7 @@
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% last = (locale == @site_in_use_locales.last ? true : false) %> <% last = (locale == @site_in_use_locales.last ? true : false) %>
<% p_value = value[locale.to_s] rescue nil%> <% p_value = value[locale.to_s] rescue nil%>
<%= text_field("#{field_name}[0]", locale,:placeholder=>I18nVariable.from_locale(locale),:class=>"input-medium",:data=>{:type=>"option_lang_0_#{locale}"}) %> <%= text_field("#{field_name}[0]", locale,:placeholder=>t(locale).to_s,:class=>"input-medium",:data=>{:type=>"option_lang_0_#{locale}"}) %>
<% if last %> <% if last %>
<a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a> <a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a>
<% end %> <% end %>
@ -24,7 +24,7 @@
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% last = (locale == @site_in_use_locales.last ? true : false) %> <% last = (locale == @site_in_use_locales.last ? true : false) %>
<% p_value = value[locale.to_s] rescue nil%> <% p_value = value[locale.to_s] rescue nil%>
<%= text_field("#{field_name}[#{index}]", locale,:value=>p_value,:placeholder=>I18nVariable.from_locale(locale),:class=>"input-medium", :data=>{:type=>"option_lang_#{index}_#{locale}"}) %> <%= text_field("#{field_name}[#{index}]", locale,:value=>p_value,:placeholder=>t(locale).to_s,:class=>"input-medium", :data=>{:type=>"option_lang_#{index}_#{locale}"}) %>
<% if last %> <% if last %>
<a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a> <a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a>
<% end %> <% end %>

View File

@ -8,7 +8,7 @@
<% active = (locale == @site_in_use_locales.first ? "active in" : "'") %> <% active = (locale == @site_in_use_locales.first ? "active in" : "'") %>
<%= content_tag :div,:class=>"tab-pane fade #{active}",:id=>"#{name_to_id(field_name)}_#{locale}" do%> <%= content_tag :div,:class=>"tab-pane fade #{active}",:id=>"#{name_to_id(field_name)}_#{locale}" do%>
<% locale_value = values[locale.to_s] rescue nil%> <% locale_value = values[locale.to_s] rescue nil%>
<%= text_field(field_name, locale,:value=>locale_value,:placeholder=>I18nVariable.from_locale(locale),:data=>{:type=>"lang_#{locale}"}) %> <%= text_field(field_name, locale,:value=>locale_value,:placeholder=> "#{t(locale).to_s}",:data=>{:type=>"lang_#{locale}"}) %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
@ -16,7 +16,7 @@
<div class="btn-group" data-toggle="buttons-radio"> <div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<% active = (locale == @site_in_use_locales.first ? "active" : "") %> <% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<%= link_to I18nVariable.from_locale(locale),"##{name_to_id(field_name)}_#{locale}",:class=>"btn #{active}",:data=>{:toggle=>"tab"}%> <%= link_to t(locale).to_s,"##{name_to_id(field_name)}_#{locale}",:class=>"btn #{active}",:data=>{:toggle=>"tab"}%>
<% end %> <% end %>
</div> </div>

View File

@ -6,4 +6,4 @@ gem 'links', git: 'git@gitlab.tp.rulingcom.com:saurabh/links.git'
gem 'page_content', git: 'git@gitlab.tp.rulingcom.com:saurabh/pagecontent.git' gem 'page_content', git: 'git@gitlab.tp.rulingcom.com:saurabh/pagecontent.git'
gem 'faq', git: 'git@gitlab.tp.rulingcom.com:saurabh/faq.git' gem 'faq', git: 'git@gitlab.tp.rulingcom.com:saurabh/faq.git'
#Personal Plugins #Personal Plugins
gem 'personal_journal', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-journal.git' gem 'personal_journal', path: '/Users/saurabhbhatia/personal_journal'