break down Ray's HTML

This commit is contained in:
Matthew K. Fu JuYuan 2012-09-13 18:39:27 +08:00 committed by Christophe Vilayphiou
parent 3e5978c8fd
commit 5fb94f644d
11 changed files with 260 additions and 131 deletions

View File

@ -31,7 +31,7 @@ gem 'resque' # background jobs
gem 'resque-scheduler' # job scheduling
gem 'resque-restriction'
#gem 'rb-readline'
gem 'ruby-debug19'
# gem 'ruby-debug19'
gem 'rubyzip'
gem 'sunspot_mongo'
@ -70,6 +70,11 @@ end
group :test, :development do
gem 'pry'
gem 'pry-remote'
gem 'pry-stack_explorer'
gem 'pry-debugger'
gem "sunspot-rails-tester"
gem 'spork'
gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing.

View File

@ -9,12 +9,46 @@ class AttributeField
field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
field :title, localize: true
#field :title, localize: true
field :locale_title, localize: true
field :neutral_title
belongs_to :attribute
belongs_to :role
has_many :attribute_values
# validates_uniqueness_of :key
def title_translations
if locale
return locale_title_translations
else
return Hash[VALID_LOCALES.map{|d| [d,neutral_title]}]
end
end
def title_translations=(var)
if locale
self.locale_title = var
end
end
def title
if locale
return self.locale_title
else
return self.neutral_title
end
end
def title=(var)
binding.pry
if locale
self.locale_title = var
else
self.neutral_title = var
end
end
# Convert the string list_options into an array
def select_list_options=(var)

View File

@ -10,6 +10,8 @@ class Role
has_many :sub_roles, :autosave => true, :dependent => :destroy
has_many :users
has_many :statuses, :autosave => true, :dependent => :destroy
has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :sub_roles, :allow_destroy => true
def is_built_in?

11
app/models/user/status.rb Normal file
View File

@ -0,0 +1,11 @@
class Status
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :role
has_and_belongs_to_many :sub_roles
field :title, localize: true
end

View File

@ -2,7 +2,7 @@ class SubRole < Attribute
belongs_to :role
has_and_belongs_to_many :users
has_and_belongs_to_many :statuses, :autosave => true, :dependent => :destroy
# Get an sub_role from key
def self.get_sub_role_from_key(key)
self.first(:conditions => {:key => key})

View File

@ -9,10 +9,13 @@
<% end %>
<% end %>
<td class='select_type'>
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
<div <%= attribute_field[:markup].eql?('select') ? nil : "style='display:none'"%>>
<%= t('admin.options') %>:
<%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %>
<%= 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 = {}) %>
</div>
</td>
<td class="action">

View File

@ -0,0 +1,46 @@
<div class="item element">
<h3><i class="icons-content"></i>Module Name</h3>
<div class="detail w-a h-a">
<table class="table table-striped">
<thead>
<tr>
<th>模組</th>
<th class="span2">數量</th>
</tr>
</thead>
</table>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table class="table table-striped">
<tbody>
<tr>
<td>University</td>
<td class="span2">2,304</td>
</tr>
<tr>
<td>Master</td>
<td class="span2">783</td>
</tr>
<tr>
<td>Doctor</td>
<td class="span2">45</td>
</tr>
<tr>
<td>Staff</td>
<td class="span2">62</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,16 @@
<div class="roles <%= role_class %>">
<div class="label-line">
<hr />
<span><%= t(i18n)%></span>
</div>
<table class="table">
<tbody>
<% items.each do |item| %>
<tr>
<td class="span1"><%= item[:name] %></td>
<td><%= item[:value] %></td>
</tr>
<% end -%>
</tbody>
</table>
</div>

View File

