Fix member module form issues

This commit is contained in:
manson 2014-07-16 19:13:54 +08:00
parent 6bb2708b82
commit 0dccaacbaf
7 changed files with 20 additions and 16 deletions

View File

@ -34,6 +34,9 @@ gem "mini_magick", github: 'minimagick/minimagick'
gem 'carrierwave'
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
# Form helper
gem 'dynamic_form'
gem 'kaminari'
gem "impressionist"
gem "chartkick"

View File

@ -111,8 +111,9 @@ class Admin::MembersController < OrbitMemberController
def create
@member = MemberProfile.new(member_profile_params)
@user = User.new(user_params) rescue nil
if @member.save
@user.member_profile_id = @member.id
@user.member_profile = @member
if @member.save and @user.save
if !params[:member_profile_field_values].nil?
params[:member_profile_field_values].each_with_index do |m,i|
@custom_field_value = @member.member_profile_field_values.build(value: m.second["value"], member_profile_field_id: m.second["member_profile_field_id"])
@ -127,10 +128,9 @@ class Admin::MembersController < OrbitMemberController
end
end
@user.save
redirect_to admin_members_path
else
redirect_to new_admin_member_path
render 'new'
end
end

View File

@ -179,7 +179,7 @@ protected
def valid_locales
site = Site.first
site.valid_locales
[I18n.locale]+(site.valid_locales-[I18n.locale])
end
def lang_panel_tabbable_wrapper(add_more_params,&block)
@ -202,7 +202,7 @@ protected
end
div_class = div_class_ary.join(" ")
div_class << (key == I18n.locale.to_s ? " active in" : '')
div_class << (key == I18n.locale ? " active in" : '')
content_tag(:div,yield(key,value), :id=>div_id,:class=>div_class)
end# of VALID_LOCALES.collect for tabed input
@ -213,7 +213,7 @@ protected
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
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale.to_s ? "active" : nil)}",:for=>key)
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale ? "active" : nil)}",:for=>key)
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'
@ -248,7 +248,7 @@ protected
end
div_class = div_class_ary.join(" ")
div_class << (key == I18n.locale.to_s ? " active in" : '')
div_class << (key == I18n.locale ? " active in" : '')
content_tag(:div,yield(key,value), :id=>div_id,:class=>div_class)
end# of VALID_LOCALES.collect for tabed input
@ -262,7 +262,7 @@ protected
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
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale.to_s ? "active" : nil)}",:for=>key)
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale ? "active" : nil)}",:for=>key)
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'

View File

@ -42,7 +42,7 @@
<div class="add-target">
<div class="input-append">
<div class="tab-content">
<% current_site.in_use_locales.each_with_index do |locale, i| %>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="first_name_<%= locale %>">
<%= f.fields_for :first_name_translations do |f| %>
<%= f.text_field locale, :value => (@member.first_name_translations[locale] rescue nil), :placeholder=>"#{t("users.first_name")}" %>
@ -51,7 +51,7 @@
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% current_site.in_use_locales.each_with_index do |locale, i| %>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#first_name_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
<a href="#" class="btn remove-input"><i class="icon-trash"></i></a>
@ -68,7 +68,7 @@
<div class="add-target">
<div class="input-append">
<div class="tab-content">
<% current_site.in_use_locales.each_with_index do |locale, i| %>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="last_name_<%= locale %>">
<%= f.fields_for :last_name_translations do |f| %>
<%= f.text_field locale, :value => (@member.last_name_translations[locale] rescue nil), :placeholder=>"#{t("users.last_name")}" %>
@ -77,7 +77,7 @@
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% current_site.in_use_locales.each_with_index do |locale, i| %>
<% @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).to_s %></a>
<% end %>
<a href="#" class="btn remove-input"><i class="icon-trash"></i></a>

View File

@ -25,7 +25,7 @@
<div class="sub-nav-block-list">
<div class="sub-nav-block" data-icons="&#xe00d;">
<h4><%= t(:member_) %></h4>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('members', 'roles','member_infos')) do -%>
<%= content_tag :ul, :class => ("nav nav-list ") do -%>
<%= content_tag :li, link_to((content_tag(:span, t(:all_member))), admin_members_path), :class => active_for_action('members', 'index') %>
<%= content_tag :li, link_to((content_tag(:span, t(:add_member))), new_admin_member_path), :class => active_for_action('members', 'new') if (current_user.is_admin? rescue nil) %>
<%= content_tag :li, link_to((content_tag(:span, t(:member_role))),admin_roles_path ), :class => active_for_action('roles', 'index') if (current_user.is_admin? rescue nil) %>
@ -35,7 +35,7 @@
</div>
<div class="sub-nav-block" data-icons="&#xe070;">
<h4><%= t(:academic_info) %></h4>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('members', 'roles','member_infos')) do -%>
<%= content_tag :ul, :class => ("nav nav-list ") do -%>
<%= content_tag :li, link_to((content_tag(:span, t(:list_))), admin_personal_plugins_path), :class => active_for_action('members', 'index') %>
<% end -%>
</div>

View File

@ -1,5 +1,5 @@
<%= form_for @user, :html => { :class=>"form-horizontal main-forms", :id=>"user-forms"} do |f| %>
<%= f.error_messages %>
<div class="attributes">
<div class="attributes-header clearfix">
<h4><%=t(:sys_basic_id_form)%></h4>

View File

@ -22,6 +22,7 @@
<%= form_for @member, :url => admin_member_path(@member), :html => { :multipart => true , :class=>"form-horizontal main-forms", :id=>"user-forms"} do |f| %>
<%= f.error_messages %>
<fieldset>
<div id="basic-area" class="input-area">