member selects

This commit is contained in:
unknown 2012-11-26 10:14:43 +08:00
parent 12f5d93e1a
commit 1f0287dd7e
9 changed files with 424 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body clear">
<% @member_select_results.each do |results| %>
<div class="checkblock">
<div class='checkbox clear'>
<div class="check-icon"></div>
<div class="member-avatar">
<% if results.avatar? %>
<%= image_tag(results.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{results.id}", (results.name rescue ''),:class=>"member-name",:id=>nil -%>
<%= check_box_tag "[users][#{results.id}]", 'true', true, :class => "check" -%>
</div>
</div>
<% end %>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary"><i class="icon-plus"></i> Add</button>
</div>
<% end %>

View File

@ -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| %>
<div class="checkblock">
<div class='checkbox clear'>
<div class="check-icon"></div>
<div class="member-avatar">
<% if users.avatar? %>
<%= image_tag(users.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{users.id}", (users.name rescue ''),:class=>"member-name",:id=>nil -%>
<%= check_box_tag "[users][#{users.id}]", 'true', true,:class => "check" -%>
</div>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,153 @@
<% # encoding: utf-8 %>
<div class="subnav">
<%= form_for('member_select_search', :remote => true, :html => { :id => 'member_select_search', :class => 'member_select_search'}, :url => admin_member_select_member_select_search_path('member_select_search') ) do |f| %>
<div id="accordion">
<ul class="nav nav-pills filter">
<% @member_selects.each do |member_select| %>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#<%= member_select.key -%>" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= member_select.title -%> <b class="web-symbol"></b></a>
</div>
</li>
<% end -%>
</ul>
<div class="accordion-group filters">
<% @member_selects.each do |member_select| %>
<div class="accordion-body collapse form-horizontal" id="<%= member_select.key -%>">
<div class="accordion-inner">
<div class="control-group">
<label class="control-label" for="">類別</label>
<div class="controls">
<% member_select.sub_roles.each do |sub_role| %>
<label class="checkbox inline">
<input type="checkbox" name="member_selects[sub_role][]" value="<%= sub_role.id -%>"> <%= sub_role.title -%>
</label>
<% end %>
<label class="checkbox inline">
<a class="select-all" href="#"><i class="icon-ok"></i></a> <a class="cancel-all" href="#"><i class="icon-remove"></i></a>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">狀態</label>
<div class="controls">
<% member_select.statuses.each do |status| %>
<label class="checkbox inline">
<input type="checkbox" name="member_selects[status][]" value="<%= status.id -%>"> <%= status.title -%>
</label>
<% end %>
<label class="checkbox inline">
<a class="select-all" href="#"><i class="icon-ok"></i></a> <a class="cancel-all" href="#"><i class="icon-remove"></i></a>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">關鍵字搜尋</label>
<div class="controls">
<input type="text" data-provide="typeahead" data-items="4" name="member_selects[keyword][<%= member_select.id -%>][]">
</div>
</div>
</div>
<div class="filter-clear">
<a href="#" class="btn btn-success btn-small"><i class="icon-plus"></i> Add</a>
<a data-toggle="modal" href="#search-results" class="btn btn-primary btn-small" data-remote="true" onclick="$('#member_select_search').submit();"><i class="icon-search"></i> Search</a>
</div>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
<% #results %>
<div id="member_select_result_add">
<div class="clear" id="users_checkbox_ary">
<div class="checkblock">
<div class="checkbox clear checked">
<div class="check-icon"></div>
<div class="member-avatar">
<img alt="Person" class="member-img" src="images/menber-pic.png">
</div>
<label class="member-name" for="lab-user-4f45f3b9e9d02c5db900006d">儒淵 傅</label>
<input checked="checked" class="check" type="checkbox" value="true">
</div>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<input class="btn btn-primary" name="commit" type="submit" value="Update">
</div>
</div>
<% #results %>
</div>
<% #search %>
<div id="member_select_result">
<div id="search-results" class="search-results modal hide fade" tabindex="1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<%#= render :partial => "member_select_search" %>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= stylesheet_link_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<script type="text/javascript">
$("#more").click(function() {
$("#member_select_search").submit();
}
$(document).ready(function(){
$('.select-all').click(function() {
$(this).each(function() {
$(this).parents('label').prevAll('label').find('input').attr({checked:'checked'})
})
});
$('.cancel-all').click(function() {
$(this).each(function() {
$(this).parents('label').prevAll('label').find('input').removeAttr('checked')
})
});
});
</script>
<% end %>

View File

@ -0,0 +1,5 @@
$("#users_checkbox_ary").html("<%= j render "member_select_result_add" %>");
$("#search-results").modal('hide');
$(document).ready(function() {
permissionCheckbox();
});

View File

@ -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| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body clear">
<div class="checkblock">
<div class='checkbox clear'>
<div class="check-icon"></div>
<div class="member-avatar">
<img src="images/menber-pic.png" class="member-img" />
</div>
<label class="member-name">Ray Chang</label>
<input class="check" type="checkbox" name="[users][4f45f3b9e9d02c5db9000067]" value="true" />
</div>
</div>
<div class="checkblock">
<div class="checkbox clear checked">
<div class="check-icon"></div>
<div class="member-avatar">
<img alt="Person" class="member-img" src="images/menber-pic.png">
</div>
<label class="member-name" for="lab-user-4f45f3b9e9d02c5db900006d">儒淵 傅</label>
<input checked="checked" class="check" type="checkbox" value="true">
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary"><i class="icon-plus"></i> Add</button>
</div>
<% end %>

View File

@ -0,0 +1,4 @@
$("#search-results").html("<%= j render "member_select_result" %>");
$(document).ready(function() {
permissionCheckbox();
});

View File

@ -133,6 +133,11 @@ Orbit::Application.routes.draw do
get 'temp_edit' get 'temp_edit'
end end
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
# end admin # end admin