@ -1,135 +1,58 @@
<div class="user-info clear">
<div id="isotope" class="user-data">
<div id="module-nav">
<div class="arrow_next pull-right"><i class="icon-chevron-right"></i></div>
<div class="arrow_prev pull-left"><i class="icon-chevron-left"></i></div>
<div class="module-nav-view">
<ul class="nav nav-pills">
<li class="active">
<a href="#"><%= t("admin.new_admin.users.all_plugin_summary")%></a>
</li>
<li><a href="#">學歷</a></li>
<li><a href="#">學歷</a></li>
<li><a href="#">學歷</a></li>
<li><a href="#">學歷</a></li>
</ul>
</div>
</div>
<div class="member-plugin">
<% binding.pry%>
<%= render :partial=> 'plugin_summary'%>
<%= render :partial=> 'plugin_summary'%>
<%= render :partial=> 'plugin_summary'%>
</div>
</div>
<div class="user-info">
<div id="brand" class="clear">
<p class="gender male"></p>
<div class="user-avatar pull-left">
<p class="reflective"></p>
<%= image_tag(@user.avatar.url) %>
<img src="images/menber-pic.png">
</div>
<div class="user-info-basic clear">
<p class="gender male"></p>
<a class="btn pull-right" href="#"><i class="icon-edit"></i> <%= t("admin.new_admin.action.edit")%></a>
<p class="user-name">
<%= @user.name %>
<%= @user.name%>
</p>
<p class="user-mail">
<%= @user.email %>
</p>
<hr />
<button class="btn btn-small"><i class="icon-pencil"></i> <%= t("admin.edit")%></button>
</div>
</div>
<div class="user-data">
<ul class="roles-nav">
<li class="teacher active">
<a href="#teacher" data-toggle="tab">
Teacher
</a>
</li>
<li class="student">
<a href="#student" data-toggle="tab">
Student
</a>
</li>
<li class="staff">
<a href="#staff" data-toggle="tab">
Staff
</a>
</li>
<li class="data">
<a href="#data" data-toggle="tab">
Data
</a>
</li>
</ul>
<div class="tab-content user-info-roles">
<div class="tab-pane fade in active teacher" id="teacher">
<p>講師</p>
</div>
<div class="tab-pane fade staff" id="staff">
staff
</div>
<div class="tab-pane fade student" id="student">
student
</div>
<div class="tab-pane fade data" id="data">
<div class="data-block information">
<h2>Information</h2>
<hr>
<div class="info_input">
<table>
<thead class="list_head">
<tr>
<td>Key</td>
<td>English</td>
<td>Chinese</td>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td>Last Name</td>
<td>Last Name</td>
<td>姓</td>
</tr>
<tr class="list_item">
<td>First Name</td>
<td>First Name</td>
<td>名</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="data-block teacher">
<h2>Teacher</h2>
<hr>
<div class="info_input">
<table>
<thead class="list_head">
<tr>
<td>Key</td>
<td>English</td>
<td>Chinese</td>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td>Last Name</td>
<td>Last Name</td>
<td>姓</td>
</tr>
<tr class="list_item">
<td>First Name</td>
<td>First Name</td>
<td>名</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="data-block student">
<h2>Student</h2>
<hr>
<div class="info_input">
<table>
<thead class="list_head">
<tr>
<td>Key</td>
<td>English</td>
<td>Chinese</td>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td>Last Name</td>
<td>Last Name</td>
<td>姓</td>
</tr>
<tr class="list_item">
<td>First Name</td>
<td>First Name</td>
<td>名</td>
</tr>
</tbody>
</table>
<div class="user-roles my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<% test_items = [ {:name=> "1",:value =>"Matt"},{:name=> "2",:value =>"Mark"},{:name=> "3",:value =>"Luke"},{:name=> "4",:value =>"John"} ]%>
<%= render :partial=> "user_role",:locals=>{:role_class=>"basic",:i18n=>"admin.new_admin.users.profile",:items=>test_items} %>
<%= render :partial=> "user_role",:locals=>{:role_class=>"teacher",:i18n=>"admin.new_admin.users.roles.teacher",:items=>test_items} %>
<%= render :partial=> "user_role",:locals=>{:role_class=>"student",:i18n=>"admin.new_admin.users.roles.student",:items=>test_items}%>
<%= render :partial=> "user_role",:locals=>{:role_class=>"staff",:i18n=>"admin.new_admin.users.roles.staff",:items=>test_items} %>
</div>
<div>
</div>
</div>

