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

show pagination range on manual sort

ulfertsf98c93537381
diff --git a/app/assets/stylesheets/content/_pagination.sass b/app/assets/stylesheets/content/_pagination.sass
index 427b28c1578..c56dde46bbc 100644
--- a/app/assets/stylesheets/content/_pagination.sass
+++ b/app/assets/stylesheets/content/_pagination.sass
@@ -102,9 +102,12 @@ $pagination--font-size: 0.8125rem
text-align: right
@include text-shortener
-.pagination--range
+.pagination--range, .pagination--info
flex: 1
margin: 0 0 0 5px
padding: 3px 0
display: block
@include text-shortener
+
+.pagination--info
+ flex-basis: auto
diff --git a/app/assets/stylesheets/content/work_packages/_table_content.sass b/app/assets/stylesheets/content/work_packages/_table_content.sass
index d36f5731aa2..5984ae92e65 100644
--- a/app/assets/stylesheets/content/work_packages/_table_content.sass
+++ b/app/assets/stylesheets/content/work_packages/_table_content.sass
@@ -160,8 +160,3 @@ body.-browser-edge
.wp-table--cell-td img.thumbnail
height: 40px
-.work-package--limited-results
- td
- height: 40px
- text-align: center !important
-
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index cd67f72267f..959b2be3b63 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -705,9 +705,8 @@ en:
no_results:
title: No work packages to display.
description: Either none have been created or all work packages are filtered out.
- limited_results: >
- There are %{total} total work packages, but only %{count} can be shown in manual sorting mode.
- Please reduce the results by filtering.
+ limited_results:
+ Only %{count} work packages can be shown in manual sorting mode. Please reduce the results by filtering.
property_groups:
details: "Details"
people: "People"
diff --git a/frontend/src/app/components/table-pagination/table-pagination.component.html b/frontend/src/app/components/table-pagination/table-pagination.component.html
index efdb5271f5d..11fa82cfede 100644
--- a/frontend/src/app/components/table-pagination/table-pagination.component.html
+++ b/frontend/src/app/components/table-pagination/table-pagination.component.html
@@ -2,7 +2,7 @@
<nav class="pagination--pages">
<ul class="pagination--items">
- <li [hidden]="pagination.page == 1" class="pagination--item">
+ <li [hidden]="pagination.page == 1 || !showPageSelections" class="pagination--item">
<a (accessibleClick)="showPage(pagination.page - 1)"
rel="prev start"
[attr.aria-label]="text.label_previous"
@@ -68,6 +68,14 @@
class="hidden-for-sighted"
[textContent]="text.no_other_page"></span>
</li>
+
+ <li class="pagination--info"
+ *ngIf="infoText">
+ <op-icon icon-classes="icon-info1 icon-context"></op-icon>
+ <span [textContent]="infoText">
+
+ </span>
+ </li>
</ul>
</nav>
diff --git a/frontend/src/app/components/table-pagination/table-pagination.component.ts b/frontend/src/app/components/table-pagination/table-pagination.component.ts
index 0598859991d..129a6dc8b96 100644
--- a/frontend/src/app/components/table-pagination/table-pagination.component.ts
+++ b/frontend/src/app/components/table-pagination/table-pagination.component.ts
@@ -48,7 +48,9 @@ import {I18nService} from 'core-app/modules/common/i18n/i18n.service';
export class TablePaginationComponent implements OnInit {
@Input() totalEntries:string;
@Input() hideForSinglePageResults:boolean = false;
- @Input() calculatePerPage:boolean = false;
+ @Input() showPerPage:boolean = true;
+ @Input() showPageSelections:boolean = true;
+ @Input() infoText?:string;
@Output() updateResults = new EventEmitter<PaginationInstance>();
public pagination:PaginationInstance;
@@ -117,7 +119,11 @@ export class TablePaginationComponent implements OnInit {
*/
public updateCurrentRangeLabel() {
if (this.pagination.total) {
- this.currentRange = '(' + this.pagination.getLowerPageBound() + ' - ' + this.pagination.getUpperPageBound(this.pagination.total) + '/' + this.pagination.total + ')';
+ let totalItems = this.pagination.total;
+ let lowerBound = this.pagination.getLowerPageBound();
+ let upperBound = this.pagination.getUpperPageBound(this.pagination.total);
+
+ this.currentRange = '(' + lowerBound + ' - ' + upperBound + '/' + totalItems + ')';
} else {
this.currentRange = '(0 - 0/0)';
}
@@ -129,6 +135,12 @@ export class TablePaginationComponent implements OnInit {
* @description Defines a list of all pages in numerical order inside the scope
*/
public updatePageNumbers() {
+ if (!this.showPageSelections) {
+ this.pageNumbers = [];
+ this.postPageNumbers = [];
+ return;
+ }
+
var maxVisible = this.paginationService.getMaxVisiblePageOptions();
var truncSize = this.paginationService.getOptionsTruncationSize();
@@ -156,7 +168,7 @@ export class TablePaginationComponent implements OnInit {
}
public showPerPageOptions() {
- return !this.calculatePerPage &&
+ return this.showPerPage &&
this.perPageOptions.length > 0 &&
this.pagination.total > this.perPageOptions[0];
}
diff --git a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
index 28b55eefcbe..b1d203c2235 100644
--- a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
+++ b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
@@ -135,9 +135,6 @@ export class WorkPackageEmbeddedTableComponent extends WorkPackageEmbeddedBaseCo
// We should allow the backend to disable results embedding instead.
if (!this.configuration.tableVisible) {
this.queryProps.pageSize = 1;
- } else if (this.configuration.forcePerPageOption) {
- // Limit the number of visible work packages
- this.queryProps.pageSize = this.configuration.forcePerPageOption;
}
// Set first page
diff --git a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html
index d1e4cc9daa9..d15027222a9 100644
--- a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html
+++ b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html
@@ -19,8 +19,7 @@
<!-- Footer -->
<div class="work-packages-split-view--tabletimeline-footer hide-when-print">
- <wp-table-pagination [hideForSinglePageResults]="true"
- [calculatePerPage]="configuration.forcePerPageOption">
+ <wp-table-pagination [hideForSinglePageResults]="true">
</wp-table-pagination>
</div>
</ng-container>
diff --git a/frontend/src/app/components/wp-table/wp-table-configuration.ts b/frontend/src/app/components/wp-table/wp-table-configuration.ts
index 752f6eb2775..a8690c7c2cb 100644
--- a/frontend/src/app/components/wp-table/wp-table-configuration.ts
+++ b/frontend/src/app/components/wp-table/wp-table-configuration.ts
@@ -66,9 +66,6 @@ export class WorkPackageTableConfiguration {
/** Whether the work packages shall be shown in cards instead of a table */
public isCardView:boolean = false;
- /** Whether the number of shown WP per page shall be calculated based on the available height */
- public forcePerPageOption:number|false = false;
-
/** Whether this table provides a UI for filters*/
public withFilters:boolean = false;
diff --git a/frontend/src/app/components/wp-table/wp-table.directive.html b/frontend/src/app/components/wp-table/wp-table.directive.html
index d5315a39889..ad2fb1be98b 100644
--- a/frontend/src/app/components/wp-table/wp-table.directive.html
+++ b/frontend/src/app/components/wp-table/wp-table.directive.html
@@ -58,18 +58,6 @@
[wp-inline-create--project-identifier]="projectIdentifier"
>
</tbody>
- <tbody class="work-package--limited-results" *ngIf="limitedResults">
- <tr>
- <td [attr.colspan]="columns.length + 2">
- <span>
- <op-icon icon-classes="icon-info1 icon-context"></op-icon>
- <span>
- {{text.limitedResults(results.count, results.total)}}
- </span>
- </span>
- </td>
- </tr>
- </tbody>
<tfoot>
<tr wpTableSumsRow></tr>
</tfoot>
diff --git a/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts b/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
index 4d956be1660..86c0df5511e 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
@@ -68,9 +68,6 @@ export class WorkPackagesListComponent extends WorkPackagesViewBase implements O
/** Do we currently have query props ? */
hasQueryProps:boolean;
- /** Should we show the pagination ? */
- showPagination = true;
-
/** Listener callbacks */
unRegisterTitleListener:Function;
removeTransitionSubscription:Function;
@@ -120,7 +117,6 @@ export class WorkPackagesListComponent extends WorkPackagesViewBase implements O
// Update the title whenever the query changes
this.updateTitle(query);
this.currentQuery = query;
- this.showPagination = !this.wpTableSortBy.isManualSortingMode;
// Update the visible representation
if (this.wpDisplayRepresentation.valueFromQuery(query) === wpDisplayCardRepresentation) {
@@ -222,7 +218,20 @@ export class WorkPackagesListComponent extends WorkPackagesViewBase implements O
return this.bcfDetectorService.isBcfActivated;
}
- protected updateQueryOnParamsChanges() {
+ public get isManualSortingMode() {
+ return this.wpTableSortBy.isManualSortingMode;
+ }
+
+ public get paginationInfoText() {
+ if (this.isManualSortingMode && (this.currentQuery.results.count < this.currentQuery.results.total)) {
+ return I18n.t('js.work_packages.limited_results',
+ {count: this.currentQuery.results.count});
+ } else {
+ return null;
+ }
+ }
+
+protected updateQueryOnParamsChanges() {
// Listen for param changes
this.removeTransitionSubscription = this.$transitions.onSuccess({}, (transition):any => {
let options = transition.options();
diff --git a/frontend/src/app/modules/work_packages/routing/wp-list/wp.list.component.html b/frontend/src/app/modules/work_packages/routing/wp-list/wp.list.component.html
index 23729ee7804..cba6046b825 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-list/wp.list.component.html
+++ b/frontend/src/app/modules/work_packages/routing/wp-list/wp.list.component.html
@@ -90,8 +90,11 @@
<!-- Footer -->
<div class="work-packages-split-view--tabletimeline-footer hide-when-print"
- *ngIf="tableInformationLoaded && showPagination">
- <wp-table-pagination></wp-table-pagination>
+ *ngIf="tableInformationLoaded">
+ <wp-table-pagination [showPerPage]="!isManualSortingMode"
+ [showPageSelections]="!isManualSortingMode"
+ [infoText]="paginationInfoText">
+ </wp-table-pagination>
</div>
</div>
diff --git a/spec/features/work_packages/pagination_spec.rb b/spec/features/work_packages/pagination_spec.rb
index 96d54fb1d4d..573f402ec30 100644
--- a/spec/features/work_packages/pagination_spec.rb
+++ b/spec/features/work_packages/pagination_spec.rb
@@ -29,11 +29,10 @@
require 'spec_helper'
RSpec.feature 'Work package pagination', js: true do
-
let(:admin) { FactoryBot.create(:admin) }
- let(:project) {
+ let(:project) do
FactoryBot.create(:project, name: 'project1', identifier: 'project1')
- }
+ end
shared_examples_for 'paginated work package list' do
let!(:work_package_1) { FactoryBot.create(:work_package, project: project) }
diff --git a/spec/features/work_packages/sorting/manual_sorting_spec.rb b/spec/features/work_packages/sorting/manual_sorting_spec.rb
index e2a75604c44..487839c01a5 100644
--- a/spec/features/work_packages/sorting/manual_sorting_spec.rb
+++ b/spec/features/work_packages/sorting/manual_sorting_spec.rb
@@ -52,6 +52,7 @@ describe 'Manual sorting of WP table', type: :feature, js: true do
let(:sort_by) { ::Components::WorkPackages::SortBy.new }
let(:hierarchies) { ::Components::WorkPackages::Hierarchies.new }
let(:dialog) { ::Components::ConfirmationDialog.new }
+ let(:pagination) { ::Components::TablePagination.new }
def expect_query_order(query, expected)
retry_block do
@@ -100,9 +101,12 @@ describe 'Manual sorting of WP table', type: :feature, js: true do
raise "Query was not yet saved." unless query.name == 'My sorted query'
end
-
# Expect sorted 1 and 2, the rest is not positioned
expect_query_order(query, [work_package_1, work_package_4].map(&:id))
+
+ # Pagination information is shown but no per page options
+ pagination.expect_range(1, 4, 4)
+ pagination.expect_no_per_page_options
end
it 'can drag an element into a hierarchy' do
@@ -253,6 +257,9 @@ describe 'Manual sorting of WP table', type: :feature, js: true do
raise "Expected sort_criteria to be updated to manual_sorting, was #{query.sort_criteria.inspect}"
end
end
+
+ pagination.expect_range(1, 4, 4)
+ pagination.expect_no_per_page_options
end
end
@@ -296,6 +303,9 @@ describe 'Manual sorting of WP table', type: :feature, js: true do
query = Query.last
expect(query.name).to eq 'Manual sorted query'
expect_query_order(query, [work_package_1.id, work_package_3.id, work_package_2.id])
+
+ pagination.expect_range(1, 4, 4)
+ pagination.expect_no_per_page_options
end
it 'does not loose the current order when switching to manual sorting' do
diff --git a/spec/support/components/table_pagination.rb b/spec/support/components/table_pagination.rb
new file mode 100644
index 00000000000..4900738a6dc
--- /dev/null
+++ b/spec/support/components/table_pagination.rb
@@ -0,0 +1,56 @@
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+module Components
+ class TablePagination
+ include Capybara::DSL
+ include RSpec::Matchers
+
+ def expect_range(from, to, total)
+ within_pagination do
+ expect(page)
+ .to have_selector('.pagination--range', text: "(#{from} - #{to}/#{total})")
+ end
+ end
+
+ def expect_no_per_page_options
+ within_pagination do
+ expect(page)
+ .to have_no_selector('.pagination--options')
+ end
+ end
+
+ protected
+
+ def within_pagination
+ within('.pagination') do
+ yield
+ end
+ end
+ end
+end