From 9fddd5b440105376caf913e1c09756ec2aaf4431 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Sat, 6 Apr 2013 22:32:23 +0300
Subject: [PATCH] Refactoring & restyle pagination: - remove admin kaminari
 theme. Use gitlab theme everywhere - use bootstrap styled for gitlab admin
 themes - dont reload page when change issue filter

---
 app/assets/javascripts/issues.js              |  2 +-
 .../stylesheets/gitlab_bootstrap/common.scss  |  7 ----
 app/assets/stylesheets/sections/issues.scss   |  2 +-
 app/views/admin/groups/index.html.haml        |  2 +-
 app/views/admin/projects/index.html.haml      |  4 +-
 app/views/admin/teams/index.html.haml         |  2 +-
 app/views/admin/users/index.html.haml         |  3 +-
 app/views/issues/_issues.html.haml            | 39 ++++++++++++++-----
 app/views/issues/index.html.haml              | 26 +------------
 app/views/issues/index.js.haml                |  4 +-
 .../kaminari/admin/_first_page.html.haml      |  9 -----
 app/views/kaminari/admin/_gap.html.haml       |  9 -----
 app/views/kaminari/admin/_last_page.html.haml |  9 -----
 app/views/kaminari/admin/_next_page.html.haml |  9 -----
 app/views/kaminari/admin/_page.html.haml      | 10 -----
 app/views/kaminari/admin/_paginator.html.haml | 17 --------
 app/views/kaminari/admin/_prev_page.html.haml |  9 -----
 app/views/kaminari/gitlab/_gap.html.haml      |  5 ++-
 .../kaminari/gitlab/_next_page.html.haml      |  2 +-
 app/views/kaminari/gitlab/_page.html.haml     |  4 +-
 .../kaminari/gitlab/_paginator.html.haml      | 17 ++++----
 .../kaminari/gitlab/_prev_page.html.haml      |  2 +-
 app/views/merge_requests/index.html.haml      | 10 ++---
 app/views/public/projects/index.html.haml     |  2 +-
 24 files changed, 63 insertions(+), 142 deletions(-)
 delete mode 100644 app/views/kaminari/admin/_first_page.html.haml
 delete mode 100644 app/views/kaminari/admin/_gap.html.haml
 delete mode 100644 app/views/kaminari/admin/_last_page.html.haml
 delete mode 100644 app/views/kaminari/admin/_next_page.html.haml
 delete mode 100644 app/views/kaminari/admin/_page.html.haml
 delete mode 100644 app/views/kaminari/admin/_paginator.html.haml
 delete mode 100644 app/views/kaminari/admin/_prev_page.html.haml

diff --git a/app/assets/javascripts/issues.js b/app/assets/javascripts/issues.js
index 9ba1a3f1bba..852402227f6 100644
--- a/app/assets/javascripts/issues.js
+++ b/app/assets/javascripts/issues.js
@@ -12,7 +12,7 @@ function initIssuesSearch() {
 
       if (terms.length >= 2 || terms.length == 0) {
         $.get(href, { 'status': status, 'terms': terms, 'milestone_id': milestone_id }, function(response) {
-          $('#issues-table').html(response);
+          $('.issues-holder').html(response);
         });
       }
     }
