From 50029163520b85548059266b79fb61fc0dadfa67 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 22 Dec 2012 17:35:59 +0800 Subject: [PATCH 1/3] Remove mysql --- Gemfile | 1 - config/initializers/nccu_ldap_connection.rb | 16 ---------------- 2 files changed, 17 deletions(-) delete mode 100644 config/initializers/nccu_ldap_connection.rb diff --git a/Gemfile b/Gemfile index 375667dc..aa6a2ba9 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,6 @@ gem 'mini_magick' gem 'mongoid', '> 2.1', '< 3.0.0' gem 'mongoid-tree', :require => 'mongoid/tree' gem "mongo_session_store-rails3" -gem 'mysql2' gem 'nokogiri' diff --git a/config/initializers/nccu_ldap_connection.rb b/config/initializers/nccu_ldap_connection.rb deleted file mode 100644 index 00e03367..00000000 --- a/config/initializers/nccu_ldap_connection.rb +++ /dev/null @@ -1,16 +0,0 @@ -#encoding: utf-8 -require 'mysql2' - -$nccu_ldap_connection - -module NccuLdapConnection - BASE = 'ou=People,dc=nccu,dc=edu,dc=tw' - - def self.establish - $nccu_ldap_connection = Net::LDAP.new - $nccu_ldap_connection.port =LDAP_CONFIG["port"] - $nccu_ldap_connection.host = LDAP_CONFIG["host"] - $nccu_ldap_connection.authenticate(LDAP_CONFIG["authenticate_info"],LDAP_CONFIG["authenticate_pwd"]) - end - -end \ No newline at end of file From 9584d67b2335c3ac7e9226077a23adaed85b22a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Jan 2013 16:58:01 +0800 Subject: [PATCH 2/3] member roles edit --- Gemfile | 8 +- app/controllers/admin/roles_controller.rb | 164 ++++++++++++- app/controllers/admin/sub_roles_controller.rb | 4 + app/models/user/attribute_field.rb | 3 + app/models/user/role.rb | 7 +- .../attributes/_attribute_field_list.html.erb | 4 + app/views/admin/attributes/edit.html.erb | 231 +++++++++++++----- app/views/admin/attributes/index.html.erb | 103 +++++--- app/views/admin/attributes/new.html.erb | 63 ++++- .../admin/roles/_attribute_field.html.erb | 121 +++++++++ .../admin/roles/add_attribute_field.js.erb | 1 + app/views/admin/roles/add_sub_role.html.erb | 36 +++ app/views/admin/roles/edit_sub_role.html.erb | 37 +++ app/views/admin/roles/new.html.erb | 1 + app/views/admin/roles/role_field.html.erb | 128 ++++++++++ app/views/admin/roles/sub_role.html.erb | 41 ++++ app/views/admin/roles/sub_role_field.html.erb | 125 ++++++++++ app/views/admin/roles/toggle_enable.js.erb | 3 + .../admin/users_new_interface/_role.html.erb | 13 +- .../users_new_interface/_show_roles.html.erb | 7 + .../users_new_interface/_side_bar.html.erb | 10 +- config/routes.rb | 4 + 22 files changed, 975 insertions(+), 139 deletions(-) create mode 100644 app/controllers/admin/sub_roles_controller.rb create mode 100644 app/views/admin/attributes/_attribute_field_list.html.erb create mode 100644 app/views/admin/roles/_attribute_field.html.erb create mode 100644 app/views/admin/roles/add_attribute_field.js.erb create mode 100644 app/views/admin/roles/add_sub_role.html.erb create mode 100644 app/views/admin/roles/edit_sub_role.html.erb create mode 100644 app/views/admin/roles/new.html.erb create mode 100644 app/views/admin/roles/role_field.html.erb create mode 100644 app/views/admin/roles/sub_role.html.erb create mode 100644 app/views/admin/roles/sub_role_field.html.erb create mode 100644 app/views/admin/roles/toggle_enable.js.erb diff --git a/Gemfile b/Gemfile index aa6a2ba9..4c3ff0cd 100644 --- a/Gemfile +++ b/Gemfile @@ -72,10 +72,10 @@ end group :test, :development do - gem 'pry' - gem 'pry-remote' - gem 'pry-stack_explorer' - gem 'pry-debugger' + #gem 'pry' + #gem 'pry-remote' + #gem 'pry-stack_explorer' + #gem 'pry-debugger' gem 'faker' gem "sunspot-rails-tester" diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index 3e8576c6..ade4aa43 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -3,7 +3,7 @@ class Admin::RolesController < ApplicationController layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? - before_filter :set_attribute, :only => [:index, :show, :new, :edit] + before_filter :set_attribute, :only => [:index, :show, :new, :edit, :role_field, :sub_role, :add_sub_role, :edit_sub_role, :sub_role_field] helper Admin::AttributeValuesViewHelper def index @@ -13,11 +13,98 @@ class Admin::RolesController < ApplicationController def show + end + + def role_field + + @field_name = 'role' + + @attribute = Role.find(params[:role_id]) + + end + + def sub_role + + @attribute = Role.find(params[:role_id]) + @attribute_fields_upper_object = @attribute.sub_roles + + + end + + def add_sub_role + + @attribute = Role.find(params[:role_id]) + # @sub_attribute = Role.find(params[:role_id]) + + @sub_attribute = SubRole.new + @sub_attribute.role_id = params[:role_id] + + end + + def edit_sub_role + + @sub_attribute = SubRole.find(params[:role_id]) + + @attribute = Role.find(@sub_attribute.role_id) + + @sub_attribute.role_id = @sub_attribute.role_id + + end + + def sub_role_field + + @field_name = 'sub_role' + + @sub_attribute = SubRole.find(params[:role_id]) + + @attribute = Role.find(@sub_attribute.role_id) + + end + + def add_attribute_field + + if params[:sub_role] + + @field_name = 'sub_role' + + attribute = SubRole.find(params[:sub_role][:id]) rescue nil + @attribute_field_counter = attribute.attribute_fields.count + @attribute_field = attribute.attribute_fields.build + @attribute_field.save + + @attribute_field[:af_count] = @attribute_field_counter + + @attribute = SubRole.find(params[:sub_role][:id]) + + else + + @field_name = 'role' + + attribute = Role.find(params[:role_id]) rescue nil + @attribute_field_counter = attribute.attribute_fields.count + @attribute_field = attribute.attribute_fields.build + @attribute_field.save + + @attribute_field[:af_count] = @attribute_field_counter + + @attribute = Role.find(params[:role_id]) + + end + + respond_to do |format| + format.js { render 'add_attribute_field' } + end + + end def new @attribute = Role.new - render :template => 'admin/attributes/new' + + if !params[:parent_id] + render :template => 'admin/attributes/new' + end + end def edit @@ -27,24 +114,75 @@ class Admin::RolesController < ApplicationController end def create - @attribute = Role.new(params[:role]) - @attribute.save - redirect_to :action => :index + + if params[:sub_role] + + @sub_role = SubRole.new(params[:sub_role]) + + # @sub_role.role_id = params[:id] + + respond_to do |format| + if @sub_role.save + format.html { redirect_to(admin_role_sub_role_url(params[:sub_role][:role_id])) } + end + end + + else + + @attribute = Role.new(params[:role]) + @attribute.save + redirect_to :action => :index + + end + end def update - @attribute = Role.find(params[:id]) - @attribute.update_attributes(params[:role]) - respond_to do |format| - format.html { redirect_to :action => :index } - format.js { render 'admin/attributes/toggle_enable' } + + if params[:sub_role] + + @sub_role = SubRole.find(params[:sub_role][:id]) + @sub_role.update_attributes(params[:sub_role]) + @sub_role.attribute_fields.each{|t| t.destroy if t["to_delete"] == true} + respond_to do |format| + format.html { redirect_to(admin_role_sub_role_url(@sub_role.role_id)) } + format.js { render 'toggle_enable' } + end + + else + + @attribute = Role.find(params[:id]) + @attribute.update_attributes(params[:role]) + @attribute.attribute_fields.each{|t| t.destroy if t["to_delete"] == true} + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/attributes/toggle_enable' } + end + end + end def destroy - @attribute = Role.find(params[:id]) - @attribute.destroy - redirect_to :action => :index + + if params[:sub_role] + + @sub_role = SubRole.find(params[:sub_role][:id]) + + respond_to do |format| + if @sub_role.destroy + format.html { redirect_to(admin_role_sub_role_url(@sub_role.role_id)) } + end + end + + else + + @attribute = Role.find(params[:id]) + @attribute.destroy + redirect_to :action => :index + + end + end protected diff --git a/app/controllers/admin/sub_roles_controller.rb b/app/controllers/admin/sub_roles_controller.rb new file mode 100644 index 00000000..e39f783d --- /dev/null +++ b/app/controllers/admin/sub_roles_controller.rb @@ -0,0 +1,4 @@ +class Admin::SubRolesController < RolesController + + +end diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index d486ccd0..0a6c4ac3 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -11,6 +11,9 @@ class AttributeField field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false field :to_delete,:type=> Boolean,:default => false + + field :to_search,:type=> Boolean,:default => false + field :typeA,:type=> Hash,:default=>{:cross_lang=>false} field :typeB,:type=> Hash,:default=>{} field :typeC,:type=> Hash,:default=>{:calendar=>"west_calendar",:format=>"format3"} diff --git a/app/models/user/role.rb b/app/models/user/role.rb index cd3d6775..e5d8039d 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -1,4 +1,4 @@ -class Role +class Role < Attribute include Mongoid::Document include Mongoid::Timestamps @@ -6,12 +6,15 @@ class Role field :key field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false + + field :to_search, :type => Boolean, :default => false + field :title, localize: true 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 + # 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/views/admin/attributes/_attribute_field_list.html.erb b/app/views/admin/attributes/_attribute_field_list.html.erb new file mode 100644 index 00000000..f09747a3 --- /dev/null +++ b/app/views/admin/attributes/_attribute_field_list.html.erb @@ -0,0 +1,4 @@ +
+

