diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css index 0f0620641..1fe9350da 100644 --- a/app/assets/stylesheets/member.css +++ b/app/assets/stylesheets/member.css @@ -131,8 +131,14 @@ margin: 0 0 3px; } .user-data { - padding: 70px 20px 0; - margin: 20px 0 0 360px; + padding: 60px 0 0; + margin: 0 0 0 360px; +} +.user-data .form-fixed { +} +.user-data .subnav { + top: 87px; + z-index: 1; } .user-data #module-nav { margin-left: -20px; @@ -141,13 +147,16 @@ background-color: #FFFFFF; top: 31px; padding: 10px 20px 0; - -webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, .16); - -moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, .16); - 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 0px 10px rgba(0, 0, 0, .16); + box-shadow: 0px 0px 10px rgba(0, 0, 0, .16); } .user-data #module-nav ul { margin-bottom: 10px; } +.member-plugin-list { + margin-bottom: 30px; +} .member-abstract, .member-large { padding: 15px; } @@ -273,3 +282,31 @@ .nav-tabs li a { 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; +} \ No newline at end of file diff --git a/app/assets/stylesheets/site-map.css b/app/assets/stylesheets/site-map.css new file mode 100644 index 000000000..3e5fb5115 --- /dev/null +++ b/app/assets/stylesheets/site-map.css @@ -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; +} diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index f0aaef739..9fe40933c 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -32,19 +32,19 @@ class Admin::UsersNewInterfaceController < ApplicationController @staff_data = [] @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| - @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| - @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| - @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 } # binding.pry @@ -81,28 +81,37 @@ class Admin::UsersNewInterfaceController < ApplicationController end end + def temp_edit + @user = User.find(params[:id]) + @form_index = 0 + get_info_and_roles + end + def edit @user = User.find(params[:id]) + @form_index = 0 get_info_and_roles end def update @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 - @user.remove_avatar! if params[:file] - @user.avatar = params[:file] if params[:file] - - if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b - flash.now[:error] = t('admin.cant_revoke_self_admin') - end - if !flash[:error] && @user.update_attributes(params[:user]) - flash[:notice] = t('admin.update_success_user') - redirect_to :action => :index - else - get_info_and_roles - render :action => :edit - end + # if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b + # flash.now[:error] = t('admin.cant_revoke_self_admin') + # end + # if !flash[:error] && @user.update_attributes(params[:user]) + # flash[:notice] = t('admin.update_success_user') + # redirect_to :action => :index + # else + # get_info_and_roles + # render :action => :edit + # end end def destroy diff --git a/app/helpers/attribute_field_helper.rb b/app/helpers/attribute_field_helper.rb new file mode 100644 index 000000000..9d0999da4 --- /dev/null +++ b/app/helpers/attribute_field_helper.rb @@ -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 = "
" + result << yield + result << "
" + result.html_safe + end + + def control_group_wrapper(&block) + result = "
" + result << yield + result << "
" + 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 \ No newline at end of file diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 0bda602d4..826627eb0 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -2,9 +2,11 @@ class AttributeField include Mongoid::Document include Mongoid::Timestamps - + include AttributeFieldHelper + field :key field :markup #[select,text_field,email,date,addr] + field :markup_value ,:type => Hash field :locale, :type => Boolean, :default => true field :list_options, :type => Array field :built_in, :type => Boolean, :default => false @@ -46,7 +48,7 @@ class AttributeField end def title=(var) - binding.pry + # binding.pry if locale self.locale_title = var else diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index 47c840858..49014e2ac 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -2,14 +2,52 @@ class AttributeValue include Mongoid::Document include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes field :key belongs_to :attribute_field belongs_to :user - - def method_missing(field) - self[field] + + before_save :check_key + + 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 + 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 diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 5ec88a11c..59032224a 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -43,28 +43,33 @@ class User self.status_record.store(sub_role_id,status_id) end - def get_status(*params) - param = params[0] - case param.class.to_s - when 'String' - sr = ::SubRole.find sub_role_id - when 'Hash' - sr = ::SubRole.first({conditions:{key: param[:key]}}) - end - if self.sub_roles.include?(sr) - return ::Status.find(status_record.fetch(sr.id.to_s)) - else - nil + # def get_status(*params) + # param = params[0] + # case param.class.to_s + # when 'String' + # sr = ::SubRole.find sub_role_id + # when 'Hash' + # sr = ::SubRole.first({conditions:{key: param[:key]}}) + # end + # if self.sub_roles.include?(sr) + # return ::Status.find(status_record.fetch(sr.id.to_s)) + # else + # nil + # end + # end + def new_attribute_values=(fields) + fields.each do |key,field| + self.attribute_values.build(field) 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 }}) status = ::Status.first({conditions:{role_id: sr.role.id,key: status_key}}) find_by_status(sr.id,status.id) 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) end @@ -112,7 +117,7 @@ class User def get_value_from_field_id(field_id) values = get_attribute_values value = values.detect {|value| value.attribute_field_id == field_id} rescue nil - value ? value : self.attribute_values.build + value ? value : nil end def self.from_id(id) @@ -128,7 +133,7 @@ class User def check_status_record 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} - 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) valide = false if includeing @@ -137,7 +142,7 @@ class User end (includeing and valide) - } + } rescue {} end end diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb index 7fd852853..5111f0155 100644 --- a/app/views/admin/attributes/_attribute_field.html.erb +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -10,13 +10,15 @@ <% end %> - <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> -
> - <%= t('admin.options') %>: - <%= f.select "select_list_options", {'1'=>"A",'2'=>"B",'3'=>"C"}, :style => "width:130px" %> - <%#= collection_select(:select_list_options, method, collection, value_method, text_method, options = {}, html_options = {}) %> + + -
+ <% if attribute_field.new_record? %> diff --git a/app/views/admin/users_new_interface/_form.html.erb b/app/views/admin/users_new_interface/_form.html.erb new file mode 100644 index 000000000..c9816391e --- /dev/null +++ b/app/views/admin/users_new_interface/_form.html.erb @@ -0,0 +1,19 @@ +
+
+