diff --git a/app/assets/stylesheets/gitlab_bootstrap/common.scss b/app/assets/stylesheets/gitlab_bootstrap/common.scss
index f061b5df70b..3ec03b96434 100644
--- a/app/assets/stylesheets/gitlab_bootstrap/common.scss
+++ b/app/assets/stylesheets/gitlab_bootstrap/common.scss
@@ -69,13 +69,6 @@ fieldset legend { font-size: 17px; }
 
 /** PAGINATION **/
 .gitlab_pagination {
-  span a { color: $link_color; }
-  .prev, .next, .current, .page a {
-    padding: 10px;
-  }
-  .current {
-    border-bottom: 2px solid $style_color;
-  }
 }
 
 .tab-content {
diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss
index 31d5c56bc6c..5a1b476fe25 100644
--- a/app/assets/stylesheets/sections/issues.scss
+++ b/app/assets/stylesheets/sections/issues.scss
@@ -77,7 +77,7 @@ input.check_all_issues {
 @media (min-width: 800px)  { .issues_bulk_update select { width: 120px; }  }
 @media (min-width: 1200px) { .issues_bulk_update select { width: 160px; }  }
 
-#issues-table-holder {
+.issues-holder {
   .issues_filters {
   }
 
diff --git a/app/views/admin/groups/index.html.haml b/app/views/admin/groups/index.html.haml
index 0029cc78e3e..08d99411bfc 100644
--- a/app/views/admin/groups/index.html.haml
+++ b/app/views/admin/groups/index.html.haml
@@ -34,4 +34,4 @@
       %td.bgred
         = link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn btn-small"
         = link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove"
-= paginate @groups, theme: "admin"
+= paginate @groups, theme: "gitlab"
diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml
index 82d5fdcd7dd..aa006dfc997 100644
--- a/app/views/admin/projects/index.html.haml
+++ b/app/views/admin/projects/index.html.haml
@@ -56,6 +56,4 @@
               = link_to 'Destroy', [project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove"
         - if @projects.blank?
           %p.nothing_here_message 0 projects matches
-        - else
-          %li.bottom
-            = paginate @projects, theme: "gitlab"
+    = paginate @projects, theme: "gitlab"
diff --git a/app/views/admin/teams/index.html.haml b/app/views/admin/teams/index.html.haml
index 3690d6d9eb4..225ad166774 100644
--- a/app/views/admin/teams/index.html.haml
+++ b/app/views/admin/teams/index.html.haml
@@ -40,4 +40,4 @@
         = link_to 'Edit', edit_admin_team_path(team), id: "edit_#{dom_id(team)}", class: "btn btn-small"
         = link_to 'Destroy', admin_team_path(team), confirm: "REMOVE #{team.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove"
 
-= paginate @teams, theme: "admin"
+= paginate @teams, theme: "gitlab"
diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml
index 9da2871e992..3657f660c9b 100644
--- a/app/views/admin/users/index.html.haml
+++ b/app/views/admin/users/index.html.haml
@@ -58,5 +58,4 @@
                 - else
                   = link_to 'Block', block_admin_user_path(user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove"
                 = link_to 'Destroy', [:admin, user], confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-small btn-remove"
-        %li.bottom
-          = paginate @admin_users, theme: "gitlab"
+      = paginate @admin_users, theme: "gitlab"
diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml
index dc7db9061ac..217956d7284 100644
--- a/app/views/issues/_issues.html.haml
+++ b/app/views/issues/_issues.html.haml
@@ -1,12 +1,33 @@
-= render @issues
+.ui-box
+  .title
+    = check_box_tag "check_all_issues", nil, false, class: "check_all_issues left"
+    .clearfix
+      .issues_bulk_update.hide
+        = form_tag bulk_update_project_issues_path(@project), method: :post  do
+          %span.update_issues_text Update selected issues with &nbsp;
+          .left
+            = select_tag('update[status]', options_for_select(['open', 'closed']), prompt: "Status")
+            = select_tag('update[assignee_id]', options_from_collection_for_select(@project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee")
+            = select_tag('update[milestone_id]', options_from_collection_for_select(issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone")
+            = hidden_field_tag 'update[issues_ids]', []
+            = hidden_field_tag :status, params[:status]
+          = button_tag "Save", class: "btn update_selected_issues btn-small btn-save"
+      .issues_filters
+        = form_tag project_issues_path(@project), method: :get, remote: true  do
+          = select_tag(:label_name, options_for_select(issue_tags, params[:label_name]), prompt: "Labels")
+          = select_tag(:assignee_id, options_from_collection_for_select([unassigned_filter] + @project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee")
+          = select_tag(:milestone_id, options_from_collection_for_select([unassigned_filter] + issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone")
+          = hidden_field_tag :status, params[:status]
+
+  %ul.well-list.issues-list
+    = render @issues
+    - if @issues.blank?
+      %li
+        %h4.nothing_here_message Nothing to show here
 
 - if @issues.present?
-  %li.bottom
-    .left= paginate @issues, remote: true, theme: "gitlab"
-    .pull-right
-      %span.issue_counter #{@issues.total_count}
-      issues for this filter
-- else
-  %li
-    %h4.nothing_here_message Nothing to show here
+  .pull-right
+    %span.issue_counter #{@issues.total_count}
+    issues for this filter
 
+  = paginate @issues, remote: true, theme: "gitlab"
diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml
index 2e26ee72281..78b677899d4 100644
--- a/app/views/issues/index.html.haml
+++ b/app/views/issues/index.html.haml
@@ -19,30 +19,8 @@
 .row
   .span3
     = render 'filter', entity: 'issue'
-  .span9
-    %div#issues-table-holder.ui-box
-      .title
-        = check_box_tag "check_all_issues", nil, false, class: "check_all_issues left"
-        .clearfix
-          .issues_bulk_update.hide
-            = form_tag bulk_update_project_issues_path(@project), method: :post  do
-              %span.update_issues_text Update selected issues with &nbsp;
-              .left
-                = select_tag('update[status]', options_for_select(['open', 'closed']), prompt: "Status")
-                = select_tag('update[assignee_id]', options_from_collection_for_select(@project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee")
-                = select_tag('update[milestone_id]', options_from_collection_for_select(issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone")
-                = hidden_field_tag 'update[issues_ids]', []
-                = hidden_field_tag :status, params[:status]
-              = button_tag "Save", class: "btn update_selected_issues btn-small btn-save"
-          .issues_filters
-            = form_tag project_issues_path(@project), method: :get  do
-              = select_tag(:label_name, options_for_select(issue_tags, params[:label_name]), prompt: "Labels")
-              = select_tag(:assignee_id, options_from_collection_for_select([unassigned_filter] + @project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee")
-              = select_tag(:milestone_id, options_from_collection_for_select([unassigned_filter] + issues_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone")
-              = hidden_field_tag :status, params[:status]
-
-      %ul#issues-table.well-list.issues-list
-        = render "issues"
+  .span9.issues-holder
+    = render "issues"
 
 :javascript
   $(function(){
diff --git a/app/views/issues/index.js.haml b/app/views/issues/index.js.haml
index 48d7f582be2..dc77be13f27 100644
--- a/app/views/issues/index.js.haml
+++ b/app/views/issues/index.js.haml
@@ -1,2 +1,4 @@
 :plain
-  $('#issues-table').html("#{escape_javascript(render('issues'))}");
+  $('.issues-holder').html("#{escape_javascript(render('issues'))}");
+  History.replaceState({path: "#{request.url}"}, document.title, "#{request.url}");
+  issuesPage();
diff --git a/app/views/kaminari/admin/_first_page.html.haml b/app/views/kaminari/admin/_first_page.html.haml
deleted file mode 100644
index 41c9c0b3af6..00000000000
--- a/app/views/kaminari/admin/_first_page.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
--#  Link to the "First" page
--#  available local variables
--#    url:           url to the first page
--#    current_page:  a page object for the currently displayed page
--#    num_pages:     total number of pages
--#    per_page:      number of items to fetch per page
--#    remote:        data-remote
-%span.first
-  = link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote
diff --git a/app/views/kaminari/admin/_gap.html.haml b/app/views/kaminari/admin/_gap.html.haml
deleted file mode 100644
index 3ffd12f8587..00000000000
--- a/app/views/kaminari/admin/_gap.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
--#  Non-link tag that stands for skipped pages...
--#  available local variables
--#    current_page:  a page object for the currently displayed page
--#    num_pages:     total number of pages
--#    per_page:      number of items to fetch per page
--#    remote:        data-remote
-%li{class: "page"}
-  %span.page.gap
-    = raw(t 'views.pagination.truncate')
diff --git a/app/views/kaminari/admin/_last_page.html.haml b/app/views/kaminari/admin/_last_page.html.haml
deleted file mode 100644
index b03a206224c..00000000000
--- a/app/views/kaminari/admin/_last_page.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
--#  Link to the "Last" page
--#  available local variables
--#    url:           url to the last page
--#    current_page:  a page object for the currently displayed page
--#    num_pages:     total number of pages
--#    per_page:      number of items to fetch per page
--#    remote:        data-remote
-%span.last
-  = link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {remote: remote}
diff --git a/app/views/kaminari/admin/_next_page.html.haml b/app/views/kaminari/admin/_next_page.html.haml
deleted file mode 100644
index 00c5f0b6f4e..00000000000
--- a/app/views/kaminari/admin/_next_page.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
--#  Link to the "Next" page
--#  available local variables
--#    url:           url to the next page
--#    current_page:  a page object for the currently displayed page
--#    num_pages:     total number of pages
--#    per_page:      number of items to fetch per page
--#    remote:        data-remote
-%li.next
-  = link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote
diff --git a/app/views/kaminari/admin/_page.html.haml b/app/views/kaminari/admin/_page.html.haml
deleted file mode 100644
index a52d883b9a8..00000000000
--- a/app/views/kaminari/admin/_page.html.haml
+++ /dev/null
@@ -1,10 +0,0 @@
--#  Link showing page number
--#  available local variables
--#    page:          a page object for "this" page
--#    url:           url to this page
--#    current_page:  a page object for the currently displayed page
--#    num_pages:     total number of pages
--#    per_page:      number of items to fetch per page
--#    remote:        data-remote
-%li{class: "page#{' active' if page.current?}"}
-  = link_to page, url, {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil}
diff --git a/app/views/kaminari/admin/_paginator.html.haml b/app/views/kaminari/admin/_paginator.html.haml
deleted file mode 100644
index 6f9fb332261..00000000000
--- a/app/views/kaminari/admin/_paginator.html.haml
+++ /dev/null
@@ -1,17 +0,0 @@
--#  The container tag
--#  available local variables
--#    current_page:  a page object for the currently displayed page
--#    num_pages:     total number of pages
--#    per_page:      number of items to fetch per page
--#    remote:        data-remote
--#    paginator:     the paginator that renders the pagination tags inside
-= paginator.render do
-  %div.pagination
-    %ul
-      = prev_page_tag unless current_page.first?
-      - each_page do |page|
-        - if page.left_outer? || page.right_outer? || page.inside_window?
-          = page_tag page
-        - elsif !page.was_truncated?
-          = gap_tag
-      = next_page_tag unless current_page.last?
diff --git a/app/views/kaminari/admin/_prev_page.html.haml b/app/views/kaminari/admin/_prev_page.html.haml
deleted file mode 100644
index f673abdb3ae..00000000000
--- a/app/views/kaminari/admin/_prev_page.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
--#  Link to the "Previous" page
--#  available local variables
--#    url:           url to the previous page
--#    current_page:  a page object for the currently displayed page
--#    num_pages:     total number of pages
--#    per_page:      number of items to fetch per page
--#    remote:        data-remote
-%li{class: "prev" }
-  = link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote
diff --git a/app/views/kaminari/gitlab/_gap.html.haml b/app/views/kaminari/gitlab/_gap.html.haml
index f82f185ac35..3ffd12f8587 100644
--- a/app/views/kaminari/gitlab/_gap.html.haml
+++ b/app/views/kaminari/gitlab/_gap.html.haml
@@ -4,5 +4,6 @@
 -#    num_pages:     total number of pages
 -#    per_page:      number of items to fetch per page
 -#    remote:        data-remote
-%span.page.gap
-  = raw(t 'views.pagination.truncate')
+%li{class: "page"}
+  %span.page.gap
+    = raw(t 'views.pagination.truncate')
diff --git a/app/views/kaminari/gitlab/_next_page.html.haml b/app/views/kaminari/gitlab/_next_page.html.haml
index 296cceb080b..00c5f0b6f4e 100644
--- a/app/views/kaminari/gitlab/_next_page.html.haml
+++ b/app/views/kaminari/gitlab/_next_page.html.haml
@@ -5,5 +5,5 @@
 -#    num_pages:     total number of pages
 -#    per_page:      number of items to fetch per page
 -#    remote:        data-remote
-%span.next
+%li.next
   = link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote
diff --git a/app/views/kaminari/gitlab/_page.html.haml b/app/views/kaminari/gitlab/_page.html.haml
index 19456dcc058..a52d883b9a8 100644
--- a/app/views/kaminari/gitlab/_page.html.haml
+++ b/app/views/kaminari/gitlab/_page.html.haml
@@ -6,5 +6,5 @@
 -#    num_pages:     total number of pages
 -#    per_page:      number of items to fetch per page
 -#    remote:        data-remote
-%span{class: "page#{' current' if page.current?}"}
-  = link_to_unless page.current?, page, url, {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil}
+%li{class: "page#{' active' if page.current?}"}
+  = link_to page, url, {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil}
diff --git a/app/views/kaminari/gitlab/_paginator.html.haml b/app/views/kaminari/gitlab/_paginator.html.haml
index 6dd5a5782a2..6f9fb332261 100644
--- a/app/views/kaminari/gitlab/_paginator.html.haml
+++ b/app/views/kaminari/gitlab/_paginator.html.haml
@@ -6,11 +6,12 @@
 -#    remote:        data-remote
 -#    paginator:     the paginator that renders the pagination tags inside
 = paginator.render do
-  %nav.gitlab_pagination
-    = prev_page_tag
-    - each_page do |page|
-      - if page.left_outer? || page.right_outer? || page.inside_window?
-        = page_tag page
-      - elsif !page.was_truncated?
-        = gap_tag
-    = next_page_tag
+  %div.pagination
+    %ul
+      = prev_page_tag unless current_page.first?
+      - each_page do |page|
+        - if page.left_outer? || page.right_outer? || page.inside_window?
+          = page_tag page
+        - elsif !page.was_truncated?
+          = gap_tag
+      = next_page_tag unless current_page.last?
diff --git a/app/views/kaminari/gitlab/_prev_page.html.haml b/app/views/kaminari/gitlab/_prev_page.html.haml
index 5c2061690ac..f673abdb3ae 100644
--- a/app/views/kaminari/gitlab/_prev_page.html.haml
+++ b/app/views/kaminari/gitlab/_prev_page.html.haml
@@ -5,5 +5,5 @@
 -#    num_pages:     total number of pages
 -#    per_page:      number of items to fetch per page
 -#    remote:        data-remote
-%span.prev
+%li{class: "prev" }
   = link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote
diff --git a/app/views/merge_requests/index.html.haml b/app/views/merge_requests/index.html.haml
index bf7a82b8fb5..b9e9096e3ae 100644
--- a/app/views/merge_requests/index.html.haml
+++ b/app/views/merge_requests/index.html.haml
@@ -25,11 +25,11 @@
         - if @merge_requests.blank?
           %li
             %h4.nothing_here_message Nothing to show here
-        - if @merge_requests.present?
-          %li.bottom
-            .left= paginate @merge_requests, theme: "gitlab"
-            .pull-right
-              %span.cgray.pull-right #{@merge_requests.total_count} merge requests for this filter
+    - if @merge_requests.present?
+      .pull-right
+        %span.cgray.pull-right #{@merge_requests.total_count} merge requests for this filter
+
+      = paginate @merge_requests, theme: "gitlab"
 
 :javascript
   $(merge_requestsPage);
diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml
index b50484f6354..3d0d793b2d2 100644
--- a/app/views/public/projects/index.html.haml
+++ b/app/views/public/projects/index.html.haml
@@ -17,4 +17,4 @@
     - unless @projects.present?
       %h3.nothing_here_message No public projects
 
-  = paginate @projects, theme: "admin"
+  = paginate @projects, theme: "gitlab"
-- 
2.30.9