<%= attribute_field_list.title+ t("admin.attributes")%>

+ <%= render :partial=>"shared/attribute_field/attribute_field",:collection=>attribute_field_list.attribute_fields%> +
\ No newline at end of file diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index 301bf18b..a98b4cad 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -1,9 +1,29 @@ - <%= form_for @attribute,:url => admin_info_path(@attribute) ,:class=> "form-horizontal" do |f| %> +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + + <%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %>
-

<%= t(:info)%>

+

<%= t(eval(":#{@attribute_type}"))%>

+ <% if @attribute._type == "Role" %> +
+ +
+ + +
+
+ <% end %> +
@@ -14,10 +34,11 @@ <% end %>
- <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"info[title_translations]"}%> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"#{@attribute_type}[title_translations]"}%>
+ <% if @attribute._type == "Info" %>

<%= @attribute.title+ t(:attributes)%>

@@ -26,11 +47,13 @@
+ <% end %> +
- <%= link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true%> + <%= ( link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true ) if @attribute._type == "Info"%> <%= f.submit t(:save),:class=>"btn btn-primary"%> - + <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
<% end %> <% content_for :page_specific_css do -%> @@ -39,12 +62,16 @@ <% end %> <% content_for :page_specific_javascript do -%> - <% end -%> diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb index 6b74f8a9..eafdde02 100644 --- a/app/views/admin/attributes/index.html.erb +++ b/app/views/admin/attributes/index.html.erb @@ -1,39 +1,72 @@ -<% content_for :secondary do %> - <%= render 'admin/users_new_interface/side_bar' %> +<% # encoding: utf-8 %> + +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %> <% end %> -
-
- <%= link_to t("new.#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %> -
- - - - - - - - - <% @attributes.each do |attribute| %> - "> - - - - - - <% end %> - -
<%= t("#{@attribute_type}") %><%= t(:action) %>
<%= attribute.title %> - - - <%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %> - <%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %> - <% if !attribute.is_built_in? %> - <%= link_to t(:delete_), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> - <% end %> -
-
- <%= link_to t("new.#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %> + + + + + + + + + + + + <% @attributes.each do |attribute| %> + + + + <% end %> + + +
+ <%= attribute.title %> +
+ +
+
+
+ <%= link_to content_tag(:i,t("new.#{@attribute_type}"),:class=>"icon-plus icon-white"),eval("new_admin_#{@attribute_type}_path"),:class=>"btn btn-primary pull-right"%> +
+ +
+
+ \ No newline at end of file diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb index 8cafdb59..99b526ff 100644 --- a/app/views/admin/attributes/new.html.erb +++ b/app/views/admin/attributes/new.html.erb @@ -1,14 +1,51 @@ -<% content_for :secondary do %> - <%= render 'admin/users_new_interface/side_bar' %> -<% end %> + <%= form_for @attribute,:url => eval("admin_#{@attribute_type}s_path") ,:class=> "form-horizontal" do |f| %> +
+
+

<%= t(eval(":#{@attribute_type}"))%>

+
+
+ + <% if @attribute._type == "Role" %> +
+ +
+ + +
+
+ <% end %> + +
+ +
+ <% if @attribute.new_record? %> + <%= f.text_field :key, :placeholder => t(:key) %> + <% else %> +
<%= @attribute.key%>
+ <% end %> +
+
+ <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"#{@attribute_type}[title_translations]"}%> +
+
+
+
+ +
+ <%= f.submit t('submit'), :class=>'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + <% end %> + -
- <%= form_for @attribute, :url => eval("admin_#{@attribute_type}s_path") do |f| %> - <%= f.error_messages %> - <%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => true } %> -
- <%= link_back %> - <%= link_to t('create'), "#", :onclick=>"$('#new_#{@attribute_type}').submit()" %> -
- <% end -%> -
\ No newline at end of file +<% content_for :page_specific_css do -%> + <%= stylesheet_link_tag "member" %> + <%= stylesheet_link_tag "site-map" %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/_attribute_field.html.erb b/app/views/admin/roles/_attribute_field.html.erb new file mode 100644 index 00000000..240a8c18 --- /dev/null +++ b/app/views/admin/roles/_attribute_field.html.erb @@ -0,0 +1,121 @@ +
+ <% + attribute_field.af_count ? @af_counter = attribute_field_counter + attribute_field.af_count : @af_counter = attribute_field_counter + %> + <%= @af_counter %> + <%#= attribute_field_counter %> + + + <%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","disabled",:value=>attribute_field.disabled,:class=>"attribute_field_disabled"%> + <%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","to_delete",:value=>false,:class=>"attribute_field_to_delete"%> + <%= t(:delete_)%> +
+
+ +
+ + +
+
+
+ +
+
+ <%= text_field "#{@field_name}[attribute_fields][#{@af_counter}]","key",:value=>attribute_field.key%> +
+
+
+ <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][title_translations]"}%> +
+ +
+ <%#= select_tag "#{@field_name}[attribute_fields][#{@af_counter}][markup]" do %> + +
+
+
+
+
+ <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeA") do%> +
+ +
+ + +
+
+ <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeA][placeholder]"}%> + <% end %> + + <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeB") do %> + <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_field["typeB"]["initial"],:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeB][initial]"}%> + + <% if attribute_field.self_defined_markup_options?%> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[attribute_fields][#{@af_counter}][attribute][role][statuses]"} %> + <%else #normal list%> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[attribute_fields][#{@af_counter}][typeB][option_list]"} %> + <% end #of self_defined_markup_options?%> + + <% end %> + <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeC") do %> +
+ +
+ <%= select "#{@field_name}[attribute_fields][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_field["typeC"]["format"] %> +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+ <% end %> + <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeD") do%> +
+ +
+ +
+
+ <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %> + <% end %> + <%= content_tag :div,:class=>show_type_panel(attribute_field,"typeE") do%> + <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%> + <% end %> +
+ <%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","id",:value=>attribute_field.id%> +
diff --git a/app/views/admin/roles/add_attribute_field.js.erb b/app/views/admin/roles/add_attribute_field.js.erb new file mode 100644 index 00000000..7b678b99 --- /dev/null +++ b/app/views/admin/roles/add_attribute_field.js.erb @@ -0,0 +1 @@ +$('<%= j render :partial => 'attribute_field', :collection => [@attribute_field] %>').appendTo('#attribute_field_list').hide().fadeIn(); diff --git a/app/views/admin/roles/add_sub_role.html.erb b/app/views/admin/roles/add_sub_role.html.erb new file mode 100644 index 00000000..bf4bf1e9 --- /dev/null +++ b/app/views/admin/roles/add_sub_role.html.erb @@ -0,0 +1,36 @@ + <%= form_for @sub_attribute,:url => eval("admin_#{@attribute_type}s_path") ,:class=> "form-horizontal" do |f| %> +
+
+

