Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/54464 snappier progress popover #15383

Merged
merged 6 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/forms/work_packages/progress_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def default_field_options(name)
data = { "work-packages--progress--preview-progress-target": "progressInput",
"work-packages--progress--touched-field-marker-target": "progressInput",
action: "input->work-packages--progress--touched-field-marker#markFieldAsTouched" }

if @focused_field == name
data[:"work-packages--progress--focus-field-target"] = "fieldToFocus"
end
Expand Down
22 changes: 11 additions & 11 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"glob": "^7.1.4",
"hammerjs": "^2.0.8",
"i18n-js": "^4.3.0",
"idiomorph": "^0.3.0",
"jquery": "^3.5.1",
"jquery-ui": "1.13.2",
"jquery-ujs": "^1.2.2",
Expand All @@ -136,7 +137,6 @@
"mime": "^2.5.2",
"moment": "^2.30.1",
"moment-timezone": "^0.5.45",
"morphdom": "^2.7.2",
"mousetrap": "~1.6.3",
"ng-dynamic-component": "^10.7.0",
"ng2-charts": "^4.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import { Controller } from '@hotwired/stimulus';
import { debounce } from 'lodash';
import morphdom from 'morphdom';
import Idiomorph from 'idiomorph/dist/idiomorph.cjs';

interface TurboBeforeFrameRenderEventDetail {
render:(currentElement:HTMLElement, newElement:HTMLElement) => void;
Expand All @@ -48,15 +48,15 @@ export default class PreviewProgressController extends Controller {
private frameMorphRenderer:(event:CustomEvent<TurboBeforeFrameRenderEventDetail>) => void;

connect() {
this.debouncedPreview = debounce((event:Event) => { void this.preview(event); }, 500);
this.debouncedPreview = debounce((event:Event) => { void this.preview(event); }, 100);
// TODO: Ideally morphing in this single controller should not be necessary.
// Turbo supports morphing, by adding the <turbo-frame refresh="morph"> attribute.
// However, it has a bug, and it doesn't morphs when reloading the frame via javascript.
// See https://github.com/hotwired/turbo/issues/1161 . Once the issue is solved, we can remove
// this code and just use <turbo-frame refresh="morph"> instead.
this.frameMorphRenderer = (event:CustomEvent<TurboBeforeFrameRenderEventDetail>) => {
event.detail.render = (currentElement:HTMLElement, newElement:HTMLElement) => {
morphdom(currentElement, newElement, { childrenOnly: true });
Idiomorph.morph(currentElement, newElement, { ignoreActiveValue: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well well well... Seems they've thought of this already 😆

};
};

Expand Down
11 changes: 0 additions & 11 deletions frontend/src/turbo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import '../typings/shims.d.ts';
import * as Turbo from '@hotwired/turbo';
import { registerDialogStreamAction } from './dialog-stream-action';
import { addTurboEventListeners } from './turbo-event-listeners';
import morphdom from 'morphdom';
import { ModalDialogElement } from '@openproject/primer-view-components/app/components/primer/alpha/modal_dialog';

// Disable default turbo-drive for now as we don't need it for now AND it breaks angular routing
Expand Down Expand Up @@ -31,13 +30,3 @@ document.addEventListener('turbo:submit-end', (event:CustomEvent) => {
dialog && dialog.close(true);
}
});

interface TurboBeforeFrameRenderEventDetail {
render:(currentElement:HTMLElement, newElement:HTMLElement) => void;
}

document.addEventListener('turbo:before-frame-render', (event:CustomEvent<TurboBeforeFrameRenderEventDetail>) => {
event.detail.render = (currentElement:HTMLElement, newElement:HTMLElement) => {
morphdom(currentElement, newElement, { childrenOnly: true });
};
});
52 changes: 52 additions & 0 deletions frontend/src/typings/idiomorph.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* -- copyright
* OpenProject is an open source project management software.
* Copyright (C) 2024 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.
* ++
*/

declare module 'idiomorph/dist/idiomorph.cjs' {
export const Idiomorph:{
morph(oldNode:Element|Document, newContent?:string|Element|Iterable<Element>|null, options?:{
morphStyle?:'innerHTML'|'outerHTML';
ignoreActive?:boolean;
ignoreActiveValue?:boolean;
head?:{
style?:'merge'|'append'|'morph'|'none';
};
callbacks?:{
beforeNodeAdded?:(node:ChildNode) => void|boolean;
afterNodeAdded?:(node:ChildNode) => void;
beforeNodeMorphed?:(oldNode:Element, newNode:Element) => void|boolean;
afterNodeMorphed?:(oldNode:Element, newNode:Element) => void;
beforeNodeRemoved?:(node:ChildNode) => void|boolean;
afterNodeRemoved?:(node:ChildNode) => void;
};
})
};

export = Idiomorph;
}
Loading