From 8a79d7ff2e80cbe05b6a7533eb8d7fe56dbeb9df Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Nov 2012 10:14:43 +0800 Subject: [PATCH] member selects --- .../admin/member_selects_controller.rb | 73 +++++++++ .../desktop_publications_controller.000.rb | 75 +++++++++ .../_member_select_result.html.erb | 40 +++++ .../_member_select_result_add.html.erb | 29 ++++ app/views/admin/member_selects/index.html.erb | 153 ++++++++++++++++++ .../member_selects/member_select_add.js.erb | 5 + .../member_select_result.html.erb | 40 +++++ .../member_select_search.js.erb | 4 + config/routes.rb | 5 + 9 files changed, 424 insertions(+) create mode 100644 app/controllers/admin/member_selects_controller.rb create mode 100644 app/controllers/desktop_publications_controller.000.rb create mode 100644 app/views/admin/member_selects/_member_select_result.html.erb create mode 100644 app/views/admin/member_selects/_member_select_result_add.html.erb create mode 100644 app/views/admin/member_selects/index.html.erb create mode 100644 app/views/admin/member_selects/member_select_add.js.erb create mode 100644 app/views/admin/member_selects/member_select_result.html.erb create mode 100644 app/views/admin/member_selects/member_select_search.js.erb diff --git a/app/controllers/admin/member_selects_controller.rb b/app/controllers/admin/member_selects_controller.rb new file mode 100644 index 00000000..a8ec1097 --- /dev/null +++ b/app/controllers/admin/member_selects_controller.rb @@ -0,0 +1,73 @@ +class Admin::MemberSelectsController < ApplicationController + + layout "new_admin" + + def index + + # @member_selects = OrbitApp::Module::Role.all + @member_selects = Role.excludes('disabled' => true) + + if(!params[:show_plugin_profile].nil?) + @right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' + else + @right_partial = "admin/users_new_interface/plugin_summary" + end + + @member_select_results = Role.excludes('disabled' => true) + @member_select_search_url = admin_member_selects_path + + + # @aa = User.where(:role_ids.in => [ "4f45f3b9e9d02c5db900001c"]) + + end + + # def show + + # @aa = admin_member_selects_path + + + # respond_to do |format| + # format.js{ render 'member_select_search' } + # end + + # end + + def member_select_add + + # @users = User.where(:ids.in => [params[:users].collect{|x| x[0]}]) + @users = params[:users].collect{|key,value| User.find key } rescue [] + # debugger + respond_to do |format| + format.js + end + + end + + def member_select_search + + @pdatas = params[:member_selects] + + @users = Role.excludes('disabled' => true) + + + # debugger + + # User.where(:role_ids.in => [ "4f45f3b9e9d02c5db900001c"]) + + # @users = User.where(:role_ids.in => [ "your role_id"]) + # @users.where(:sub_role_ids.in => [id, id, id]) + + + # @member_select_results = Role.excludes('disabled' => true) + @member_select_results = User.where(:sub_role_ids.in => params[:member_selects][:sub_role]) + + @member_select_search_url = admin_member_select_member_select_add_path('member_select_add') + + + respond_to do |format| + format.js + end + + end + +end diff --git a/app/controllers/desktop_publications_controller.000.rb b/app/controllers/desktop_publications_controller.000.rb new file mode 100644 index 00000000..fc3f36ab --- /dev/null +++ b/app/controllers/desktop_publications_controller.000.rb @@ -0,0 +1,75 @@ +class DesktopPublicationsController< ApplicationController + def journal_p + render "desktop/journal_p", :layout => false + end + + def journal_p_list + render "desktop/journal_pages/list", :layout => false + end + + def journal_p_add + debugger + render "desktop/journal_pages/add", :layout => false + end + + def books + render "desktop/books", :layout => false + end + + def books_list + render "desktop/books/list", :layout => false + end + + def books_add + render "desktop/books/add", :layout => false + end + + def seminar_p + render "desktop/seminar_p", :layout => false + end + + def seminar_p_list + render "desktop/seminar_pages/list", :layout => false + end + + def seminar_p_add + render "desktop/seminar_pages/add", :layout => false + end + + def create_journal + Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich") + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def getjournals + @journals = current_user.journals + data = Array.new + @journals.each do |journal| + @papers = journal.papers.all + data << {"title" => journal.title, "papers" => @papers} + end + render :json=>data.to_json + end + + def delete_journal + @journals = Journal.find("") + @journals.delete + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def update_journal + @journal = Journal.find("4ff2d6ebbd98eb02b9000017") + @papers = @journal.papers + @papers.each do |paper| + paper.update_attributes(:user_id => current_user.id) + end + b = Array.new + + b << {"success"=>"true"} + render :json=>b.to_json + end +end diff --git a/app/views/admin/member_selects/_member_select_result.html.erb b/app/views/admin/member_selects/_member_select_result.html.erb new file mode 100644 index 00000000..6b38328d --- /dev/null +++ b/app/views/admin/member_selects/_member_select_result.html.erb @@ -0,0 +1,40 @@ +<% # encoding: utf-8 %> + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + + + + + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/_member_select_result_add.html.erb b/app/views/admin/member_selects/_member_select_result_add.html.erb new file mode 100644 index 00000000..2a032e38 --- /dev/null +++ b/app/views/admin/member_selects/_member_select_result_add.html.erb @@ -0,0 +1,29 @@ +<% # encoding: utf-8 %> + + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + <% @users.each do |users| %> + +
+
+
+
+ + <% if users.avatar? %> + <%= image_tag(users.avatar.thumb.url,:class => "member-img") %> + <% else %> + <%= image_tag "person.png",:class => "member-img" %> + <% end %> + +
+ <%= label_tag "lab-user-#{users.id}", (users.name rescue ''),:class=>"member-name",:id=>nil -%> + <%= check_box_tag "[users][#{users.id}]", 'true', true,:class => "check" -%> +
+
+ + <% end %> + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/index.html.erb b/app/views/admin/member_selects/index.html.erb new file mode 100644 index 00000000..bcc83e2e --- /dev/null +++ b/app/views/admin/member_selects/index.html.erb @@ -0,0 +1,153 @@ +<% # encoding: utf-8 %> + + + + + + <% #results %> + +
+ + +
+ +
+
+
+
+ Person +
+ + +
+
+
+ +
+ +
+ + +
+ + <% #results %> + + + + + + <% #search %> + +
+ +
+ + +<% content_for :page_specific_javascript do %> + + <%= stylesheet_link_tag "inc/permission-checkbox" %> + <%= javascript_include_tag "inc/permission-checkbox" %> + + + +<% end %> + + \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_add.js.erb b/app/views/admin/member_selects/member_select_add.js.erb new file mode 100644 index 00000000..e1414d34 --- /dev/null +++ b/app/views/admin/member_selects/member_select_add.js.erb @@ -0,0 +1,5 @@ +$("#users_checkbox_ary").html("<%= j render "member_select_result_add" %>"); +$("#search-results").modal('hide'); +$(document).ready(function() { +permissionCheckbox(); +}); \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_result.html.erb b/app/views/admin/member_selects/member_select_result.html.erb new file mode 100644 index 00000000..aebb9331 --- /dev/null +++ b/app/views/admin/member_selects/member_select_result.html.erb @@ -0,0 +1,40 @@ +<% # encoding: utf-8 %> +<% debugger %> + +<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'} , :url => @member_select_search_url ) do |f| %> + + + + + + + +<% end %> + \ No newline at end of file diff --git a/app/views/admin/member_selects/member_select_search.js.erb b/app/views/admin/member_selects/member_select_search.js.erb new file mode 100644 index 00000000..deca2586 --- /dev/null +++ b/app/views/admin/member_selects/member_select_search.js.erb @@ -0,0 +1,4 @@ +$("#search-results").html("<%= j render "member_select_result" %>"); +$(document).ready(function() { +permissionCheckbox(); +}); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6b328019..9b584ebe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -132,6 +132,11 @@ Orbit::Application.routes.draw do get 'temp_edit' end end + + resources :member_selects do + match 'member_select_search' => "member_selects#member_select_search" ,:as => :member_select_search,:via => "post" + match 'member_select_add' => "member_selects#member_select_add" ,:as => :member_select_add,:via => "post" + end end # end admin