user new interface 70%

This commit is contained in:
Matthew K. Fu JuYuan 2012-10-08 16:58:33 +08:00 committed by chris
parent 1aacf5e2ce
commit 9f825de288
20 changed files with 589 additions and 52 deletions

View File

@ -131,8 +131,14 @@
margin: 0 0 3px; margin: 0 0 3px;
} }
.user-data { .user-data {
padding: 70px 20px 0; padding: 60px 0 0;
margin: 20px 0 0 360px; margin: 0 0 0 360px;
}
.user-data .form-fixed {
}
.user-data .subnav {
top: 87px;
z-index: 1;
} }
.user-data #module-nav { .user-data #module-nav {
margin-left: -20px; margin-left: -20px;
@ -141,13 +147,16 @@
background-color: #FFFFFF; background-color: #FFFFFF;
top: 31px; top: 31px;
padding: 10px 20px 0; padding: 10px 20px 0;
-webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, .16); -webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, .16);
-moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, .16); -moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, .16);
box-shadow: 0px 5px 10px rgba(0, 0, 0, .16); box-shadow: 0px 0px 10px rgba(0, 0, 0, .16);
} }
.user-data #module-nav ul { .user-data #module-nav ul {
margin-bottom: 10px; margin-bottom: 10px;
} }
.member-plugin-list {
margin-bottom: 30px;
}
.member-abstract, .member-large { .member-abstract, .member-large {
padding: 15px; padding: 15px;
} }
@ -273,3 +282,31 @@
.nav-tabs li a { .nav-tabs li a {
padding-right: 32px; padding-right: 32px;
} }
.user-role {
padding: 0 20px 0 150px !important;
margin: 20px 0 0;
}
.user-role .user-info {
top: 23px;
margin-left: -135px;
width: 100px;
border-right: none;
box-shadow: none;
}
.user-role .map-block h4 .gender {
top: -1px;
bottom: auto;
left: -1px;
right: auto;
border-radius: 4px 0 0 0;
}
.user-role .teacher h4 .gender {
border-color: #186AB6 transparent transparent #186AB6;
}
.user-role .student h4 .gender {
border-color: #F38C08 transparent transparent #F38C08;
}
.user-role .staff h4 .gender {
border-color: #139E2F transparent transparent #139E2F;
}

View File

