[close #76] Changed styles. Fixed bug with pagination.
This commit is contained in:
parent
49082c2a8d
commit
73b710ae4e
|
@ -54,7 +54,6 @@ class RepositoriesController < ApplicationController
|
|||
def add_project
|
||||
if params[:project_id]
|
||||
@project = Project.find(params[:project_id])
|
||||
# params[:project_id] = nil
|
||||
unless @repository.projects.find_by_name(@project.name)
|
||||
@repository.projects << @project
|
||||
flash[:notice] = t('flash.repository.project_added')
|
||||
|
@ -63,22 +62,27 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
redirect_to repository_path(@repository)
|
||||
else
|
||||
# if @repository.platform.platform_type == 'main'
|
||||
# @projects = Project.addable_to_repository(@repository.id).by_visibilities(['open']).paginate(:page => params[:project_page])
|
||||
# else
|
||||
# @projects = Project.addable_to_repository(@repository.id).paginate(:page => params[:project_page])
|
||||
# end
|
||||
render :projects_list
|
||||
end
|
||||
end
|
||||
|
||||
def projects_list
|
||||
owner_subquery = "
|
||||
INNER JOIN (
|
||||
SELECT id, 'User' AS type, uname
|
||||
FROM users
|
||||
UNION
|
||||
SELECT id, 'Group' AS type, uname
|
||||
FROM groups
|
||||
) AS owner
|
||||
ON projects.owner_id = owner.id AND projects.owner_type = owner.type"
|
||||
colName = ['owner.uname', 'projects.name']
|
||||
sort_col = params[:iSortCol_0] || 0
|
||||
sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc'
|
||||
order = "#{colName[sort_col.to_i]} #{sort_dir}"
|
||||
|
||||
@projects = Project.addable_to_repository(@repository.id)
|
||||
@projects = Project.joins(owner_subquery).addable_to_repository(@repository.id)
|
||||
@projects = @projects.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength])
|
||||
@projects = @projects.by_visibilities(['open']) if @repository.platform.platform_type == 'main'
|
||||
|
||||
@total_projects = @projects.count
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-#= include_stylesheets :application
|
||||
|
||||
= stylesheet_link_tag "web-app-theme/base.css", "web-app-theme/themes/default/style.css", "web-app-theme/override.css", "git/style.css"
|
||||
= stylesheet_link_tag "jquery-ui-1.8.16.custom.css"
|
||||
= stylesheet_link_tag "jquery-ui-1.8.16.custom.css", "datatable.css"
|
||||
|
||||
= yield :stylesheets
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
- columns = [{:type => 'html', :sortable => false, :searchable => false}, {:type => 'html'}, {:type => nil}]
|
||||
= raw datatable(columns, {:sort_by => "[1, 'asc']", :ajax_source => "#{url_for :controller => :repositories, :action => :projects_list, :id => @repository.id}" })
|
||||
- columns = [{:type => 'html', :searchable => false}, {:type => 'html'}, {:type => nil, :sortable => false, :searchable => false}]
|
||||
= raw datatable(columns, {:sort_by => "[1, 'asc']", :search_label => t("layout.search_by_name"), :processing => t("layout.processing"),
|
||||
:pagination_labels => {:first => t("datatables.first_label"), :previous => t("datatables.previous_label"),
|
||||
:next => t("datatables.next_label"), :last => t("datatables.last_label")},
|
||||
:empty_label => t("datatables.empty_label"),
|
||||
:info_label => t("datatables.info_label"),
|
||||
:info_empty_label => t("datatables.info_empty_label"),
|
||||
:filtered_label => t("datatables.filtered_label"),
|
||||
:ajax_source => "#{url_for :controller => :repositories, :action => :projects_list, :id => @repository.id}" })
|
||||
|
||||
%table.table.datatable
|
||||
%thead
|
||||
%tr
|
||||
%th.first= t("activerecord.attributes.user.uname")
|
||||
%th.first{:style => 'width: 80px'}= t("activerecord.attributes.user.uname")
|
||||
%th= t("activerecord.attributes.project.name")
|
||||
%th.last
|
||||
%tbody
|
||||
%br
|
||||
|
||||
= content_for :javascripts do
|
||||
= javascript_include_tag 'jquery.dataTables.min.js'
|
||||
|
|
|
@ -4,6 +4,16 @@ ru:
|
|||
next_label: Следующая ›
|
||||
page_gap: ...
|
||||
|
||||
datatables:
|
||||
previous_label: ‹ Пред.
|
||||
next_label: След. ›
|
||||
first_label: « Первая
|
||||
last_label: Последняя »
|
||||
empty_label: Нет доступных данных
|
||||
info_label: Показаны записи с _START_ по _END_ из _TOTAL_
|
||||
info_empty_label: Показаны записи с 0 по 0 из 0
|
||||
filtered_label: (отфильтровано из _MAX_)
|
||||
|
||||
layout:
|
||||
logged_in_as: Вы вошли как
|
||||
logout: Выйти
|
||||
|
@ -30,6 +40,7 @@ ru:
|
|||
not_access: Нет доступа!
|
||||
owner: Владелец
|
||||
confirm: Уверенны?
|
||||
processing: Обрабатывается...
|
||||
|
||||
downloads:
|
||||
title: Статистика закачек пакетов
|
||||
|
|
|
@ -12,6 +12,22 @@ module RailsDatatables
|
|||
auto_width = opts[:auto_width].present? ? opts[:auto_width].to_s : "true"
|
||||
row_callback = opts[:row_callback] || nil
|
||||
|
||||
empty_label = opts[:empty_label] if opts[:empty_label].present?
|
||||
info_label = opts[:info_label] if opts[:info_label].present?
|
||||
info_empty_label = opts[:info_empty_label] if opts[:info_empty_label].present?
|
||||
filtered_label = opts[:filtered_label] if opts[:filtered_label].present?
|
||||
|
||||
if opts[:pagination_labels].present?
|
||||
pagination_labels = []
|
||||
pagination_labels << "'sFirst': '#{opts[:pagination_labels][:first]}'" if opts[:pagination_labels][:first].present?
|
||||
pagination_labels << "'sLast': '#{opts[:pagination_labels][:last]}'" if opts[:pagination_labels][:last].present?
|
||||
pagination_labels << "'sPrevious': '#{opts[:pagination_labels][:previous]}'" if opts[:pagination_labels][:previous].present?
|
||||
pagination_labels << "'sNext': '#{opts[:pagination_labels][:next]}'" if opts[:pagination_labels][:next].present?
|
||||
pagination_labels = pagination_labels.join(",\n")
|
||||
else
|
||||
pagination_labels = false
|
||||
end
|
||||
|
||||
append = opts[:append] || nil
|
||||
|
||||
ajax_source = opts[:ajax_source] || nil
|
||||
|
@ -30,6 +46,17 @@ module RailsDatatables
|
|||
"oLanguage": {
|
||||
"sSearch": "#{search_label}",
|
||||
#{"'sZeroRecords': '#{no_records_message}'," if no_records_message}
|
||||
#{"
|
||||
'oPaginate': {
|
||||
#{pagination_labels}
|
||||
},
|
||||
" if pagination_labels}
|
||||
|
||||
#{"'sEmptyTable': '#{empty_label}'," if empty_label}
|
||||
#{"'sInfo': '#{info_label}'," if info_label}
|
||||
#{"'sInfoEmpty': '#{info_empty_label}'," if info_empty_label}
|
||||
#{"'sInfoFiltered': '#{filtered_label}'," if filtered_label}
|
||||
|
||||
"sProcessing": '#{processing}'
|
||||
},
|
||||
"sPaginationType": "full_numbers",
|
||||
|
|
Loading…
Reference in New Issue