+ <% if @user.avatar? %> + <%= image_tag(@user.avatar.thumb.url) %> + <% else %> + <%= image_tag "person.png" %> + <% end %> + <%= file_field_tag 'file' %> + <%= hidden_field_tag :avatar_cache %> +
+ +
+ +<%= render :partial=>"infos"%> + diff --git a/app/views/admin/users_new_interface/_info.html.erb b/app/views/admin/users_new_interface/_info.html.erb new file mode 100644 index 000000000..d821b2098 --- /dev/null +++ b/app/views/admin/users_new_interface/_info.html.erb @@ -0,0 +1,14 @@ +
+

<%= info.title %>

+
+ + <% info.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/_infos.html.erb b/app/views/admin/users_new_interface/_infos.html.erb new file mode 100644 index 000000000..57e80aca8 --- /dev/null +++ b/app/views/admin/users_new_interface/_infos.html.erb @@ -0,0 +1,4 @@ + + <%#= 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%> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_temp_form.html.erb b/app/views/admin/users_new_interface/_temp_form.html.erb new file mode 100644 index 000000000..9e63fb2d1 --- /dev/null +++ b/app/views/admin/users_new_interface/_temp_form.html.erb @@ -0,0 +1,31 @@ +
+ <% if @user.avatar? %> + <%= image_tag(@user.avatar.thumb.url) %> + <% else %> + <%= image_tag "person.png" %> + <% end %> + <%= file_field_tag 'file' %> + <%= hidden_field_tag :avatar_cache %> + + + + + + <%=render :partial=>"temp_profile",:collection=>Info.all%> + + <%= t('admin.role') %>: + + <%= render :partial=>"temp_sub_role_from",:collection=>@user.sub_roles %> + +
+
+ + diff --git a/app/views/admin/users_new_interface/_temp_profile.html.erb b/app/views/admin/users_new_interface/_temp_profile.html.erb new file mode 100644 index 000000000..7791030ee --- /dev/null +++ b/app/views/admin/users_new_interface/_temp_profile.html.erb @@ -0,0 +1,9 @@ + +<%= 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/_temp_sub_role_from.html.erb b/app/views/admin/users_new_interface/_temp_sub_role_from.html.erb new file mode 100644 index 000000000..05fa4196f --- /dev/null +++ b/app/views/admin/users_new_interface/_temp_sub_role_from.html.erb @@ -0,0 +1,10 @@ + +<%= temp_sub_role_from.title%> + + + \ 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 new file mode 100644 index 000000000..0c295dfe2 --- /dev/null +++ b/app/views/admin/users_new_interface/edit.html.erb @@ -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 } %> +
+ <%= link_back %> + <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').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 c70a1d98f..03aff8d48 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -37,6 +37,7 @@

<%= @user.email %>

+ <%= link_to "TempEdit".html_safe,temp_edit_admin_users_new_interface_path(@user),:class=>"btn btn-small"%>
diff --git a/app/views/admin/users_new_interface/temp_edit.html.erb b/app/views/admin/users_new_interface/temp_edit.html.erb new file mode 100644 index 000000000..ebaa51eb9 --- /dev/null +++ b/app/views/admin/users_new_interface/temp_edit.html.erb @@ -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 } %> +
+ <%= link_back %> + <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> +
+ <% end -%> + +<% end -%> \ No newline at end of file diff --git a/config/list.yml b/config/list.yml index 8615c60f4..7e8d75670 100644 --- a/config/list.yml +++ b/config/list.yml @@ -6,6 +6,12 @@ forbidden_item_names: markups: - text_field - select + - date + - text_area #NC + - radio_button #NC + - checkbox #NC + - date_durnation #NC + - text_field_ext #NC for addr for phone public_r_tags: - ad_banner diff --git a/config/routes.rb b/config/routes.rb index e0416c1cc..b3d8d6ec4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -127,7 +127,12 @@ Orbit::Application.routes.draw do resources :tags resources :translations resources :users - resources :users_new_interface + resources :users_new_interface do + member do + get 'temp_edit' + end + end + end # end admin diff --git a/lib/tasks/build_new_member.rake b/lib/tasks/build_new_member.rake index c7953057b..4e4a6bcc9 100644 --- a/lib/tasks/build_new_member.rake +++ b/lib/tasks/build_new_member.rake @@ -1,6 +1,37 @@ # encoding: utf-8 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 SubRoleTag.destroy_all role_keys = %w{teacher staff student}