@ -0,0 +1,116 @@
.site-map {
padding: 15px;
}
.site-map .map-block {
min-width: 250px;
min-height: 20px;
border: 1px solid #dedede;
background-color: #E6E6E6;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
margin-bottom: 10px;
}
.site-map .map-block ul {
margin: 0px;
list-style: none;
width: 220px \9;
}
.site-map .map-block li {
background-color: #F7F7F7;
padding: 5px 15px;
border-top: 1px solid #FFF;
border-bottom: 1px solid #dedede;
display: table;
width: 100%;
}
.site-map .map-block li span {
width: 170px;
display: block;
}
.site-map .map-block li:last-child {
border-radius: 0 0 4px 4px;
border-bottom: none;
}
.site-map .map-block li:hover a {;
text-decoration: none;
}
.site-map .map-block li.disabled {
color: #C9C9C9;
}
.site-map .map-block li.disabled .onoff {
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(0,0,0,.2) inset;
background-color: #9C9C9C;
color: #CACACA;
}
.site-map .map-block h4 {
line-height: 18px;
min-height: 20px;
margin: 0;
padding: 5px 15px;
border-radius: 4px 4px 0 0;
box-shadow: 0px 1px 2px #A8A8A8;
position: relative;
background-image: -moz-linear-gradient(top, #FCFCFC, #DFDFDF);
background-image: -ms-linear-gradient(top, #FCFCFC, #DFDFDF);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#FCFCFC), to(#DFDFDF));
background-image: -webkit-linear-gradient(top, #FCFCFC, #DFDFDF);
background-image: -o-linear-gradient(top, #FCFCFC, #DFDFDF);
background-image: linear-gradient(top, #FCFCFC, #DFDFDF);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FCFCFC', endColorstr='#DFDFDF', GradientType=0);
}
.site-map .map-block h4 span {
width: 170px;
display: block;
}
.site-map .map-block h4 .onoff {
}
.site-map .disabled h4 {
color: #CACACA;
}
.site-map .disabled h4 .onoff {
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(0,0,0,.2) inset;
background-color: #9C9C9C;
color: #CACACA;
}
.onoff {
display: block;
background-color: #5EB92B;
font-size: 9px;
padding: 0px 10px;
border-radius: 8px;
line-height: 16px;
height: 15px;
color: #FFF;
width: 38px;
border: none;
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(13, 75, 23, 0.5) inset;
margin-top: 2px;
}
/* for mamber role */
.user-role .form-horizontal {
padding: 20px 10px 10px;
background-color: #FFF;
margin-bottom: 0;
border-radius: 0 0 4px 4px;
}
.user-role .form-horizontal .control-label {
width: 100px;
}
.user-role .form-horizontal .controls {
margin-left: 120px;
}
.user-role .form-horizontal .controls>.input-append {
margin-bottom: 10px;
}
.user-role .map-block {
min-width: 440px;
}
.user-role .map-block legend {
font-size: 18px;
line-height: 25px;
}

View File

@ -34,19 +34,19 @@ class Admin::UsersNewInterfaceController < ApplicationController
@staff_data = [] @staff_data = []
@user.attribute_values.each{|att_val| @user.attribute_values.each{|att_val|
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]}) if att_val.attribute_field.attribute.key=="profile" rescue false @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale)}) if att_val.attribute_field.attribute.key=="profile" rescue false
} }
@user.attribute_values.each{|att_val| @user.attribute_values.each{|att_val|
@teacher_data.push({:name => att_val.attribute_field.title,:value => eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="teacher"rescue false @teacher_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) if att_val.attribute_field.role.key=="teacher"rescue false
} }
@user.attribute_values.each{|att_val| @user.attribute_values.each{|att_val|
@student_data.push({:name => att_val.attribute_field.title,:value =>eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="student"rescue false @student_data.push({:name => att_val.attribute_field.title,:value => att_val.get_value_by_locale(I18n.locale) }) if att_val.attribute_field.role.key=="student"rescue false
} }
@user.attribute_values.each{|att_val| @user.attribute_values.each{|att_val|
@staff_data.push({:name => att_val.attribute_field.title,:value =>eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="staff_data"rescue false @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
} }
if(!params[:show_plugin_profile].nil?) if(!params[:show_plugin_profile].nil?)
@ -89,28 +89,37 @@ class Admin::UsersNewInterfaceController < ApplicationController
end end
end end
def temp_edit
@user = User.find(params[:id])
@form_index = 0
get_info_and_roles
end
def edit def edit
@user = User.find(params[:id]) @user = User.find(params[:id])
@form_index = 0
get_info_and_roles get_info_and_roles
end end
def update def update
@user = User.find(params[:id]) @user = User.find(params[:id])
@user.update_attributes(params[:user])
@user.save
redirect_to :action => :show
# # Update changes to the avatar
# @user.remove_avatar! if params[:file]
# @user.avatar = params[:file] if params[:file]
# Update changes to the avatar # if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b
@user.remove_avatar! if params[:file] # flash.now[:error] = t('admin.cant_revoke_self_admin')
@user.avatar = params[:file] if params[:file] # end
# if !flash[:error] && @user.update_attributes(params[:user])
if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b # flash[:notice] = t('admin.update_success_user')
flash.now[:error] = t('admin.cant_revoke_self_admin') # redirect_to :action => :index
end # else
if !flash[:error] && @user.update_attributes(params[:user]) # get_info_and_roles
flash[:notice] = t('admin.update_success_user') # render :action => :edit
redirect_to :action => :index # end
else
get_info_and_roles
render :action => :edit
end
end end
def destroy def destroy

View File

@ -0,0 +1,151 @@
# require ActionView::Helpers::FormTagHelper
module AttributeFieldHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormOptionsHelper
include ActionView::Helpers::DateHelper
include ActionView::Helpers::TagHelper
def block_helper(user,index)
@index = index
@user = user
@attribute_value = @user.get_value_from_field_id(id)
@new_attribute = @attribute_value.nil?
@attribute_value = @attribute_value || @user.attribute_values.build(attribute_field_id: id)
@prefiled_value = @attribute_value.get_values
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
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")}
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
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, {})}
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
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
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, {})}
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
protected
def controls_wrapper(&block)
result = "<div class='controls'>"
result << yield
result << "</div>"
result.html_safe
end
def control_group_wrapper(&block)
result = "<div class='control-group'>"
result << yield
result << "</div>"
result.html_safe
end
def end_block
if @new_attribute
hidden_field_tag(get_field_name_base+"[attribute_field_id]",id)
else
hidden_field_tag(get_field_name_base+"[id]",@attribute_value.id)
end
end
def get_field_name_base
# "user[#{self.attribute._type.downcase.pluralize}][#{self.attribute._id.to_s}][attribute_values][#{attribute_value.id}]"
if @new_attribute
"user[new_attribute_values][#{@index}]"
else
"user[attribute_values][#{@index}]"
end
end
def label
label_tag(key,title,:class=>"control-label")
end
end

View File

@ -2,9 +2,11 @@ class AttributeField
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include AttributeFieldHelper
field :key field :key
field :markup #[select,text_field,email,date,addr] field :markup #[select,text_field,email,date,addr]
field :markup_value ,:type => Hash
field :locale, :type => Boolean, :default => true field :locale, :type => Boolean, :default => true
field :list_options, :type => Array field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false field :built_in, :type => Boolean, :default => false
@ -46,7 +48,7 @@ class AttributeField
end end
def title=(var) def title=(var)
binding.pry # binding.pry
if locale if locale
self.locale_title = var self.locale_title = var
else else

View File

@ -2,14 +2,52 @@ class AttributeValue
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
field :key field :key
belongs_to :attribute_field belongs_to :attribute_field
belongs_to :user belongs_to :user
def method_missing(field) before_save :check_key
self[field]
NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"]
def check_key
self.key = attribute_field.key
end
def method_missing(*field)
if field.size < 1
self[field[0]]
else
self[(field[0].to_s.delete "=")] = field[1]
end
end end
def get_value_by_locale(locale)
case self.attribute_field.markup
when "text_field"
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 "date"
Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i)
when "addr"
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)
return Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}]
else
return self[:value]
end
end
end end

