diff --git a/app/assets/javascripts/lib/member/registration_approval.js b/app/assets/javascripts/lib/member/registration_approval.js new file mode 100644 index 00000000..6dcc7283 --- /dev/null +++ b/app/assets/javascripts/lib/member/registration_approval.js @@ -0,0 +1,55 @@ +jQuery(document).ready(function($) { + + var selectAll = $( "#select_all_registration" ), + checkboxes = $( "input.select-this" ), + selectedBtns = $( "a.selected-actions" ); + + selectAll.bind(clickEvent,function(){ + + if( $( this ).is( ":checked" ) ){ + checkboxes.prop( "checked", true ); + selectedBtns.removeClass('hide'); + }else{ + checkboxes.prop( "checked", false ); + selectedBtns.addClass('hide'); + } + + }); + + checkboxes.bind(clickEvent,function(){ + var checkedCheckboxes = $( "input.select-this:checked" ); + if( checkboxes.length == checkedCheckboxes.length ){ + selectAll.prop( "checked", true ); + }else{ + selectAll.prop( "checked", false ); + } + + (checkedCheckboxes.length > 0 ? selectedBtns.removeClass('hide') : selectedBtns.addClass('hide')); + }); + + selectedBtns.bind(clickEvent,function(){ + if( confirm("Are you sure?") ){ + var userids = [], + _this = $( this ), + checkedCheckboxes = $( "input.select-this:checked" ); + + checkedCheckboxes.each(function(){ + userids.push( $( this ).val() ); + }) + + $.ajax({ + url : _this.attr("href"), + type : "post", + dataType : "json", + data : {"userids" : userids}, + success : function(data){ + if( data.success == true){ + window.location.href = data.url; + } + } + }) + } + return false; + }) + +}); \ No newline at end of file diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index c5a569dd..4d621269 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -13,16 +13,39 @@ class Admin::UsersNewInterfaceController < OrbitMemberController end def approve_registration - user = User.find(params[:users_new_interface_id]) - user.approved = true - user.save - desk = user.desktop - desk.theme = DesktopTheme.first.id.to_s - desk.wallpaper = nil - desk.save! + approve_method params[:users_new_interface_id] redirect_to admin_users_new_interface_registration_approval_path end + def approve_method(user_id = nil) + if !user_id.nil? + user = User.find(user_id) + user.approved = true + user.save + desk = user.desktop + desk.theme = DesktopTheme.first.id.to_s + desk.wallpaper = nil + desk.save! + end + end + + def approve_selected + users = params[:userids] + users.each do |user| + approve_method user + end + render :json => {"success"=>true,"url"=>admin_users_new_interface_registration_approval_path} + end + + def delete_selected + users = params[:userids] + users.each do |user| + u = User.find(user) + u.destroy + end + render :json => {"success"=>true,"url"=>admin_users_new_interface_registration_approval_path} + end + def index get_tags get_sub_roles @@ -345,6 +368,11 @@ class Admin::UsersNewInterfaceController < OrbitMemberController flash[:error] = t(:cant_delete_self) else @user = User.find(params[:id]) + @not_approved_count = nil + if !@user.approved + @not_approved_count = User.not_guest_and_approved_user.count - 1 + end + @user.destroy end diff --git a/app/views/admin/users_new_interface/_not_approved_listing.html.erb b/app/views/admin/users_new_interface/_not_approved_listing.html.erb index 2a53aceb..ac139e0d 100644 --- a/app/views/admin/users_new_interface/_not_approved_listing.html.erb +++ b/app/views/admin/users_new_interface/_not_approved_listing.html.erb @@ -9,6 +9,7 @@ %> + <% not_approved_listing.roles.each do |rf| %> <% @roledata = Role.find(rf.id) %> 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 115d064b..500179d3 100644 --- a/app/views/admin/users_new_interface/_side_bar.html.erb +++ b/app/views/admin/users_new_interface/_side_bar.html.erb @@ -29,7 +29,7 @@ <%= content_tag :li, link_to((content_tag(:span, t(:all_member))), admin_users_new_interface_index_path), :class => active_for_action('users_new_interface', 'index') %> <%= content_tag :li, link_to((content_tag(:span, t(:add_member))), new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') if (is_admin? rescue nil) %> <%= content_tag :li, link_to((content_tag(:span, t(:member_authorization))), '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %> - <%= content_tag :li, link_to((content_tag(:span, t(:member_registration))), admin_users_new_interface_registration_approval_path), :class => active_for_action('users_new_interface', 'registration_approval') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((content_tag(:span, t(:member_registration)) + (User.not_guest_and_approved_user.count > 0 ? content_tag(:span,"(#{User.not_guest_and_approved_user.count})",:style=>"margin-left:3px;", :id=>"registration_count") : "")), admin_users_new_interface_registration_approval_path), :class => active_for_action('users_new_interface', 'registration_approval') if (is_admin? rescue nil) %> <%= content_tag :li, link_to((content_tag(:span, t(:member_role))),admin_roles_path ), :class => active_for_action('roles', 'index') if (is_admin? rescue nil) %> <%= content_tag :li, link_to((content_tag(:span, t(:member_info))), edit_admin_info_path(Info.first.id.to_s)), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) and Info.first %> <% end -%> diff --git a/app/views/admin/users_new_interface/destroy.js.erb b/app/views/admin/users_new_interface/destroy.js.erb index 86982ae1..4770c925 100644 --- a/app/views/admin/users_new_interface/destroy.js.erb +++ b/app/views/admin/users_new_interface/destroy.js.erb @@ -1 +1,8 @@ -$("#<%= dom_id @user %>").remove(); \ No newline at end of file +$("#<%= dom_id @user %>").remove(); +<% if !@not_approved_count.nil? %> + <% if @not_approved_count > 0 %> + $("#registration_count").text("(<%= @not_approved_count %>)"); + <% else %> + $("#registration_count").remove(); + <% end %> +<% end %> diff --git a/app/views/admin/users_new_interface/registration_approval.html.erb b/app/views/admin/users_new_interface/registration_approval.html.erb index f7d087b6..1053124b 100644 --- a/app/views/admin/users_new_interface/registration_approval.html.erb +++ b/app/views/admin/users_new_interface/registration_approval.html.erb @@ -3,12 +3,13 @@ <% end %> <%= render :partial => "js_and_css"%> - +<%= javascript_include_tag "lib/member/registration_approval" %>
+ @@ -18,12 +19,18 @@ <% if !@users.blank? %> <%= render :partial => "not_approved_listing",:collection=> @users %> <% else %> - + <% end %>
Select All Roles Name Email
Hooray! No pending registration approvals left.
Hooray! No pending registration approvals left.
+
+ <% if !@users.blank? %> + Delete Selected + Approve Selected + <% end -%> +
diff --git a/config/routes.rb b/config/routes.rb index 6fcbf460..dedbc744 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -223,6 +223,8 @@ Orbit::Application.routes.draw do resources :users match "users_new_interface/registration_approval" => "users_new_interface#registration_approval" + match "users_new_interface/approve_selected" => "users_new_interface#approve_selected" + match "users_new_interface/delete_selected" => "users_new_interface#delete_selected" resources :users_new_interface do member do