Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

making the projects table scrollable and has sticky header (#8692)

Behrokh Satarnejad1943c4db29d2
diff --git a/app/cells/views/projects/table/show.erb b/app/cells/views/projects/table/show.erb
index d11caa04ccb..479e94c626a 100644
--- a/app/cells/views/projects/table/show.erb
+++ b/app/cells/views/projects/table/show.erb
@@ -27,75 +27,77 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
-<div class="generic-table--container">
- <div class="generic-table--results-container">
- <table class="generic-table" <%= table_id ? "id=\"#{table_id}\"" : '' %>>
- <colgroup>
- <% headers.each do |_name, _options| %>
- <col highlight-col>
- <% end %>
- <col>
- </colgroup>
- <thead>
- <tr>
- <% headers.each do |name, options| %>
- <% if name == :hierarchy %>
- <th id="project-table--hierarchy-header">
- <div class="generic-table--sort-header-outer">
- <div class="generic-table--sort-header">
- <%= content_tag :a,
- op_icon("icon-hierarchy"),
- href: href_only_when_not_sort_lft,
- class: deactivate_class_on_lft_sort,
- title: t(:label_sort_by, value: %("#{t(:label_project_hierarchy)}")) %>
+<div class="generic-table--flex-container">
+ <div class="generic-table--container">
+ <div class="generic-table--results-container">
+ <table class="generic-table" <%= table_id ? "id=\"#{table_id}\"" : '' %>>
+ <colgroup>
+ <% headers.each do |_name, _options| %>
+ <col highlight-col>
+ <% end %>
+ <col>
+ </colgroup>
+ <thead class="-sticky">
+ <tr>
+ <% headers.each do |name, options| %>
+ <% if name == :hierarchy %>
+ <th id="project-table--hierarchy-header">
+ <div class="generic-table--sort-header-outer">
+ <div class="generic-table--sort-header">
+ <%= content_tag :a,
+ op_icon("icon-hierarchy"),
+ href: href_only_when_not_sort_lft,
+ class: deactivate_class_on_lft_sort,
+ title: t(:label_sort_by, value: %("#{t(:label_project_hierarchy)}")) %>
+ </div>
</div>
- </div>
- </th>
- <% elsif sortable_column?(name) %>
- <%= build_sort_header name, options %>
- <% else %>
- <th>
- <div class="generic-table--sort-header-outer">
- <div class="generic-table--sort-header">
- <span>
- <%= options[:caption] %>
- </span>
+ </th>
+ <% elsif sortable_column?(name) %>
+ <%= build_sort_header name, options %>
+ <% else %>
+ <th>
+ <div class="generic-table--sort-header-outer">
+ <div class="generic-table--sort-header">
+ <span>
+ <%= options[:caption] %>
+ </span>
+ </div>
</div>
- </div>
- </th>
+ </th>
+ <% end %>
<% end %>
- <% end %>
- <th class="-right">
- <div class="generic-table--header-outer">
- <div class="generic-table--header">
- <% if params[:expand] == 'all' %>
- <%= link_to t(:button_collapse_all), { params: safe_query_params(%w{filters page per_page sortBy}).except(:expand) } %>
- <% else %>
- <%= link_to t(:button_expand_all), { params: safe_query_params(%w{filters page per_page sortBy}).merge(expand: 'all') } %>
- <% end %>
+ <th class="-right">
+ <div class="generic-table--header-outer">
+ <div class="generic-table--header">
+ <% if params[:expand] == 'all' %>
+ <%= link_to t(:button_collapse_all), { params: safe_query_params(%w{filters page per_page sortBy}).except(:expand) } %>
+ <% else %>
+ <%= link_to t(:button_expand_all), { params: safe_query_params(%w{filters page per_page sortBy}).merge(expand: 'all') } %>
+ <% end %>
+ </div>
</div>
- </div>
- </th>
- </tr>
- </thead>
- <tbody>
- <% if rows.empty? %>
- <tr class="generic-table--empty-row">
- <td colspan="<%= headers.length + 1 %>"><%= empty_row_message %></td>
+ </th>
</tr>
+ </thead>
+ <tbody>
+ <% if rows.empty? %>
+ <tr class="generic-table--empty-row">
+ <td colspan="<%= headers.length + 1 %>"><%= empty_row_message %></td>
+ </tr>
+ <% end %>
+ <% for row in rows do -%>
+ <%= render_row row %>
+ <% end -%>
+ </tbody>
+ </table>
+ <% if inline_create_link && show_inline_create %>
+ <div class="wp-inline-create-button">
+ <%= inline_create_link %>
+ </div>
<% end %>
- <% for row in rows do -%>
- <%= render_row row %>
- <% end -%>
- </tbody>
- </table>
- <% if inline_create_link && show_inline_create %>
- <div class="wp-inline-create-button">
- <%= inline_create_link %>
- </div>
- <% end %>
+ </div>
</div>
-</div>
-<% if paginated? %>
- <%= pagination_links_full model %>
-<% end %>
+ <% if paginated? %>
+ <%= pagination_links_full model %>
+ <% end %>
+</div>
\ No newline at end of file
diff --git a/frontend/src/global_styles/content/_pagination.sass b/frontend/src/global_styles/content/_pagination.sass
index 6b8dad8e152..6a7339865be 100644
--- a/frontend/src/global_styles/content/_pagination.sass
+++ b/frontend/src/global_styles/content/_pagination.sass
@@ -32,6 +32,7 @@ $pagination--font-size: 0.8125rem
display: flex
justify-content: space-between
width: 100%
+ min-height: 45px
.pagination--pages
flex-grow: 2
diff --git a/frontend/src/global_styles/content/_table.sass b/frontend/src/global_styles/content/_table.sass
index 3abbfea871c..f41691a6ddc 100644
--- a/frontend/src/global_styles/content/_table.sass
+++ b/frontend/src/global_styles/content/_table.sass
@@ -34,6 +34,23 @@
$input-elements: input, 'input.form--text-field', select, 'select.form--select', '.form--field-affix', 'a.button'
+$toolbar-height: 80px
+$toolbar-height--mobile: 100px
+
+.generic-table--flex-container
+ display: flex
+ flex-direction: column
+ // Calculate table size by subtracting the space above
+ max-height: calc(100vh - #{var(--header-height)} - #{$toolbar-height})
+
+ @media screen and (max-width: 679px)
+ max-height: calc(100vh - #{var(--header-height)} - #{$toolbar-height--mobile})
+
+ .generic-table--container
+ display: contents
+ .generic-table
+ position: relative
+
.generic-table--container
position: relative
height: 100%