View File

@ -43,28 +43,33 @@ class User
self.status_record.store(sub_role_id,status_id) self.status_record.store(sub_role_id,status_id)
end end
def get_status(*params) # def get_status(*params)
param = params[0] # param = params[0]
case param.class.to_s # case param.class.to_s
when 'String' # when 'String'
sr = ::SubRole.find sub_role_id # sr = ::SubRole.find sub_role_id
when 'Hash' # when 'Hash'
sr = ::SubRole.first({conditions:{key: param[:key]}}) # sr = ::SubRole.first({conditions:{key: param[:key]}})
end # end
if self.sub_roles.include?(sr) # if self.sub_roles.include?(sr)
return ::Status.find(status_record.fetch(sr.id.to_s)) # return ::Status.find(status_record.fetch(sr.id.to_s))
else # else
nil # nil
# end
# end
def new_attribute_values=(fields)
fields.each do |key,field|
self.attribute_values.build(field)
end end
end end
def self.find_by_status_and_sub_role_key(sub_role_key,status_key) def self.find_by_status_and_sub_role_key(sub_role_key,status_key) #Query for users by using specific sub_role and status key
sr = ::SubRole.first({conditions: { key: sub_role_key }}) sr = ::SubRole.first({conditions: { key: sub_role_key }})
status = ::Status.first({conditions:{role_id: sr.role.id,key: status_key}}) status = ::Status.first({conditions:{role_id: sr.role.id,key: status_key}})
find_by_status(sr.id,status.id) find_by_status(sr.id,status.id)
end end
def self.find_by_status(sub_role_id,status_id) def self.find_by_status(sub_role_id,status_id) #Query for users by using specific sub_role and status key buy within ID
User.where("status_record.#{sub_role_id}" => status_id) User.where("status_record.#{sub_role_id}" => status_id)
end end
@ -112,7 +117,7 @@ class User
def get_value_from_field_id(field_id) def get_value_from_field_id(field_id)
values = get_attribute_values values = get_attribute_values
value = values.detect {|value| value.attribute_field_id == field_id} rescue nil value = values.detect {|value| value.attribute_field_id == field_id} rescue nil
value ? value : self.attribute_values.build value ? value : nil
end end
def self.from_id(id) def self.from_id(id)
@ -128,7 +133,7 @@ class User
def check_status_record def check_status_record
roles = sub_roles.collect{|t| t.role}.uniq #get all role from sub_roles roles = sub_roles.collect{|t| t.role}.uniq #get all role from sub_roles
sub_roles_ary = sub_roles.collect{|t| t.id.to_s} sub_roles_ary = sub_roles.collect{|t| t.id.to_s}
self.status_record = status_record.keep_if{|sub_role_id, status_id| self.status_record = status_record.keep_if{|sub_role_id, status_id|
includeing = sub_roles_ary.include?(sub_role_id) includeing = sub_roles_ary.include?(sub_role_id)
valide = false valide = false
if includeing if includeing
@ -137,7 +142,7 @@ class User
end end
(includeing and valide) (includeing and valide)
} } rescue {}
end end
end end

