diff --git a/Gemfile b/Gemfile index f47bdcef5..b91c3b765 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,8 @@ gem 'russian', '~> 0.6.0' gem 'highline', '~> 1.6.11' gem 'rails-xmlrpc', '~> 0.3.6' # :git => 'git://github.com/chipiga/rails-xmlrpc.git' +gem 'jbuilder' + # gem 'rugged', '~> 0.16.0' gem 'grack', :git => 'git://github.com/rdblue/grack.git', :require => 'git_http' gem "grit", :git => 'git://github.com/chipiga/grit.git' diff --git a/Gemfile.lock b/Gemfile.lock index dea8e6efc..a27ac23f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,6 +63,7 @@ GEM arel (3.0.2) bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1-java) + blankslate (2.1.2.4) bluepill (0.0.60) activesupport (>= 3.0.0) daemons (~> 1.1.4, <= 1.1.6) @@ -141,6 +142,9 @@ GEM hike (1.2.1) hirb (0.6.2) i18n (0.6.0) + jbuilder (0.4.0) + activesupport (>= 3.0.0) + blankslate (>= 2.1.2.4) journey (1.0.3) jquery-rails (2.0.1) railties (>= 3.2.0, < 5.0) @@ -336,6 +340,7 @@ DEPENDENCIES haml-rails (~> 0.3.4) highline (~> 1.6.11) hirb + jbuilder jquery-rails (~> 2.0.1) mailcatcher meta-tags (~> 1.2.5) diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 1edd08e66..14040f928 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -636,6 +636,10 @@ ul.ui-autocomplete { z-index: 999 !important; } +table.dataTable { + margin: 10px 0 15px; +} + table.tablesorter tr.search th { background: none repeat scroll 0 0 #DCECFA; } diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5adf2bca1..1155e686f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -4,7 +4,13 @@ class ProjectsController < ApplicationController load_and_authorize_resource def index - @projects = Project.accessible_by(current_ability, :members).recent.paginate(:page => params[:page]) + @projects = Project.accessible_by(current_ability, :members) + + #puts prepare_list(@projects).inspect + respond_to do |format| + format.html { @projects = @projects.recent.paginate(:page => params[:page], :per_page => 25) } + format.json { @projects = prepare_list(@projects) } + end # @projects = @projects.search(params[:query]).search_order if params[:query] end @@ -78,6 +84,32 @@ class ProjectsController < ApplicationController protected + def prepare_list(projects) + res = {} + + colName = ['name'] + sort_col = params[:iSortCol_0] || 0 + sort_dir = params[:sSortDir_0] == "desc" ? 'desc' : 'asc' + order = "#{colName[sort_col.to_i]} #{sort_dir}" + + res[:total_count] = projects.count + projects = projects.where(['projects.name ILIKE ?', "%#{ params[:sSearch] }%"]) if params[:sSearch] and !params[:sSearch].empty? + res[:filtered_count] = projects.count + + projects = projects.order(order) + res[:projects] = if params[:iDisplayLength].present? + start = params[:iDisplayStart].present? ? params[:iDisplayStart].to_i : 0 + length = params[:iDisplayLength].to_i + page = start/length + 1 + + projects.paginate(:page => page, :per_page => length) + else + projects + end + + res + end + def choose_owner if params[:who_owns] == 'group' Group.find(params[:owner_id]) diff --git a/app/views/projects/_project.html.haml b/app/views/projects/_project.html.haml index 1e4891e38..f4b5c8307 100644 --- a/app/views/projects/_project.html.haml +++ b/app/views/projects/_project.html.haml @@ -2,7 +2,13 @@ %td = link_to project do .table-sort-left= image_tag visibility_icon(project.visibility) - .table-sort-right #{project.owner.uname} / #{project.name} + .table-sort-right + = link_to project.owner.uname, project.owner.class == User ? user_path(project.owner) : group_path(project.owner) #{project.owner.uname} / #{project.name} + #{ ' / ' } + = link_to project.name, project_path(project) %td.td2= project.description %td= t("layout.collaborators.role_names.#{project.relations.by_user_through_groups(current_user).first.role}") - %td.td5= link_to image_tag('x.png'), remove_user_project_path(project), :method => :delete, :confirm => t("layout.confirm") unless project.owner == current_user \ No newline at end of file + %td.td5 + - unless project.owner == current_user + = link_to remove_user_project_path(project), :method => :delete, :confirm => t("layout.confirm") do + %span.delete diff --git a/app/views/projects/_project.json.jbuilder b/app/views/projects/_project.json.jbuilder new file mode 100644 index 000000000..86c3d2723 --- /dev/null +++ b/app/views/projects/_project.json.jbuilder @@ -0,0 +1,17 @@ +json.project do |proj| + proj.visibility project.visibility.to_s + + proj.name project.name + proj.description project.description + proj.link project_path(project) + + proj.role t("layout.collaborators.role_names.#{project.relations.by_user_through_groups(current_user).first.role}").force_encoding(Encoding::UTF_8) + + proj.leave_link remove_user_project_path(project) unless project.owner == current_user + + proj.owner do |owner| + owner.name project.owner.uname + owner.type project.owner.class.to_s.underscore + owner.link project.owner.class == User ? user_path(project.owner) : group_path(project.owner) + end +end diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index 152a4a50d..9c9bb852b 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -30,6 +30,46 @@ :javascript $(document).ready(function() { + var JsonParser = function (json) { + + var firstColumn = function(row) { + var project = row.project + + var image = ''; + + var owner = '' + project.owner.name + ''; + var project = '' + project.name + ''; + + return '