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

implemented feedback from product team and adjusted micro behaviors, needs refactoring

Jonas Jabarieb4ac8f58043
diff --git a/app/components/_index.sass b/app/components/_index.sass
index 887a4542f48..b5ddb6fd7b4 100644
--- a/app/components/_index.sass
+++ b/app/components/_index.sass
@@ -1,5 +1,6 @@
@import "work_packages/activities_tab/index_component"
@import "work_packages/activities_tab/journals/new_component"
+@import "work_packages/activities_tab/journals/item_component"
@import "work_packages/activities_tab/journals/item_component/edit"
@import "work_packages/activities_tab/journals/item_component/details"
@import "shares/modal_body_component"
diff --git a/app/components/work_packages/activities_tab/index_component.sass b/app/components/work_packages/activities_tab/index_component.sass
index 6a5a5d6e282..2b34f85e084 100644
--- a/app/components/work_packages/activities_tab/index_component.sass
+++ b/app/components/work_packages/activities_tab/index_component.sass
@@ -1,14 +1,15 @@
#work-packages-activities-tab-index-component
#journals-container
+ padding-top: 3px
overflow-y: auto
&.with-initial-input-compensation
- margin-bottom: 75px // initial margin-bottom, will be increased by stimulus when opening ckeditor
+ margin-bottom: 65px // initial margin-bottom, will be increased by stimulus when opening ckeditor
@media screen and (max-width: $breakpoint-xl)
- margin-bottom: 0
+ margin-bottom: -16px
&.with-input-compensation
- margin-bottom: 190px
+ margin-bottom: 180px
@media screen and (max-width: $breakpoint-xl)
- margin-bottom: 0
+ margin-bottom: -16px
#input-container
@media screen and (min-width: $breakpoint-xl)
position: absolute
diff --git a/app/components/work_packages/activities_tab/journals/item_component.html.erb b/app/components/work_packages/activities_tab/journals/item_component.html.erb
index b602ca21b9b..5c540315e7d 100644
--- a/app/components/work_packages/activities_tab/journals/item_component.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component.html.erb
@@ -7,41 +7,27 @@
id: "activity-#{journal.version}",
padding: :condensed
)) do |border_box_component|
- border_box_component.with_header(px: 2, py: 0, classes: "journal-notes-header") do
+ border_box_component.with_header(px: 2, py: 1, classes: "journal-notes-header") do
flex_layout(align_items: :center, justify_content: :space_between) do |header_container|
header_container.with_column(flex_layout: true) do |header_start_container|
header_start_container.with_column(mr: 2) do
render Users::AvatarComponent.new(user: journal.user, show_name: false, size: :mini)
end
- header_start_container.with_column(mr: 1) do
- render(Primer::Beta::Link.new(
- href: user_url(journal.user),
- target: "_blank",
- scheme: :primary,
- underline: false,
- font_weight: :bold
- )) do
- journal.user.name
+ header_start_container.with_column(mr: 1, flex_layout: true) do |user_name_container|
+ user_name_container.with_row do
+ truncated_user_name(journal.user)
end
+ user_name_container.with_row(classes: "hidden-for-desktop") do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) { format_time(journal.created_at) }
+ end
end
header_start_container.with_column(mr: 1, classes: "hidden-for-mobile") do
- if journal.initial?
- render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
- t("activities.work_packages.activity_tab.created_on")
- end
- else
- render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
- t("activities.work_packages.activity_tab.commented_on")
- end
- end
- end
- header_start_container.with_column(mr: 1) do
- render(Primer::Beta::Text.new(color: :subtle, mt: 1)) { format_time(journal.updated_at) }
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) { format_time(journal.updated_at) }
end
end
header_container.with_column(flex_layout: true, align_items: :center) do |header_end_container|
if has_unread_notifications?
- header_end_container.with_column(mr: 2, pt: 1) do
+ header_end_container.with_column(mr: 2, pt: 1, classes: "bubble-container") do
bubble_html
end
end
@@ -56,7 +42,7 @@
"##{journal.version}"
end
end
- header_end_container.with_column(ml: 2) do
+ header_end_container.with_column(ml: 1) do
render(Primer::Alpha::ActionMenu.new) do |menu|
menu.with_show_button(icon: "kebab-horizontal",
'aria-label': I18n.t(:button_actions),
diff --git a/app/components/work_packages/activities_tab/journals/item_component.rb b/app/components/work_packages/activities_tab/journals/item_component.rb
index 67048023500..c2b5a1aab72 100644
--- a/app/components/work_packages/activities_tab/journals/item_component.rb
+++ b/app/components/work_packages/activities_tab/journals/item_component.rb
@@ -31,6 +31,7 @@ module WorkPackages
module Journals
class ItemComponent < ApplicationComponent
include ApplicationHelper
+ include WorkPackages::ActivitiesTab::SharedHelpers
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
diff --git a/app/components/work_packages/activities_tab/journals/item_component.sass b/app/components/work_packages/activities_tab/journals/item_component.sass
new file mode 100644
index 00000000000..d02c5bc4d0c
--- /dev/null
+++ b/app/components/work_packages/activities_tab/journals/item_component.sass
@@ -0,0 +1,7 @@
+.work-packages-activities-tab-journals-item-component
+ action-menu
+ button
+ padding-top: 3px // for whatever reason, the dots in the action menu are not perfectly aligned in center vertically by default
+ .bubble-container:
+ padding-top: 2px
+
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.rb b/app/components/work_packages/activities_tab/journals/item_component/details.rb
index ff8a8794b64..5e9778570bb 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/details.rb
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.rb
@@ -33,6 +33,7 @@ module WorkPackages
include ApplicationHelper
include AvatarHelper
include JournalFormatter
+ include WorkPackages::ActivitiesTab::SharedHelpers
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
@@ -53,9 +54,9 @@ module WorkPackages
end
def render_details_header(details_container)
- details_container.with_row(flex_layout: true, align_items: :center,
+ details_container.with_row(flex_layout: true,
justify_content: :space_between, classes: "journal-details-header-container") do |header_container|
- header_container.with_column(flex_layout: true, align_items: :center,
+ header_container.with_column(flex_layout: true,
classes: "journal-details-header") do |header_start_container|
header_start_container.with_column(mr: 2, classes: "timeline-icon") do
if journal.initial?
@@ -67,35 +68,32 @@ module WorkPackages
header_start_container.with_column(mr: 2) do
render Users::AvatarComponent.new(user: journal.user, show_name: false, size: :mini)
end
- header_start_container.with_column(mr: 1) do
- render(Primer::Beta::Link.new(
- href: user_url(journal.user),
- target: "_blank",
- scheme: :primary,
- underline: false,
- font_weight: :bold
- )) do
- journal.user.name
+ header_start_container.with_column(mr: 1, flex_layout: true) do |user_name_container|
+ user_name_container.with_row do
+ truncated_user_name(journal.user)
+ end
+ user_name_container.with_row(classes: "hidden-for-desktop") do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) { format_time(journal.created_at) }
end
end
header_start_container.with_column(mr: 1, classes: "hidden-for-mobile") do
if journal.initial?
- render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) do
t("activities.work_packages.activity_tab.created_on")
end
else
- render(Primer::Beta::Text.new(color: :subtle, mt: 1)) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) do
t("activities.work_packages.activity_tab.changed_on")
end
end
end
- header_start_container.with_column(mr: 1) do
- render(Primer::Beta::Text.new(color: :subtle, mt: 1)) { format_time(journal.updated_at) }
+ header_start_container.with_column(mr: 1, classes: "hidden-for-mobile") do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle, mt: 1)) { format_time(journal.updated_at) }
end
end
- header_container.with_column(flex_layout: true, align_items: :center) do |header_end_container|
+ header_container.with_column(flex_layout: true) do |header_end_container|
if has_unread_notifications
- header_end_container.with_column(mr: 2, pt: 1) do
+ header_end_container.with_column(mr: 2, classes: "bubble-container") do
bubble_html
end
end
diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.sass b/app/components/work_packages/activities_tab/journals/item_component/details.sass
index c949752129e..d9e7766d57f 100644
--- a/app/components/work_packages/activities_tab/journals/item_component/details.sass
+++ b/app/components/work_packages/activities_tab/journals/item_component/details.sass
@@ -13,6 +13,7 @@
height: 28px
text-align: center
padding-top: 3px
+ margin-top: -2px
.empty-line
margin-top: 0px!important
margin-bottom: 0px!important
@@ -32,4 +33,6 @@
// quick hack to adapt the current detail rendering to desired primerised design
i
font-style: normal
- color: var(--fgColor-muted, var(--color-fg-subtle))
\ No newline at end of file
+ color: var(--fgColor-muted, var(--color-fg-subtle))
+ .bubble-container
+ padding-top: 2px
\ No newline at end of file
diff --git a/app/components/work_packages/activities_tab/shared_helpers.rb b/app/components/work_packages/activities_tab/shared_helpers.rb
new file mode 100644
index 00000000000..10ed02e8450
--- /dev/null
+++ b/app/components/work_packages/activities_tab/shared_helpers.rb
@@ -0,0 +1,58 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2023 the OpenProject GmbH
+#
+# 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-2013 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 COPYRIGHT and LICENSE files for more details.
+# ++
+
+module WorkPackages
+ module ActivitiesTab
+ module SharedHelpers
+ def truncated_user_name(user)
+ render(Primer::Beta::Link.new(
+ href: user_url(user),
+ target: "_blank",
+ scheme: :primary,
+ underline: false,
+ font_weight: :bold
+ )) do
+ component_collection do |collection|
+ collection.with_component(Primer::Beta::Truncate.new(classes: "hidden-for-mobile")) do |component|
+ component.with_item(max_width: 180) do
+ user.name
+ end
+ end
+ collection.with_component(Primer::Beta::Truncate.new(classes: "hidden-for-desktop")) do |component|
+ component.with_item(max_width: 220) do
+ user.name
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f733165cdeb..c3088e25f0b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -43,9 +43,8 @@ en:
label_sort_desc: "Newest on top"
label_type_to_comment: "Type here to comment"
label_submit_comment: "Submit comment"
- commented_on: "commented on"
changed_on: "made changes on"
- created_on: "created on"
+ created_on: "created this on"
admin:
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 aff02ebe912..b73667e7e6c 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
@@ -5,6 +5,7 @@ import {
} from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types';
import { KeyCodes } from 'core-app/shared/helpers/keyCodes.enum';
import { workPackageFilesCount } from 'core-app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-files-count.function';
+import { set } from 'lodash';
export default class IndexController extends Controller {
static values = {
@@ -100,6 +101,7 @@ export default class IndexController extends Controller {
}
async updateActivitiesList() {
+ const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom(this.journalsContainerTarget);
const url = new URL(this.updateStreamsUrlValue);
url.searchParams.append('last_update_timestamp', this.lastUpdateTimestamp);
url.searchParams.append('filter', this.filterValue);
@@ -111,6 +113,16 @@ export default class IndexController extends Controller {
Turbo.renderStreamMessage(text);
this.setLastUpdateTimestamp();
this.hideLastPartOfTimeLineStem();
+ setTimeout(() => {
+ if (this.sortingValue === 'asc' && 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);
+ } else {
+ this.scrollJournalContainer(this.journalsContainerTarget, true);
+ }
+ }
+ }, 100);
}
}
@@ -164,6 +176,25 @@ export default class IndexController extends Controller {
return AngularCkEditorElement ? jQuery(AngularCkEditorElement).data('editor') as ICKEditorInstance : null;
}
+ private getInputContainer():HTMLElement | null {
+ return this.element.querySelector('#input-container');
+ }
+
+ // TODO: get rid of static width value and reach for a more CSS based solution
+ private isMobile():boolean {
+ return window.innerWidth < 1279;
+ }
+
+ // TODO: get rid of static width value and reach for a more CSS based solution
+ private isSmViewPort():boolean {
+ return window.innerWidth < 543;
+ }
+
+ // TODO: get rid of static width value and reach for a more CSS based solution
+ private isMdViewPort():boolean {
+ return window.innerWidth >= 543 && window.innerWidth < 1279;
+ }
+
private addEventListenersToCkEditorInstance() {
const editor = this.getCkEditorInstance();
if (editor) {
@@ -208,7 +239,10 @@ export default class IndexController extends Controller {
// current limitation:
// clicking on empty toolbar space and the somewhere else on the page does not trigger the blur anymore
setTimeout(() => {
- if (!editor.ui.focusTracker.isFocused) { this.hideEditorIfEmpty(); }
+ if (!editor.ui.focusTracker.isFocused) {
+ this.hideEditorIfEmpty();
+ if (this.isMobile()) { this.scrollInputContainerIntoView(300); }
+ }
}, 0);
},
{ priority: 'highest' },
@@ -217,9 +251,27 @@ export default class IndexController extends Controller {
private adjustJournalContainerMargin() {
// don't do this on mobile screens
- // TODO: get rid of static width value and reach for a more CSS based solution
- if (window.innerWidth < 1279) { return; }
- this.journalsContainerTarget.style.marginBottom = `${this.formRowTarget.clientHeight + 40}px`;
+ if (this.isMobile()) { return; }
+ this.journalsContainerTarget.style.marginBottom = `${this.formRowTarget.clientHeight + 33}px`;
+ }
+
+ private isJournalsContainerScrolledToBottom(journalsContainer:HTMLElement) {
+ let atBottom = false;
+ // we have to handle different scrollable containers for different viewports in order to idenfity if the user is at the bottom of the journals
+ // seems way to hacky for me, but I couldn't find a better solution
+ if (this.isSmViewPort()) {
+ atBottom = (window.scrollY + window.outerHeight) >= document.body.scrollHeight;
+ } else if (this.isMdViewPort()) {
+ const scrollableContainer = document.querySelector('#content') as HTMLElement;
+
+ atBottom = (scrollableContainer.scrollTop + scrollableContainer.clientHeight + 10) >= scrollableContainer.scrollHeight;
+ } else {
+ const scrollableContainer = jQuery(journalsContainer).scrollParent()[0];
+
+ atBottom = (scrollableContainer.scrollTop + scrollableContainer.clientHeight + 10) >= scrollableContainer.scrollHeight;
+ }
+
+ return atBottom;
}
private scrollJournalContainer(journalsContainer:HTMLElement, toBottom:boolean) {
@@ -229,13 +281,31 @@ export default class IndexController extends Controller {
}
}
+ private scrollInputContainerIntoView(timeout:number = 0) {
+ const inputContainer = this.getInputContainer() as HTMLElement;
+ setTimeout(() => {
+ if (inputContainer) {
+ inputContainer.scrollIntoView({ behavior: 'smooth' });
+ }
+ }, timeout);
+ }
+
showForm() {
+ const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom(this.journalsContainerTarget);
+
this.buttonRowTarget.classList.add('d-none');
this.formRowTarget.classList.remove('d-none');
this.journalsContainerTarget?.classList.add('with-input-compensation');
this.addEventListenersToCkEditorInstance();
+ if (this.isMobile()) {
+ this.scrollInputContainerIntoView(300);
+ } else if (this.sortingValue === 'asc' && journalsContainerAtBottom) {
+ // scroll to (new) bottom if sorting is ascending and journals container was already at bottom before showing the form
+ this.scrollJournalContainer(this.journalsContainerTarget, true);
+ }
+
const ckEditorInstance = this.getCkEditorInstance();
if (ckEditorInstance) {
setTimeout(() => ckEditorInstance.editing.view.focus(), 10);
@@ -311,7 +381,11 @@ export default class IndexController extends Controller {
if (this.journalsContainerTarget) {
this.clearEditor();
- this.focusEditor();
+ if (this.isMobile()) {
+ this.hideEditorIfEmpty();
+ } else {
+ this.focusEditor();
+ }
if (this.journalsContainerTarget) {
this.journalsContainerTarget.style.marginBottom = '';
this.journalsContainerTarget.classList.add('with-input-compensation');
@@ -322,7 +396,10 @@ export default class IndexController extends Controller {
this.sortingValue === 'asc',
);
this.hideLastPartOfTimeLineStem();
- }, 100);
+ if (this.isMobile()) {
+ this.scrollInputContainerIntoView(300);
+ }
+ }, 10);
}
}
}