View File

@ -10,13 +10,15 @@
<% end %> <% end %>
<td class='select_type'> <td class='select_type'>
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> <ul>
<div <%= attribute_field[:markup].eql?('select') ? nil : "style='display:none'"%>> <li><%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> </li>
<%= t('admin.options') %>: <li><%= f.check_box :locale %><%= label_tag "Locale" %> </li>
<%= f.select "select_list_options", {'1'=>"A",'2'=>"B",'3'=>"C"}, :style => "width:130px" %> <li><%= attribute_field[:markup].eql?('select') ? nil : "style='display:none'"%> </li>
<%#= collection_select(:select_list_options, method, collection, value_method, text_method, options = {}, html_options = {}) %> <li><%= t('admin.options') %>: <%= f.text_field :markup_value%></li>
</ul>
</div>
</td> </td>
<td class="action"> <td class="action">
<% if attribute_field.new_record? %> <% if attribute_field.new_record? %>

View File

@ -0,0 +1,19 @@
<div class="user-info">
<div class="user-avatar pull-left">
<p class="reflective"></p>
<% if @user.avatar? %>
<%= image_tag(@user.avatar.thumb.url) %>
<% else %>
<%= image_tag "person.png" %>
<% end %>
<%= file_field_tag 'file' %>
<%= hidden_field_tag :avatar_cache %>
</div>
<label>
<%= f.check_box :admin %>
<span><%= t('admin.admin') %></span>
</label>
</div>
<%= render :partial=>"infos"%>

View File

@ -0,0 +1,14 @@
<div class="map-block back">
<h4><span><%= info.title %></span></h4>
<div class="form-horizontal">
<% info.attribute_fields.each do |af|%>
<div class="control-group">
<%= af.block_helper(@user,@form_index)%>
</div>
<% @form_index = @form_index +1 %>
<% end %>
</div>
</div>

View File

@ -0,0 +1,4 @@
<!--<span><%#= t('admin.email') %></span> -->
<%#= f.text_field :email, :onfocus => "this.value='';", :onblur => "if(this.value==''){this.value=#{t('admin.email')};}", :value => (@user.email.blank? ? t('admin.email') : @user.email), :class => 'user_mail' %>
<%=render :partial=>"info",:collection=>Info.all%>

View File

@ -0,0 +1,31 @@
<div id="person" class="clear">
<% if @user.avatar? %>
<%= image_tag(@user.avatar.thumb.url) %>
<% else %>
<%= image_tag "person.png" %>
<% end %>
<%= file_field_tag 'file' %>
<%= hidden_field_tag :avatar_cache %>
<label>
<span><%= t('admin.email') %></span>
<%= f.text_field :email, :onfocus => "this.value='';", :onblur => "if(this.value==''){this.value=#{t('admin.email')};}", :value => (@user.email.blank? ? t('admin.email') : @user.email), :class => 'user_mail' %>
</label>
<label>
<%= f.check_box :admin %>
<span><%= t('admin.admin') %></span>
</label>
<label>
</label>
<table>
<tr>
<%=render :partial=>"temp_profile",:collection=>Info.all%>
<tr>
<tr> <span><%= t('admin.role') %></span> </tr>
<tr>
<%= render :partial=>"temp_sub_role_from",:collection=>@user.sub_roles %>
</tr>
</table>
</div>

View File

