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

Simplify index outlet sorting value predicate (#19817)

Kabiru Mwenja2dbb689de563
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.ts
index 2c4a23f595d..5f339020dde 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/auto-scrolling.controller.ts
@@ -72,7 +72,7 @@ export default class AutoScrollingController extends BaseController {
}
performAutoScrollingOnStreamsUpdate(journalsContainerAtBottom:boolean = false) {
- if (this.indexOutlet.sortingValue === 'asc' && journalsContainerAtBottom) {
+ if (this.indexOutlet.sortingAscending && journalsContainerAtBottom) {
// scroll to (new) bottom if sorting is ascending and journals container was already at bottom before a new activity was added
if (this.isMobile()) {
this.scrollInputContainerIntoView(300);
@@ -88,7 +88,7 @@ export default class AutoScrollingController extends BaseController {
// timeout amount tested on mobile devices for best possible user experience
this.scrollInputContainerIntoView(800);
} else {
- this.scrollJournalContainer(this.indexOutlet.sortingValue === 'asc', true);
+ this.scrollJournalContainer(this.indexOutlet.sortingAscending, true);
}
}
@@ -98,7 +98,7 @@ export default class AutoScrollingController extends BaseController {
if (inputContainer) {
inputContainer.scrollIntoView({
behavior,
- block: this.indexOutlet.sortingValue === 'desc' ? 'nearest' : 'start',
+ block: this.indexOutlet.sortingDescending ? 'nearest' : 'start',
});
}
}, timeout);
@@ -124,7 +124,7 @@ export default class AutoScrollingController extends BaseController {
if (activityIdMatch && activityIdMatch.length === 3) {
this.scrollToActivity(activityIdMatch[1] as AnchorType, activityIdMatch[2]);
- } else if (this.indexOutlet.sortingValue === 'asc' && (!this.isMobile() || this.isWithinNotificationCenter())) {
+ } else if (this.indexOutlet.sortingAscending && (!this.isMobile() || this.isWithinNotificationCenter())) {
this.scrollToBottom();
}
}
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts
index 592410244aa..60355d4a69a 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/editor.controller.ts
@@ -91,7 +91,7 @@ export default class EditorController extends BaseController {
if (this.isMobile()) {
this.focusEditor(0);
- } else if (this.indexOutlet.sortingValue === 'asc' && journalsContainerAtBottom) {
+ } else if (this.indexOutlet.sortingAscending && journalsContainerAtBottom) {
// scroll to (new) bottom if sorting is ascending and journals container was already at bottom before showing the form
this.autoScrollingOutlet.scrollJournalContainer(true);
this.focusEditor();
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
index ab234aae8dd..a74f1e6e895 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
@@ -67,6 +67,9 @@ export default class IndexController extends Controller<HTMLElement> {
setFilterToOnlyChanges() { this.filterValue = 'only_changes'; }
unsetFilter() { this.filterValue = ''; }
+ get sortingAscending():boolean { return this.sortingValue === 'asc'; }
+ get sortingDescending():boolean { return this.sortingValue === 'desc'; }
+
adjustJournalContainerMarginWith(marginBottomPx:string) {
// don't do this on mobile screens
if (this.viewPortService.isMobile()) { return; }
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts
index 18d012d51e0..9361e9f7465 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/stems.controller.ts
@@ -50,7 +50,7 @@ export default class StemsController extends BaseController {
private handleStemVisibilityForMobile() {
if (this.isMobile()) {
- if (this.indexOutlet.sortingValue === 'asc') return;
+ if (this.indexOutlet.sortingAscending) return;
const initialJournalContainer = (this.element).querySelector('.work-packages-activities-tab-journals-item-component-details--journal-details-container[data-initial="true"]');
@@ -68,7 +68,7 @@ export default class StemsController extends BaseController {
container.classList.remove('work-packages-activities-tab-journals-item-component-details--journal-details-container--hidden');
});
- if (this.indexOutlet.sortingValue === 'asc' || this.indexOutlet.filterValue === 'only_changes') return;
+ if (this.indexOutlet.sortingAscending || this.indexOutlet.filterValue === 'only_changes') return;
// then hide the last one again
if (emptyLines.length > 0) {