forked from saurabh/orbit4-5
fixed authorization bug and also added select and deselect for member selection
This commit is contained in:
parent
e320fa848d
commit
56e18cd040
|
@ -5,20 +5,52 @@ $(document).ready(function() {
|
|||
switch(authorization_type){
|
||||
case "managers":
|
||||
$("ul#card-list-submanagers li.check-item").removeClass("active");
|
||||
$("ul#card-list-submanagers li.check-item input[type=checkbox]").removeAttr("checked")
|
||||
$("ul#card-list-submanagers li.check-item input[type=checkbox]").removeAttr("checked");
|
||||
break;
|
||||
case "sub_managers":
|
||||
$("ul#card-list-managers li.check-item").removeClass("active");
|
||||
$("ul#card-list-managers li.check-item input[type=checkbox]").removeAttr("checked")
|
||||
$("ul#card-list-managers li.check-item input[type=checkbox]").removeAttr("checked");
|
||||
break;
|
||||
}
|
||||
hide_or_show_button();
|
||||
})
|
||||
|
||||
$('.selected_user input[type="checkbox"], .selected_role input[type="checkbox"]').on("change",function(){
|
||||
$(document).on("change",".selected_user input[type=checkbox], .selected_role input[type=checkbox]",function(){
|
||||
hide_or_show_button();
|
||||
})
|
||||
|
||||
$("#select_all").on("click",function(){
|
||||
switch(authorization_type){
|
||||
case "managers":
|
||||
$("ul#card-list-managers li.check-item").addClass("active");
|
||||
$("ul#card-list-managers li.check-item input[type=checkbox]").prop("checked","checked");
|
||||
break;
|
||||
case "sub_managers":
|
||||
$("ul#card-list-submanagers li.check-item").addClass("active");
|
||||
$("ul#card-list-submanagers li.check-item input[type=checkbox]").prop("checked","checked");
|
||||
break;
|
||||
}
|
||||
$(".dropup").removeClass("open");
|
||||
hide_or_show_button();
|
||||
return false;
|
||||
})
|
||||
|
||||
$("#deselect_all").on("click",function(){
|
||||
switch(authorization_type){
|
||||
case "managers":
|
||||
$("ul#card-list-managers li.check-item").removeClass("active");
|
||||
$("ul#card-list-managers li.check-item input[type=checkbox]").removeAttr("checked");
|
||||
break;
|
||||
case "sub_managers":
|
||||
$("ul#card-list-submanagers li.check-item").removeClass("active");
|
||||
$("ul#card-list-submanagers li.check-item input[type=checkbox]").removeAttr("checked");
|
||||
break;
|
||||
}
|
||||
$(".dropup").removeClass("open");
|
||||
hide_or_show_button();
|
||||
return false;
|
||||
})
|
||||
|
||||
var hide_or_show_button = function(){
|
||||
if($('.selected_role input[type="checkbox"]:checked').length == 0 && $('.selected_user input[type="checkbox"]:checked').length == 0){
|
||||
$("#remove_users").addClass("hide");
|
||||
|
@ -64,6 +96,18 @@ $(document).ready(function() {
|
|||
$(".modal").on("hidden", function () {
|
||||
$("#select_user_modal").empty();
|
||||
});
|
||||
var current_role = $("#select_user_modal .current_role a").eq(0).attr("href");
|
||||
$("#select_user_modal .current_role a").on("click",function(){
|
||||
current_role = $(this).attr("href");
|
||||
})
|
||||
$("#select_all_modal").on("click",function(){
|
||||
$(current_role).find(".check-item").addClass("active");
|
||||
$(current_role).find(".check-item input[type=checkbox]").prop("checked","checked");
|
||||
})
|
||||
$("#deselect_all_modal").on("click",function(){
|
||||
$(current_role).find(".check-item").removeClass("active");
|
||||
$(current_role).find(".check-item input[type=checkbox]").removeAttr("checked");
|
||||
})
|
||||
},
|
||||
});
|
||||
return false;
|
||||
|
@ -101,6 +145,9 @@ $(document).ready(function() {
|
|||
data: data_to_send,
|
||||
error: function(){
|
||||
alert("ERROR");
|
||||
},
|
||||
success : function(){
|
||||
hide_or_show_button();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class Admin::AuthorizationsController < OrbitAdminController
|
|||
end
|
||||
|
||||
def remove_users
|
||||
@users = User.find(params[:ids]) rescue []
|
||||
@users = User.find(params[:user_ids]) rescue []
|
||||
unless @users.blank?
|
||||
authorization = @users.map {|u| remove_authorizations(u)}.first
|
||||
end
|
||||
|
@ -147,7 +147,7 @@ class Admin::AuthorizationsController < OrbitAdminController
|
|||
|
||||
|
||||
def reload_users
|
||||
@managers = @module_app.module_managers rescue []
|
||||
@managers = @module_app.managers rescue []
|
||||
@sub_managers = @module_app.sub_managers rescue []
|
||||
manager_roles = @module_app.role_managers.collect{|r| Role.find(r)} rescue []
|
||||
sub_manager_roles = @module_app.role_sub_managers rescue []
|
||||
|
|
|
@ -115,6 +115,12 @@ class ModuleApp
|
|||
authorized_users.inject(users_authorized_by_role, :<<) rescue []
|
||||
end
|
||||
|
||||
|
||||
def managers
|
||||
Authorization.module_authorized_users(self).map{|a| a.user}
|
||||
end
|
||||
|
||||
|
||||
def data_count
|
||||
get_registration.get_data_count
|
||||
end
|
||||
|
|
|
@ -69,6 +69,16 @@
|
|||
<!-- footer -->
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<div class="btn-group dropup">
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Select
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" id="select_all"><i class="icon-ok"></i> Select All</a></li>
|
||||
<li><a href="#" id="deselect_all"><i class="icon-remove"></i> De-select All</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + ' ' + t(:add), '#', class: 'btn btn-primary select_user_modal', rel: modal_select_authorizations_path(@module_app.key, @type, @object) %>
|
||||
<%= link_to content_tag(:i, nil, class: "icon-trash") + ' ' + t(:delete_), '#', id: 'remove_users', class: 'btn btn-danger hide', rel: remove_users_authorizations_path(@module_app.key, @type, @object) %>
|
||||
</div>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<ul class="nav nav-tabs">
|
||||
<% i = 0 %>
|
||||
<% @sorted_users.each_key do |role| %>
|
||||
<li class="<%= i == 0 ? 'active' : '' %>"><a href="#r_<%= role.id %>" data-toggle="tab"><%= role.title %></a></li>
|
||||
<li class="current_role <%= i == 0 ? 'active' : '' %>"><a href="#r_<%= role.id %>" data-toggle="tab"><%= role.title %></a></li>
|
||||
<% i = i + 1 %>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
@ -72,6 +72,16 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<div class="btn-group dropup" style="text-align:left;">
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Select
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" id="select_all_modal"><i class="icon-ok"></i> Select All</a></li>
|
||||
<li><a href="#" id="deselect_all_modal"><i class="icon-remove"></i> De-select All</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<button type="button" class="btn" data-dismiss="modal"><%= t(:cancel) %></button>
|
||||
<%= submit_tag t(:submit), class: "btn btn-primary" %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue