From 9bfd1d2b0c9b6de8368c457420109483981d1da0 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 13 Sep 2012 18:39:27 +0800 Subject: [PATCH] break down Ray's HTML --- Gemfile | 7 +- app/models/user/attribute_field.rb | 38 +++- app/models/user/role.rb | 2 + app/models/user/status.rb | 11 ++ app/models/user/sub_role.rb | 2 +- .../attributes/_attribute_field.html.erb | 5 +- .../_plugin_summary.html.erb | 46 +++++ .../users_new_interface/_user_role.html.erb | 16 ++ .../admin/users_new_interface/show.html.erb | 175 +++++------------- config/locales/zh_tw.yml | 7 + lib/tasks/build_new_member.rake | 82 ++++++++ 11 files changed, 260 insertions(+), 131 deletions(-) create mode 100644 app/models/user/status.rb create mode 100644 app/views/admin/users_new_interface/_plugin_summary.html.erb create mode 100644 app/views/admin/users_new_interface/_user_role.html.erb create mode 100644 lib/tasks/build_new_member.rake diff --git a/Gemfile b/Gemfile index 906fa408..e83da25d 100644 --- a/Gemfile +++ b/Gemfile @@ -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' @@ -68,6 +68,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. diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 2a227d27..dd22b9df 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -9,13 +9,47 @@ 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) self.list_options = var.gsub(' ', '').split(',') diff --git a/app/models/user/role.rb b/app/models/user/role.rb index bbcedfc7..438e2dab 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -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? diff --git a/app/models/user/status.rb b/app/models/user/status.rb new file mode 100644 index 00000000..9022a4f1 --- /dev/null +++ b/app/models/user/status.rb @@ -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 \ No newline at end of file diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb index cdefb5f5..8ff91b3f 100644 --- a/app/models/user/sub_role.rb +++ b/app/models/user/sub_role.rb @@ -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}) diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb index b2e94344..7fd85285 100644 --- a/app/views/admin/attributes/_attribute_field.html.erb +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -9,10 +9,13 @@ <% end %> <% end %> + <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
> <%= 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 = {}) %> +
diff --git a/app/views/admin/users_new_interface/_plugin_summary.html.erb b/app/views/admin/users_new_interface/_plugin_summary.html.erb new file mode 100644 index 00000000..09871ad8 --- /dev/null +++ b/app/views/admin/users_new_interface/_plugin_summary.html.erb @@ -0,0 +1,46 @@ +
+

Module Name

+
+ + + + + + + +
模組數量
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
University2,304
Master783
Doctor45
Staff62
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/admin/users_new_interface/_user_role.html.erb b/app/views/admin/users_new_interface/_user_role.html.erb new file mode 100644 index 00000000..05ef4bb1 --- /dev/null +++ b/app/views/admin/users_new_interface/_user_role.html.erb @@ -0,0 +1,16 @@ +
+
+
+ <%= t(i18n)%> +
+ + + <% items.each do |item| %> + + + + + <% end -%> + +
<%= item[:name] %><%= item[:value] %>
+
diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index d6a83048..a1f5fdee 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -1,135 +1,58 @@ -
-
-

- <%= image_tag(@user.avatar.url) %> +
+ - +