diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index c1c24c242..85d0175cc 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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 diff --git a/app/views/layouts/_stylesheets.html.haml b/app/views/layouts/_stylesheets.html.haml index b2e58f3b8..b74e60ab4 100644 --- a/app/views/layouts/_stylesheets.html.haml +++ b/app/views/layouts/_stylesheets.html.haml @@ -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 diff --git a/app/views/repositories/_proj_list.html.haml b/app/views/repositories/_proj_list.html.haml index a326b40ed..64d8a5da8 100644 --- a/app/views/repositories/_proj_list.html.haml +++ b/app/views/repositories/_proj_list.html.haml @@ -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' diff --git a/config/locales/ru.yml b/config/locales/ru.yml index dbc4294dc..7fcd2b6c0 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -3,6 +3,16 @@ ru: previous_label: ‹ Предыдущая 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: Вы вошли как @@ -30,6 +40,7 @@ ru: not_access: Нет доступа! owner: Владелец confirm: Уверенны? + processing: Обрабатывается... downloads: title: Статистика закачек пакетов diff --git a/vendor/plugins/rails_datatables/lib/rails_datatables.rb b/vendor/plugins/rails_datatables/lib/rails_datatables.rb index 68bc52d9b..1088cb9fe 100644 --- a/vendor/plugins/rails_datatables/lib/rails_datatables.rb +++ b/vendor/plugins/rails_datatables/lib/rails_datatables.rb @@ -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", @@ -78,4 +105,4 @@ module RailsDatatables end }.join(",") end -end \ No newline at end of file +end