user friendly revoke and delete

This commit is contained in:
Harry Bomrah 2015-08-28 17:30:12 +08:00
parent a1a24751e3
commit 081dea82ba
3 changed files with 24 additions and 4 deletions

View File

@ -34,7 +34,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
def change_access_status def change_access_status
if !request.xhr? if !request.xhr?
redirect_to admin_registered_sites_path(:page => params[:page]) redirect_to admin_registered_sites_path(:page => params[:page], :keywords => params[:keywords])
return return
end end
status = params[:status] status = params[:status]
@ -48,10 +48,26 @@ class Admin::RegisteredSitesController < OrbitAdminController
site.save site.save
end end
@table_fields = table_fields @table_fields = table_fields
@registeredsites = RegisteredSite.all.desc(:created_at).page(params[:page]).per(10) @registeredsites = RegisteredSite.all.order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag")).desc(:created_at)
@registeredsites = search_data(@registeredsites,[:title]).page(params[:page]).per(10)
# render :partial => "index" # render :partial => "index"
end end
def destroy
registeredsite = RegisteredSite.find(params[:id]) rescue nil
if !registeredsite.nil?
registeredsite.destroy
end
@table_fields = table_fields
@registeredsites = RegisteredSite.all.order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag")).desc(:created_at)
@registeredsites = search_data(@registeredsites,[:title]).page(params[:page]).per(10)
end
private private
def table_fields def table_fields
[:domain, :admin_email, :status, :category, :tags, :permission] [:domain, :admin_email, :status, :category, :tags, :permission]

View File

@ -44,10 +44,13 @@
<% if !site.site_confirmed %> <% if !site.site_confirmed %>
<a class="btn btn-success" disabled="disabled"> Grant </a> <a class="btn btn-success" disabled="disabled"> Grant </a>
<% elsif !site.access_granted %> <% elsif !site.access_granted %>
<a href="/admin/registered_site/change_access/<%= site.site_token %>?status=grant<%= "&page=#{params[:page]}" if params[:page]%>" class="btn btn-success" data-remote="true">Grant</a> <a href="/admin/registered_site/change_access/<%= site.site_token %>?status=grant<%= "&page=#{params[:page]}" if params[:page]%><%= "&keywords=#{params[:keywords]}" if params[:keywords] %>" class="btn btn-success" data-remote="true">Grant</a>
<% else %> <% else %>
<a href="/admin/registered_site/change_access/<%= site.site_token %>?status=revoke<%= "&page=#{params[:page]}" if params[:page]%>" class="btn btn-danger" data-remote="true">Revoke</a> <a href="/admin/registered_site/change_access/<%= site.site_token %>?status=revoke<%= "&page=#{params[:page]}" if params[:page]%><%= "&keywords=#{params[:keywords]}" if params[:keywords] %>" class="btn btn-warning" data-remote="true">Revoke</a>
<% end %> <% end %>
<%# if current_user.is_admin? %>
<a href="/admin/registered_sites/<%= site.id.to_s %>?s=s<%= "&page=#{params[:page]}" if params[:page]%><%= "&keywords=#{params[:keywords]}" if params[:keywords] %>" class="btn btn-danger" data-remote="true" data-method="delete"><i class="icons-trash"></i></a>
<%# end %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@ -0,0 +1 @@
$("#index_table").html("<%= j render 'index' %>");