@ -0,0 +1,9 @@
<td>
<%= temp_profile.title %>
<% temp_profile.attribute_fields.each do |af|%>
<div class="control-group">
<%= af.block_helper(@user,@form_index)%>
</div>
<% @form_index = @form_index +1 %>
<% end %>
</td>

View File

@ -0,0 +1,10 @@
<td>
<%= temp_sub_role_from.title%>
<ul>
<% temp_sub_role_from.attribute_fields.each do |af| %>
<li><%= af.block_helper(@user,@form_index) %></li>
<% @form_index = @form_index +1 %>
<% end %>
</ul>
</td>

View File

@ -0,0 +1,24 @@
<% 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_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %>
</div>
<% end -%>
<% end -%>

View File

@ -34,6 +34,7 @@
<p class="user-mail"> <p class="user-mail">
<%= @user.email %> <%= @user.email %>
</p> </p>
<%= link_to "<i class='icon-pencil'></i>TempEdit".html_safe,temp_edit_admin_users_new_interface_path(@user),:class=>"btn btn-small"%>
<button class="btn btn-small"><i class="icon-pencil"></i> <%= t("admin.edit")%></button> <button class="btn btn-small"><i class="icon-pencil"></i> <%= t("admin.edit")%></button>
</div> </div>
<div class="user-roles my_scroll"> <div class="user-roles my_scroll">

View File

@ -0,0 +1,23 @@
<% 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_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'temp_form', :locals => { :f => f } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %>
</div>
<% end -%>
<% end -%>

View File

@ -6,6 +6,12 @@ forbidden_item_names:
markups: markups:
- text_field - text_field
- select - select
- date
- text_area #NC
- radio_button #NC
- checkbox #NC
- date_durnation #NC
- text_field_ext #NC for addr for phone
public_r_tags: public_r_tags:
- ad_banner - ad_banner

View File

@ -127,7 +127,12 @@ Orbit::Application.routes.draw do
resources :tags resources :tags
resources :translations resources :translations
resources :users resources :users
resources :users_new_interface resources :users_new_interface do
member do
get 'temp_edit'
end
end
end end
# end admin # end admin

View File

@ -1,6 +1,37 @@
# encoding: utf-8 # encoding: utf-8
namespace :build_new_member do namespace :build_new_member do
task :set_gender => :environment do
af = AttributeField.first({conditions:{key: "gender"}})
af.markup_value = {"1"=>{"en"=>"Male", "zh_tw"=>"男性"}, "2"=>{"en"=>"Female", "zh_tw"=>"女性"}, "3"=>{"en"=>"Other", "zh_tw"=>"其他"}, "3"=>{"en"=>"Not public", "zh_tw"=>"不公開"}}
af.markup = "select"
af.locale = true
af.save
end
task :setup_status_options => :environment do
data_set = {
:teacher=>{:status=>{:markup=>"select",:markup_value=>{"1"=>{"en"=>"Fulltime", "zh_tw"=>"全職"}, "2"=>{"en"=>"Adjunct", "zh_tw"=>"兼職"}, "3"=>{"en"=>"Co Hiring", "zh_tw"=>"合聘"}, "3"=>{"en"=>"Distinguished", "zh_tw"=>"特聘"}}}},
:student=>{:status=>{:markup=>"select",:markup_value=>{"1"=>{"en"=>"Studying", "zh_tw"=>"在學"}, "2"=>{"en"=>"Drop-out", "zh_tw"=>"休學"}, "3"=>{"en"=>"Alumi", "zh_tw"=>"校友"}, "3"=>{"en"=>"Suspended", "zh_tw"=>"未完成"}}}},
:staff=>{:staff=>{:markup=>"select",:markup_value=>nil}}
}
data_set.each do |key,data|
role = Role.first({conditions:{key: key}})
role.sub_roles.each do |sr|
sr.attribute_fields.each do |af|
if af.key == "status"
# binding.pry
af.markup = data[:status][:markup]
af.markup_value = data[:status][:markup_value]
af.save
# binding.pry
end
end
end
end
end
task :sub_role_tags_generate => :environment do task :sub_role_tags_generate => :environment do
SubRoleTag.destroy_all SubRoleTag.destroy_all
role_keys = %w{teacher staff student} role_keys = %w{teacher staff student}