<%= t(eval(":#{@attribute_type}"))%>:<%= @attribute.title %>

+
+
+
+ +
+ <% if @sub_attribute.new_record? %> + <%= f.text_field :key, :placeholder => t(:key) %> + <% else %> +
<%= @sub_attribute.key%>
+ <% end %> +
+
+ <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@sub_attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"sub_role[title_translations]"}%> +
+
+
+
+ +
+ <%#= hidden_field_tag 'id', params[:role_id] if !params[:role_id].blank? %> + <%= f.hidden_field :role_id, :value => params[:role_id] if !params[:role_id].blank? %> + <%= f.submit t('submit'), :class=>'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + <% end %> + + +<% content_for :page_specific_css do -%> + <%= stylesheet_link_tag "member" %> + <%= stylesheet_link_tag "site-map" %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/edit_sub_role.html.erb b/app/views/admin/roles/edit_sub_role.html.erb new file mode 100644 index 00000000..b4848fd4 --- /dev/null +++ b/app/views/admin/roles/edit_sub_role.html.erb @@ -0,0 +1,37 @@ + <%= form_for @sub_attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %> +
+
+

<%= t(eval(":#{@attribute_type}"))%>:<%= @attribute.title %>

+
+
+
+ +
+ <% if @sub_attribute.new_record? %> + <%= f.text_field :key, :placeholder => t(:key) %> + <% else %> +
<%= @sub_attribute.key%>
+ <% end %> +
+
+ <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@sub_attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"sub_role[title_translations]"}%> +
+
+
+
+ +
+ <%#= hidden_field_tag 'id', params[:role_id] if !params[:role_id].blank? %> + <%= f.hidden_field :id %> + <%#= f.hidden_field :role_id, :value => @attribute.id if !params[:role_id].blank? %> + <%= f.submit t('submit'), :class=>'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + <% end %> + + +<% content_for :page_specific_css do -%> + <%= stylesheet_link_tag "member" %> + <%= stylesheet_link_tag "site-map" %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/new.html.erb b/app/views/admin/roles/new.html.erb new file mode 100644 index 00000000..9d07aa0d --- /dev/null +++ b/app/views/admin/roles/new.html.erb @@ -0,0 +1 @@ +111 \ No newline at end of file diff --git a/app/views/admin/roles/role_field.html.erb b/app/views/admin/roles/role_field.html.erb new file mode 100644 index 00000000..43880fac --- /dev/null +++ b/app/views/admin/roles/role_field.html.erb @@ -0,0 +1,128 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + + <%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %> +
+ +
+