View File

@ -217,6 +217,13 @@ zh_tw:
user_roles: 角色
user_info: 使用者資訊
user: 會員
users:
all_plugin_summary: 全部
profile: 基本資料
roles:
staff: 職員資料
student: 學生資料
teacher: 教師資料
action:
add: 新增
edit: 編輯

View File

@ -0,0 +1,82 @@
# encoding: utf-8
namespace :build_new_member do
task :module_app => :environment do
ModuleApp.create!(:key=>"new_member",
:title=>"new_member",
:version=> "0.1",
:organization => "Rulingcom",
:author => "RD dep",
:intro => "New interface for member menagement",
:enable_frontend => true)
end
task :sub_role => :environment do
teacher_role = Role.first({conditions:{key: 'teacher'}})
teacher_role.sub_roles.destroy_all
teacher_sub_roles ={
:professor => {"zh_tw"=>"教授", "en"=>"Professor"},
:lecturer => {"zh_tw"=>"講師", "en"=>"Lecturer"},
:associate_professor => {"zh_tw"=>"副教授", "en"=>"Associate Professor"},
:assistant_professor => {"zh_tw"=>"助理教授", "en"=>"Assistant Professor"}
}
teacher_sub_roles.each do |key,title|
teacher_role.sub_roles.build :key=>key,:title_translations=>title,:built_in=>true
puts "=SubRole key:#{key}\t Title:#{title}"
end
teacher_role.save
p "==Finished building sub_roles for Teachers"
student_role = Role.first({conditions:{key: 'student'}})
student_role.sub_roles.destroy_all
student_sub_roles ={
:ph_d => {"zh_tw"=>"博士班", "en"=>"Ph.D"},
:master => {"zh_tw"=>"碩士班", "en"=>"Master"},
:bachelor => {"zh_tw"=>"學士班", "en"=>"Bachelor"},
}
student_sub_roles.each do |key,title|
student_role.sub_roles.build :key=>key,:title_translations=>title,:built_in=>true
puts "=SubRole key:#{key}\t Title:#{title}"
end
student_role.save
p "==Finished building sub_roles for Students"
end
task :status => :environment do
teacher_role = Role.first({conditions:{key: 'teacher'}})
teacher_role.statuses.destroy_all
teacher_status ={
:fulltime => {"en"=>"Full Time", "zh_tw"=>"全職"},
:adjunct => {"en"=>"Adjunct", "zh_tw"=>"兼職"},
:co_hiring => {"en"=>"Co Hiring", "zh_tw"=>"合聘"},
:distinguished => {"en"=>"Distinguished", "zh_tw"=>"特聘"}
}
teacher_status.each do |key,title|
teacher_role.statuses.build :key=>key,:title_translations=>title
puts "=Status key:#{key}\t Title:#{title}"
end
teacher_role.save
p "==Finished building status for Teachers"
student_role = Role.first({conditions:{key: 'student'}})
student_status.statuses.destroy_all
student_status ={
:studying => {"en"=>"Studying", "zh_tw"=>"在學"},
:drop_out => {"en"=>"Drop-out", "zh_tw"=>"休學"},
:alumi => {"en"=>"Alumi", "zh_tw"=>"校友"},
:suspended => {"en"=>"Suspended", "zh_tw"=>"未完成"}
}
student_status.each do |key,title|
student_role.statuses.build :key=>key,:title_translations=>title
puts "=Status key:#{key}\t Title:#{title}"
end
student_role.save
p "==Finished building status for Students"
end
end