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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
implemented sticky bottom editor approach, file upload and mentions not working yet via ckeditor
Jonas Jabari21a7eea83202
diff --git a/app/components/_index.sass b/app/components/_index.sassindex 9bbe0035237..476da9ea37f 100644--- a/app/components/_index.sass+++ b/app/components/_index.sass@@ -1,4 +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/edit"@import "work_packages/share/modal_body_component"@import "work_packages/share/invite_user_form_component"@import "work_packages/progress/modal_body_component"diff --git a/app/components/work_packages/activities_tab/index_component.html.erb b/app/components/work_packages/activities_tab/index_component.html.erbindex f5b617b1e0d..2ab8703fc80 100644--- a/app/components/work_packages/activities_tab/index_component.html.erb+++ b/app/components/work_packages/activities_tab/index_component.html.erb@@ -10,25 +10,16 @@))end- # if journal_sorting == "desc"- # activties_tab_container.with_row do- # render(- # WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:)- # )- # end- # end- activties_tab_container.with_row do+ activties_tab_container.with_row(id: "journals-container") dorender(WorkPackages::ActivitiesTab::Journals::IndexComponent.new(work_package:, filter:))end- # if journal_sorting == "asc"- # activties_tab_container.with_row do- # render(- # WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:)- # )- # end- # end+ activties_tab_container.with_row(id: "input-container", mt: 3, pt: 3, pb: 3, pl: 3, pr: 2, border: :top, bg: :subtle) do+ render(+ WorkPackages::ActivitiesTab::Journals::NewComponent.new(work_package:)+ )+ endendendenddiff --git a/app/components/work_packages/activities_tab/index_component.sass b/app/components/work_packages/activities_tab/index_component.sassnew file mode 100644index 00000000000..2a953e5acb7--- /dev/null+++ b/app/components/work_packages/activities_tab/index_component.sass@@ -0,0 +1,15 @@+#work-packages-activities-tab-index-component+ #journals-container+ overflow-y: auto+ margin-bottom: 90px // initial margin-bottom, will be increased by stimulus when opening ckeditor+ &.with-input-compensation+ margin-bottom: 340px+ #input-container+ position: absolute+ min-height: 60px+ bottom: 0+ left: 0+ right: 0+ @media screen and (max-width: $breakpoint-md)+ width: 100vw+ margin-left: -15pxdiff --git a/app/components/work_packages/activities_tab/journals/form_component.html.erb b/app/components/work_packages/activities_tab/journals/form_component.html.erbindex ec4bcd0a4b8..d26adad9bc5 100644--- a/app/components/work_packages/activities_tab/journals/form_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/form_component.html.erb@@ -8,7 +8,7 @@) do |f|flex_layout do |form_container|form_container.with_row do- render(WorkPackages::ActivitiesTab::Journals::NotesForm.new(f))+ render(WorkPackages::ActivitiesTab::Journals::NotesForm.new(f, journal:))endform_container.with_row(flex_layout: true, mt: 3, justify_content: :flex_end) do |submit_container|submit_container.with_column(mr: 2) dodiff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erbindex 41ccbab3dc7..2820e6293de 100644--- a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb@@ -1,5 +1,5 @@<%=- component_wrapper do+ component_wrapper(class: "work-packages-activities-tab-journals-item-component-edit") dorender(Primer::Box.new(mt: 3)) dorender(WorkPackages::ActivitiesTab::Journals::FormComponent.new(diff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.sass b/app/components/work_packages/activities_tab/journals/item_component/edit.sassnew file mode 100644index 00000000000..38adcf394e0--- /dev/null+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.sass@@ -0,0 +1,13 @@+.work-packages-activities-tab-journals-item-component-edit+ // prototypical primer style adoptions+ .ck-toolbar+ border-radius: var(--borderRadius-medium) var(--borderRadius-medium) 0px 0px!important+ .document-editor__editable-container+ background: var(--color-scale-white)+ border-radius: 0px 0px var(--borderRadius-medium) var(--borderRadius-medium)!important+ .ck-content+ background: var(--color-scale-white)+ overflow-y: auto+ border-radius: var(--borderRadius-medium)!important+ margin: 5px+diff --git a/app/components/work_packages/activities_tab/journals/new_component.html.erb b/app/components/work_packages/activities_tab/journals/new_component.html.erbindex 31482dbb115..cdbb06ff4c3 100644--- a/app/components/work_packages/activities_tab/journals/new_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/new_component.html.erb@@ -1,29 +1,58 @@<%=component_wrapper(data: wrapper_data_attributes) doflex_layout(my: 2) do |new_form_container|- new_form_container.with_row() do- render(Primer::Beta::Button.new(+ new_form_container.with_row(data: {+ "work-packages--activities-tab--new-target": "buttonRow"+ }) do+ flex_layout(justify_content: :space_between) do |button_row|+ button_row.with_column(id: "input-trigger-column", mr: 2) do+ render(Primer::Beta::Button.new(+ text_align: :left,scheme: :default,size: :medium,block: true,- data: {- "work-packages--activities-tab--new-target": "button",+ data: {"action": "click->work-packages--activities-tab--new#showForm"})) do- render(Primer::Beta::Text.new()) { I18n.t("js.label_add_comment_title") }+ render(Primer::Beta::Text.new(color: :muted, font_weight: :normal)) { t("activities.work_packages.activity_tab.label_type_to_comment") }+ end+ end+ button_row.with_column do+ render(Primer::Beta::IconButton.new(+ scheme: :default,+ icon: :"paper-airplane",+ "aria-label": "submit comment",+ disabled: true+ ))+ endendendnew_form_container.with_row(display: :none,- data: { "work-packages--activities-tab--new-target": "form" }+ data: { "work-packages--activities-tab--new-target": "formRow" }) do- render(- WorkPackages::ActivitiesTab::Journals::FormComponent.new(- journal:,- submit_path: work_package_activities_path(work_package_id: work_package.id)- )- )+ primer_form_with(+ id: "work-package-journal-form",+ model: journal,+ method: :post,+ data: { turbo: true, turbo_stream: true, "work-packages--activities-tab--new-target": "form", action: "submit->work-packages--activities-tab--new#onSubmit" },+ url: work_package_activities_path(work_package_id: work_package.id),+ ) do |f|+ flex_layout(justify_content: :space_between, align_items: :flex_end) do |form_container|+ form_container.with_column(id: "ck-editor-column", mr: 2) do+ render(WorkPackages::ActivitiesTab::Journals::NotesForm.new(f, journal:))+ end+ form_container.with_column do+ render(Primer::Beta::IconButton.new(+ scheme: :default,+ icon: :"paper-airplane",+ "aria-label": "submit comment",+ type: :submit+ ))+ end+ end+ endendendenddiff --git a/app/components/work_packages/activities_tab/journals/new_component.rb b/app/components/work_packages/activities_tab/journals/new_component.rbindex 91a980e3190..889c16aecbe 100644--- a/app/components/work_packages/activities_tab/journals/new_component.rb+++ b/app/components/work_packages/activities_tab/journals/new_component.rb@@ -49,9 +49,14 @@ module WorkPackagesdef wrapper_data_attributes{controller: "work-packages--activities-tab--new",+ "work-packages--activities-tab--new-sorting-value": journal_sorting,"application-target": "dynamic"}end++ def journal_sorting+ User.current.preference&.comments_sorting || "desc"+ endendendenddiff --git a/app/components/work_packages/activities_tab/journals/new_component.sass b/app/components/work_packages/activities_tab/journals/new_component.sassindex f21398240e0..27e33c901fe 100644--- a/app/components/work_packages/activities_tab/journals/new_component.sass+++ b/app/components/work_packages/activities_tab/journals/new_component.sass@@ -1,3 +1,23 @@#work-packages-activities-tab-journals-new-component- #work-package-journal-new-label- cursor: pointer+ #input-trigger-column+ width: 100%+ button+ background: var(--color-scale-white)+ cursor: text+ .Button-content+ display: block+ #ck-editor-column+ width: 100%+ // prototypical primer style adoptions+ .ck-toolbar+ border-radius: var(--borderRadius-medium) var(--borderRadius-medium) 0px 0px+ .document-editor__editable-container+ background: var(--color-scale-white)+ border-radius: 0px 0px var(--borderRadius-medium) var(--borderRadius-medium)+ .ck-content+ background: var(--color-scale-white)+ height: 235px+ overflow-y: auto+ border-radius: var(--borderRadius-medium)+ margin: 5px+diff --git a/app/forms/work_packages/activities_tab/journals/notes_form.rb b/app/forms/work_packages/activities_tab/journals/notes_form.rbindex e6114159542..f76ba4ede8b 100644--- a/app/forms/work_packages/activities_tab/journals/notes_form.rb+++ b/app/forms/work_packages/activities_tab/journals/notes_form.rb@@ -32,20 +32,23 @@ module WorkPackages::ActivitiesTab::Journalsname: :notes,label: nil,rich_text_options: {- resource:,showAttachments: false,- macros: "none"+ macros: "none",+ resource:,+ editorType: "constrained"})end+ def initialize(journal:)+ @journal = journal+ end+privatedef resource- return unless object&.journal-- API::V3::Journals::JournalRepresenter- .new(object.journal, current_user: User.current, embed_links: false)+ API::V3::Activities::ActivityRepresenter+ .new(@journal, current_user: User.current, embed_links: false)endendenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex f9f3173e1a5..f14b2001091 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -41,6 +41,7 @@ en:label_activity_show_only_changes: "Show changes only"label_sort_asc: "Oldest on top"label_sort_desc: "Newest on top"+ label_type_to_comment: "Type here to comment"admin:diff --git a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.tsindex e97081b1bff..db7e40a6981 100644--- a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts+++ b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts@@ -170,7 +170,10 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin impl}if (this.turboMode) {- navigator.submitForm(this.formElement, evt?.submitter || undefined);+ // If the form has a stimulus action defined, we ONLY want to submit it via stimulus+ if (!this.formElement.dataset.action) {+ navigator.submitForm(this.formElement, evt?.submitter || undefined);+ }} else {this.formElement.requestSubmit(evt?.submitter);}diff --git a/frontend/src/global_styles/layout/work_packages/_full_view.sass b/frontend/src/global_styles/layout/work_packages/_full_view.sassindex df620ed2771..6616c4a1fe8 100644--- a/frontend/src/global_styles/layout/work_packages/_full_view.sass+++ b/frontend/src/global_styles/layout/work_packages/_full_view.sass@@ -79,7 +79,7 @@display: gridgrid-template-rows: auto auto 1frheight: 100%- padding: 5px 0 10px 15px+ padding: 5px 0 0px 15px.tabcontentheight: 100%diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/new.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/new.controller.tsindex 365a88a45ae..c6e20e68b4d 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/new.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/new.controller.ts@@ -28,26 +28,117 @@* ++*/+import * as Turbo from '@hotwired/turbo';import { Controller } from '@hotwired/stimulus';export default class NewController extends Controller {- static targets = ['button', 'form'];- declare readonly buttonTarget:HTMLInputElement;- declare readonly formTarget:HTMLInputElement;+ static values = {+ sorting: String,+ };++ static targets = ['buttonRow', 'formRow', 'form'];++ declare readonly buttonRowTarget:HTMLInputElement;+ declare readonly formRowTarget:HTMLInputElement;+ declare readonly formTarget:HTMLFormElement;++ declare sortingValue:string;++ getCkEditorElement() {+ return this.formRowTarget.querySelectorAll('.document-editor__editable')[0] as HTMLElement;+ }++ addEventListenerToCkEditorElement(ckEditorElement:HTMLElement) {+ ckEditorElement.addEventListener('keydown', (event) => {+ this.onCtrlEnter(event);+ });+ }++ onCtrlEnter(event:KeyboardEvent) {+ if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {+ this.onSubmit(event);+ }+ }++ getJournalsContainer() {+ return document.querySelector('#work-packages-activities-tab-index-component #journals-container') as HTMLElement;+ }++ scrollJournalContainerToBottom(journalsContainer:HTMLElement) {+ const scrollableContainer = jQuery(journalsContainer).scrollParent()[0];+ if (scrollableContainer) {+ scrollableContainer.scrollTop = scrollableContainer.scrollHeight;+ }+ }++ scrollJournalContainerToTop(journalsContainer:HTMLElement) {+ const scrollableContainer = jQuery(journalsContainer).scrollParent()[0];+ if (scrollableContainer) {+ scrollableContainer.scrollTop = 0;+ }+ }showForm() {- this.buttonTarget.classList.add('d-none');- this.formTarget.classList.remove('d-none');- setTimeout(() => {- const ckEditorElement = this.formTarget.querySelectorAll('.document-editor__editable')[0] as HTMLElement;- if (ckEditorElement) {- ckEditorElement.focus();+ this.buttonRowTarget.classList.add('d-none');+ this.formRowTarget.classList.remove('d-none');++ const journalsContainer = this.getJournalsContainer();+ if (journalsContainer) {+ journalsContainer.classList.add('with-input-compensation');+ if (this.sortingValue === 'asc') {+ this.scrollJournalContainerToBottom(journalsContainer);+ } else {+ // this.scrollJournalContainerToTop(journalsContainer);}- }, 10);+ }++ const ckEditorElement = this.getCkEditorElement();+ if (ckEditorElement) {+ this.addEventListenerToCkEditorElement(ckEditorElement);++ setTimeout(() => {+ if (ckEditorElement) {+ ckEditorElement.focus();+ }+ }, 10);+ }}- hideForm() {- this.buttonTarget.classList.remove('d-none');- this.formTarget.classList.add('d-none');+ async onSubmit(event:Event) {+ event.preventDefault(); // Prevent the native form submission++ const form = this.formTarget;+ const formData = new FormData(form);+ const action = form.action;++ const response = await fetch(+ action,+ {+ method: 'POST',+ body: formData,+ headers: {+ 'X-CSRF-Token': (document.querySelector('meta[name="csrf-token"]') as HTMLMetaElement).content,+ Accept: 'text/vnd.turbo-stream.html',+ },+ credentials: 'same-origin',+ },+ );++ if (response.ok) {+ const text = await response.text();+ Turbo.renderStreamMessage(text);++ const journalsContainer = this.getJournalsContainer();+ if (journalsContainer) {+ setTimeout(() => {+ journalsContainer.classList.remove('with-input-compensation');+ if (this.sortingValue === 'asc') {+ this.scrollJournalContainerToBottom(journalsContainer);+ } else {+ this.scrollJournalContainerToTop(journalsContainer);+ }+ }, 100);+ }+ }}}