<%= @attribute.title+ t(:attributes)%>

+
+ <%= render :partial=>"attribute_field",:collection=>@attribute.attribute_fields%> +
+
+ +
+ <%= link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_role_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true%> +
+ +
+ +
+ <%#= f.hidden_field :id, :value => params[:role_id] if !params[:role_id].blank? %> + <%= hidden_field_tag 'id', params[:role_id] if !params[:role_id].blank? %> + <%= f.submit t(:save),:class=>"btn btn-primary"%> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + <% end %> + +<% content_for :page_specific_css do -%> + <%= stylesheet_link_tag "member" %> + <%= stylesheet_link_tag "site-map" %> +<% end %> + +<% content_for :page_specific_javascript do -%> + +<% end -%> diff --git a/app/views/admin/roles/sub_role.html.erb b/app/views/admin/roles/sub_role.html.erb new file mode 100644 index 00000000..9dc8892e --- /dev/null +++ b/app/views/admin/roles/sub_role.html.erb @@ -0,0 +1,41 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + +
+
+ <%= link_to t(:new_sub_role), eval("admin_#{@attribute_type}_add_sub_role_path(@attribute)"), :class => 'new' %> +
+ + + + + + + + + <% @attribute_fields_upper_object.each do |attribute| %> + "> + + + + + + <% end %> + +
<%= t("#{@attribute_type}") %>:<%= @attribute.title %><%= t(:action) %>
<%= attribute.title %> + + + <%= link_to t(:edit), eval("admin_#{@attribute_type}_edit_sub_role_path(attribute)"), :class => 'edit' %> + <%= link_to t(:sub_role_field), eval("admin_#{@attribute_type}_sub_role_field_path(attribute)"), :class => 'edit' %> + <%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :sub_role => {:disabled => true, :id => attribute })"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :sub_role => {:disabled => false, :id => attribute })"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %> + + <% if !attribute.is_built_in? %> + <%= link_to t(:delete_), eval("admin_#{@attribute_type}_path(attribute, :sub_role => {:id => attribute })"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> + <% end %> +
+
+ <%= link_to t(:new_sub_role), eval("admin_#{@attribute_type}_add_sub_role_path(@attribute)"), :class => 'new' %> +
+
diff --git a/app/views/admin/roles/sub_role_field.html.erb b/app/views/admin/roles/sub_role_field.html.erb new file mode 100644 index 00000000..ed71f8b7 --- /dev/null +++ b/app/views/admin/roles/sub_role_field.html.erb @@ -0,0 +1,125 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + + <%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %> +
+ +
+

<%= @attribute.title+ t(:attributes)%> - <%= @sub_attribute.title %>

+
+ <%= render :partial=>"attribute_field",:collection=>@sub_attribute.attribute_fields%> +
+
+ +
+ +
+ <%= link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_role_add_attribute_field_path(@sub_attribute, :sub_role => {:id => @sub_attribute }),:class=>"btn btn-primary",:remote => true%> + <%#= f.hidden_field :id, :value => params[:role_id] if !params[:role_id].blank? %> + <%= hidden_field_tag 'sub_role[id]', params[:role_id] if !params[:role_id].blank? %> + <%= f.submit t(:save),:class=>"btn btn-primary"%> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + <% end %> + +<% content_for :page_specific_css do -%> + <%= stylesheet_link_tag "member" %> + <%= stylesheet_link_tag "site-map" %> +<% end %> + +<% content_for :page_specific_javascript do -%> + +<% end -%> diff --git a/app/views/admin/roles/toggle_enable.js.erb b/app/views/admin/roles/toggle_enable.js.erb new file mode 100644 index 00000000..3d42caab --- /dev/null +++ b/app/views/admin/roles/toggle_enable.js.erb @@ -0,0 +1,3 @@ +$("#enable_<%= @sub_role.id %>").toggle(); +$("#disable_<%= @sub_role.id %>").toggle(); +$("#attribute_<%= @sub_role.id %>").toggleClass('disable'); \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_role.html.erb b/app/views/admin/users_new_interface/_role.html.erb index 7d5f174c..ac04809f 100644 --- a/app/views/admin/users_new_interface/_role.html.erb +++ b/app/views/admin/users_new_interface/_role.html.erb @@ -2,10 +2,17 @@

<%= role.title %>

+ + <% role.attribute_fields.each do |rf|%> + + <%= rf.block_helper(@user,@form_index)%> + <% @form_index = @form_index +1 %> + + <% end %> - - <% role.sub_roles.each do |sub_role| %> - <% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %> + <% role.sub_roles.where(:disabled=>false).each do |sub_role| %> + <% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %> + <%# sub_role_disable = !sub_role.disabled ? false : true %> <%#= hidden_field_tag("[user][new_attribute_values][sub_role][disable][#{sub_role.id}]",sub_role_disable)%> <%= sub_role.title %> diff --git a/app/views/admin/users_new_interface/_show_roles.html.erb b/app/views/admin/users_new_interface/_show_roles.html.erb index fa4775df..0ecfb0b2 100644 --- a/app/views/admin/users_new_interface/_show_roles.html.erb +++ b/app/views/admin/users_new_interface/_show_roles.html.erb @@ -1,9 +1,16 @@
+ <%= show_roles.title %>

+ <% show_roles.attribute_fields.where(:disabled=>false).each do |rf| %> + + + + + <% end -%> <%= render :partial => 'show_sub_role',:collection=> @user.get_sub_roles_by_role(show_roles)%>
<%= rf.title %><%= show_attribute_value(@user.get_attribute_value(rf).get_value_by_locale(I18n.locale)) rescue '' %>
diff --git a/app/views/admin/users_new_interface/_side_bar.html.erb b/app/views/admin/users_new_interface/_side_bar.html.erb index d4bb74b5..651f0794 100644 --- a/app/views/admin/users_new_interface/_side_bar.html.erb +++ b/app/views/admin/users_new_interface/_side_bar.html.erb @@ -2,14 +2,16 @@ <%= link_to content_tag(:i, nil, :class => 'icons-member')+ content_tag(:span, t(:member)), admin_users_new_interface_index_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('users_new_interface')) do -%> <%= content_tag :li, link_to((t(:all_member) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_users_new_interface_index_path), :class => active_for_action('users_new_interface', 'index') %> - <%= content_tag :li, link_to((t(:add_member) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') %> - <%= content_tag :li, link_to((t(:roles) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_infos_path ), :class => active_for_action('users_new_interfacexx', 'index') %> - <%= content_tag :li, link_to((t(:info) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_roles_path), :class => active_for_action('users_new_interfacexx', 'index') %> + <%= content_tag :li, link_to((t(:add_member) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t(:roles) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_roles_path ), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t(:info) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, edit_admin_info_path('4f45f3b9e9d02c5db900002c')), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t(:authorigation) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t(:registrant) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %> <% end -%> <% end -%> <%= content_tag :li, :class => active_for_controllers('plugins') do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-pie')+ content_tag(:span, t(:plugins)), admin_plugins_path %> + <%= link_to content_tag(:i, nil, :class => 'icons-pie')+ content_tag(:span, t(:analysis)), admin_plugins_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('plugins')) do -%> <%= content_tag :li, link_to((t(:all_plugins) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_plugins_path), :class => active_for_action('users_new_interface', 'index') %> <% end -%> diff --git a/config/routes.rb b/config/routes.rb index 2c52f6ec..d682f14a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -117,7 +117,11 @@ Orbit::Application.routes.draw do end end resources :roles do + get 'role_field' + get 'sub_role_field' + get 'sub_role' get 'add_sub_role' + get 'edit_sub_role' get 'add_attribute_field' end resources :sites do From 9c8bf1ffab6a7be94b07bbd60c9a088dec5dce10 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 8 Jan 2013 17:30:36 +0800 Subject: [PATCH 3/3] Change translation --- app/helpers/attribute_fields_helper.rb | 2 +- .../shared/attribute_field/_address_modal_dialog.html.erb | 2 +- app/views/shared/attribute_field/_list_block.html.erb | 4 ++-- app/views/shared/attribute_field/_placeholder_block.html.erb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb index 2705dc8f..be1b39ee 100644 --- a/app/helpers/attribute_fields_helper.rb +++ b/app/helpers/attribute_fields_helper.rb @@ -149,7 +149,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 - content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil),:for=>key) + content_tag(:li,link_to(I18nVariable.from_locale(key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil),:for=>key) end.join.html_safe # of VALID_LOCALES.collect for tabs end # of content ul end diff --git a/app/views/shared/attribute_field/_address_modal_dialog.html.erb b/app/views/shared/attribute_field/_address_modal_dialog.html.erb index 74944a00..45a91c7e 100644 --- a/app/views/shared/attribute_field/_address_modal_dialog.html.erb +++ b/app/views/shared/attribute_field/_address_modal_dialog.html.erb @@ -9,7 +9,7 @@ <% VALID_LOCALES.each do |locale|%> <% active = (locale == I18n.locale.to_s ? ["active"] : [] ) %> <%= content_tag :li,:class=>active.push("modal_tab","address_tab").join(' '),:for=>locale do%> - <%= link_to t("langs.#{locale}"),".#{btn_class}.address_modal.#{locale}",:data=>{:toggle=>"tab"}%> + <%= link_to I18nVariable.from_locale(locale),".#{btn_class}.address_modal.#{locale}",:data=>{:toggle=>"tab"}%> <% end %> <% end %> diff --git a/app/views/shared/attribute_field/_list_block.html.erb b/app/views/shared/attribute_field/_list_block.html.erb index 18407ab9..1843a1fc 100644 --- a/app/views/shared/attribute_field/_list_block.html.erb +++ b/app/views/shared/attribute_field/_list_block.html.erb @@ -10,7 +10,7 @@ <% last = (locale == @site_valid_locales.last ? true : false) %> <% p_value = value[locale.to_s] rescue nil%> <%= content_tag :div,:class=>"input-append #{"unRadius" if last }" do%> - <%= text_field("#{field_name}[0]", locale,:placeholder=>t("langs.#{locale}")) %> + <%= text_field("#{field_name}[0]", locale,:placeholder=>I18nVariable.from_locale(locale)) %> <% if last %> <% end %> @@ -26,7 +26,7 @@ <% last = (locale == @site_valid_locales.last ? true : false) %> <% p_value = value[locale.to_s] rescue nil%> <%= content_tag :div,:class=>"input-append #{"unRadius" if last }" do%> - <%= text_field("#{field_name}[#{index}]", locale,:value=>p_value,:placeholder=>t("langs.#{locale}")) %> + <%= text_field("#{field_name}[#{index}]", locale,:value=>p_value,:placeholder=>I18nVariable.from_locale(locale)) %> <% if last %> <% end %> diff --git a/app/views/shared/attribute_field/_placeholder_block.html.erb b/app/views/shared/attribute_field/_placeholder_block.html.erb index 5654b4da..6318d7c1 100644 --- a/app/views/shared/attribute_field/_placeholder_block.html.erb +++ b/app/views/shared/attribute_field/_placeholder_block.html.erb @@ -8,7 +8,7 @@ <% active = (locale == @site_valid_locales.first ? "active in" : "'") %> <%= content_tag :div,:class=>"tab-pane fade #{active}",:id=>"#{name_to_id(field_name)}_#{locale}" do%> <% locale_value = values[locale.to_s] rescue nil%> - <%= text_field(field_name, locale,:value=>locale_value,:placeholder=>t("langs.#{locale}")) %> + <%= text_field(field_name, locale,:value=>locale_value,:placeholder=>I18nVariable.from_locale(locale)) %> <% end %> <% end %>
@@ -16,7 +16,7 @@ <% @site_valid_locales.each do |locale| %> <% active = (locale == @site_valid_locales.first ? "active" : "'") %> <%=content_tag :li,:class=>active do %> - <%= link_to t("langs.#{locale}"),"##{name_to_id(field_name)}_#{locale}",:data=>{:toggle=>"tab"}%> + <%= link_to I18nVariable.from_locale(locale),"##{name_to_id(field_name)}_#{locale}",:data=>{:toggle=>"tab"}%> <% end %> <% end %>