[issue #586] Custom JSON generators changed to JBuilder
This commit is contained in:
parent
606609dea6
commit
03cc4668dc
|
@ -76,7 +76,10 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
||||||
@projects = Project.joins(owner_subquery).addable_to_repository(@repository.id)
|
@projects = Project.joins(owner_subquery).addable_to_repository(@repository.id)
|
||||||
@projects = @projects.by_visibilities('open') if @repository.platform.platform_type == 'main'
|
@projects = @projects.by_visibilities('open') if @repository.platform.platform_type == 'main'
|
||||||
end
|
end
|
||||||
@projects = @projects.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength])
|
@projects = @projects.paginate(
|
||||||
|
:page => (params[:iDisplayStart].to_i/(params[:iDisplayLength].present? ? params[:iDisplayLength] : 25).to_i).to_i + 1,
|
||||||
|
:per_page => params[:iDisplayLength].present? ? params[:iDisplayLength] : 25
|
||||||
|
)
|
||||||
|
|
||||||
@total_projects = @projects.count
|
@total_projects = @projects.count
|
||||||
@projects = @projects.search(params[:sSearch]).search_order if params[:sSearch].present?
|
@projects = @projects.search(params[:sSearch]).search_order if params[:sSearch].present?
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"sEcho": <%=h params[:sEcho].to_i || -1 %>,
|
|
||||||
"iTotalRecords": <%= @total_users %>,
|
|
||||||
"iTotalDisplayRecords": <%= @total_user %>,
|
|
||||||
"aaData": [
|
|
||||||
<% @users.each do |user| %>
|
|
||||||
[
|
|
||||||
"<%= user.name %>",
|
|
||||||
"<%= user.uname %>",
|
|
||||||
"<%= user.email %>",
|
|
||||||
"<span style='<%=user.access_locked? ? 'background: #FEDEDE' : ''%>'><%= user.role %></span>",
|
|
||||||
"<%= j raw [(link_to t('layout.show'), user if can? :read, user),
|
|
||||||
(link_to t('layout.edit'), edit_admin_user_path(user) if can? :edit, user),
|
|
||||||
(link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user)
|
|
||||||
].compact.join(' | ') %>"
|
|
||||||
]<%= user == @users.last ? '' : ',' %>
|
|
||||||
<% end %>
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
users = @users.map do |user|
|
||||||
|
link_block = [
|
||||||
|
(link_to t('layout.show'), user if can? :read, user),
|
||||||
|
(link_to t('layout.edit'), edit_admin_user_path(user) if can? :edit, user),
|
||||||
|
(link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user)
|
||||||
|
].compact.join(' | ').html_safe
|
||||||
|
|
||||||
|
[
|
||||||
|
user.name,
|
||||||
|
user.uname,
|
||||||
|
user.email,
|
||||||
|
content_tag(:span, user.role, :style => user.access_locked? ? 'background: #FEDEDE' : ''),
|
||||||
|
link_block
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
json.sEcho params[:sEcho].to_i || -1
|
||||||
|
json.iTotalRecords @total_users
|
||||||
|
json.iTotalDisplayRecords @total_user
|
||||||
|
json.aaData users
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"sEcho": <%=h params[:sEcho].to_i || -1 %>,
|
|
||||||
"iTotalRecords": <%= @total_projects %>,
|
|
||||||
"iTotalDisplayRecords": <%= @total_project %>,
|
|
||||||
"aaData": [
|
|
||||||
<% @projects.each do |project| %>
|
|
||||||
[
|
|
||||||
"<%=j link_to(project.name_with_owner, project) %>",
|
|
||||||
"<%= truncate(project.description || '', :length => 60).gsub(/\n|\r|\t/, ' ') %>",
|
|
||||||
"<%=j link_to t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id) %>"
|
|
||||||
]<%= project == @projects.last ? '' : ',' %>
|
|
||||||
<% end %>
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
projs = @projects.map do |project|
|
||||||
|
[
|
||||||
|
link_to(project.name_with_owner, project),
|
||||||
|
truncate(project.description || '', :length => 60).gsub(/\n|\r|\t/, ' '),
|
||||||
|
link_to(t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id))
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
json.sEcho params[:sEcho] || -1
|
||||||
|
json.iTotalRecords @total_projects
|
||||||
|
json.iTotalDisplayRecords @total_project
|
||||||
|
json.aaData projs
|
|
@ -1,31 +0,0 @@
|
||||||
{
|
|
||||||
"sEcho": <%=h params[:sEcho].to_i || -1 %>,
|
|
||||||
"iTotalRecords": <%= @total_projects %>,
|
|
||||||
"iTotalDisplayRecords": <%= @total_project %>,
|
|
||||||
"aaData": [
|
|
||||||
<% @projects.each do |project| %>
|
|
||||||
[
|
|
||||||
"<%=(
|
|
||||||
"<div class='table-sort-left'>" +
|
|
||||||
j(image_tag(visibility_icon(project.visibility))) +
|
|
||||||
"</div>" +
|
|
||||||
"<div class='table-sort-right'>" +
|
|
||||||
j(link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project)) +
|
|
||||||
"</div>").html_safe
|
|
||||||
%>",
|
|
||||||
"<%= truncate(project.description || '', :length => 60).gsub(/\n|\r|\t/, ' ') %>",
|
|
||||||
"<%=
|
|
||||||
if can? :remove_project, @repository
|
|
||||||
j(link_to('<span class="delete"> </span>'.html_safe,
|
|
||||||
remove_project_platform_repository_path(@platform, @repository, :project_id => project.id),
|
|
||||||
:method => :delete, :confirm => t("layout.confirm")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else
|
|
||||||
''
|
|
||||||
end
|
|
||||||
%>"
|
|
||||||
]<%= project == @projects.last ? '' : ',' %>
|
|
||||||
<% end %>
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
projs = @projects.map do |pr|
|
||||||
|
[
|
||||||
|
content_tag(:div, image_tag(visibility_icon(pr.visibility)), :class => 'table-sort-left') +
|
||||||
|
content_tag(:div, link_to(pr.name_with_owner, pr), :class => 'table-sort-right'),
|
||||||
|
|
||||||
|
truncate(pr.description || '', :length => 60).gsub(/\n|\r|\t/, ' '),
|
||||||
|
|
||||||
|
if can? :remove_project, @repository
|
||||||
|
link_to(
|
||||||
|
remove_project_platform_repository_path(@platform, @repository, :project_id => pr.id),
|
||||||
|
:method => :delete, :confirm => t("layout.confirm")) do
|
||||||
|
content_tag(:span, " ".html_safe, :class => 'delete')
|
||||||
|
end
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
json.sEcho params[:sEcho].to_i || -1
|
||||||
|
json.iTotalRecords @total_projects
|
||||||
|
json.iTotalDisplayRecords @total_project
|
||||||
|
json.aaData projs
|
Loading…
Reference in New Issue